OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
8 | 8 |
9 #include "lib/stacktrace.h" | 9 #include "lib/stacktrace.h" |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 return Api::CastIsolate(I); | 1197 return Api::CastIsolate(I); |
1198 } | 1198 } |
1199 *error = strdup(error_obj.ToErrorCString()); | 1199 *error = strdup(error_obj.ToErrorCString()); |
1200 // We exit the API scope entered above. | 1200 // We exit the API scope entered above. |
1201 Dart_ExitScope(); | 1201 Dart_ExitScope(); |
1202 } | 1202 } |
1203 Dart::ShutdownIsolate(); | 1203 Dart::ShutdownIsolate(); |
1204 return reinterpret_cast<Dart_Isolate>(NULL); | 1204 return reinterpret_cast<Dart_Isolate>(NULL); |
1205 } | 1205 } |
1206 | 1206 |
| 1207 DART_EXPORT void Dart_IsolateFlagsInitialize(Dart_IsolateFlags* flags) { |
| 1208 Isolate::FlagsInitialize(flags); |
| 1209 } |
| 1210 |
1207 DART_EXPORT Dart_Isolate | 1211 DART_EXPORT Dart_Isolate |
1208 Dart_CreateIsolate(const char* script_uri, | 1212 Dart_CreateIsolate(const char* script_uri, |
1209 const char* main, | 1213 const char* main, |
1210 const uint8_t* snapshot_data, | 1214 const uint8_t* snapshot_data, |
1211 const uint8_t* snapshot_instructions, | 1215 const uint8_t* snapshot_instructions, |
1212 Dart_IsolateFlags* flags, | 1216 Dart_IsolateFlags* flags, |
1213 void* callback_data, | 1217 void* callback_data, |
1214 char** error) { | 1218 char** error) { |
1215 return CreateIsolate(script_uri, main, snapshot_data, snapshot_instructions, | 1219 return CreateIsolate(script_uri, main, snapshot_data, snapshot_instructions, |
1216 -1, NULL, flags, callback_data, error); | 1220 -1, NULL, flags, callback_data, error); |
(...skipping 5509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6726 writer.WriteFullSnapshot(); | 6730 writer.WriteFullSnapshot(); |
6727 | 6731 |
6728 *isolate_snapshot_data_size = writer.IsolateSnapshotSize(); | 6732 *isolate_snapshot_data_size = writer.IsolateSnapshotSize(); |
6729 *isolate_snapshot_instructions_size = | 6733 *isolate_snapshot_instructions_size = |
6730 isolate_image_writer.InstructionsBlobSize(); | 6734 isolate_image_writer.InstructionsBlobSize(); |
6731 | 6735 |
6732 return Api::Success(); | 6736 return Api::Success(); |
6733 #endif | 6737 #endif |
6734 } | 6738 } |
6735 | 6739 |
| 6740 DART_EXPORT Dart_Handle Dart_GetObfuscationMap(uint8_t** buffer, |
| 6741 intptr_t* buffer_length) { |
| 6742 #if defined(DART_PRECOMPILED_RUNTIME) |
| 6743 return Api::NewError("No obfuscation map to save on an AOT runtime."); |
| 6744 #elif !defined(DART_PRECOMPILER) |
| 6745 return Api::NewError("Obfuscation is only supported for AOT compiler."); |
| 6746 #else |
| 6747 Thread* thread = Thread::Current(); |
| 6748 DARTSCOPE(thread); |
| 6749 Isolate* isolate = thread->isolate(); |
| 6750 |
| 6751 if (buffer == NULL) { |
| 6752 RETURN_NULL_ERROR(buffer); |
| 6753 } |
| 6754 if (buffer_length == NULL) { |
| 6755 RETURN_NULL_ERROR(buffer_length); |
| 6756 } |
| 6757 |
| 6758 // Note: can't use JSONStream in PRODUCT builds. |
| 6759 const intptr_t kInitialBufferSize = 1 * MB; |
| 6760 TextBuffer text_buffer(kInitialBufferSize); |
| 6761 |
| 6762 text_buffer.AddChar('['); |
| 6763 if (isolate->obfuscation_map() != NULL) { |
| 6764 for (intptr_t i = 0; isolate->obfuscation_map()[i] != NULL; i++) { |
| 6765 if (i > 0) { |
| 6766 text_buffer.AddChar(','); |
| 6767 } |
| 6768 text_buffer.AddChar('"'); |
| 6769 text_buffer.AddEscapedString(isolate->obfuscation_map()[i]); |
| 6770 text_buffer.AddChar('"'); |
| 6771 } |
| 6772 } |
| 6773 text_buffer.AddChar(']'); |
| 6774 |
| 6775 *buffer_length = text_buffer.length(); |
| 6776 *reinterpret_cast<char**>(buffer) = text_buffer.Steal(); |
| 6777 return Api::Success(); |
| 6778 #endif |
| 6779 } |
| 6780 |
6736 DART_EXPORT bool Dart_IsPrecompiledRuntime() { | 6781 DART_EXPORT bool Dart_IsPrecompiledRuntime() { |
6737 #if defined(DART_PRECOMPILED_RUNTIME) | 6782 #if defined(DART_PRECOMPILED_RUNTIME) |
6738 return true; | 6783 return true; |
6739 #else | 6784 #else |
6740 return false; | 6785 return false; |
6741 #endif | 6786 #endif |
6742 } | 6787 } |
6743 | 6788 |
6744 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6789 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
6745 #ifndef PRODUCT | 6790 #ifndef PRODUCT |
6746 Profiler::DumpStackTrace(context); | 6791 Profiler::DumpStackTrace(context); |
6747 #endif | 6792 #endif |
6748 } | 6793 } |
6749 | 6794 |
6750 } // namespace dart | 6795 } // namespace dart |
OLD | NEW |