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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "vm/unicode.h" | 52 #include "vm/unicode.h" |
53 #include "vm/uri.h" | 53 #include "vm/uri.h" |
54 #include "vm/verifier.h" | 54 #include "vm/verifier.h" |
55 #include "vm/version.h" | 55 #include "vm/version.h" |
56 | 56 |
57 namespace dart { | 57 namespace dart { |
58 | 58 |
59 // Facilitate quick access to the current zone once we have the current thread. | 59 // Facilitate quick access to the current zone once we have the current thread. |
60 #define Z (T->zone()) | 60 #define Z (T->zone()) |
61 | 61 |
62 DECLARE_FLAG(bool, use_dart_frontend); | |
63 DECLARE_FLAG(bool, print_class_table); | 62 DECLARE_FLAG(bool, print_class_table); |
64 DECLARE_FLAG(bool, verify_handles); | 63 DECLARE_FLAG(bool, verify_handles); |
65 DECLARE_FLAG(bool, use_dart_frontend); | |
66 #if defined(DART_NO_SNAPSHOT) | 64 #if defined(DART_NO_SNAPSHOT) |
67 DEFINE_FLAG(bool, | 65 DEFINE_FLAG(bool, |
68 check_function_fingerprints, | 66 check_function_fingerprints, |
69 true, | 67 true, |
70 "Check function fingerprints"); | 68 "Check function fingerprints"); |
71 #endif // defined(DART_NO_SNAPSHOT). | 69 #endif // defined(DART_NO_SNAPSHOT). |
72 DEFINE_FLAG(bool, | 70 DEFINE_FLAG(bool, |
73 verify_acquired_data, | 71 verify_acquired_data, |
74 false, | 72 false, |
75 "Verify correct API acquire/release of typed data."); | 73 "Verify correct API acquire/release of typed data."); |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 if (params->version != DART_INITIALIZE_PARAMS_CURRENT_VERSION) { | 1084 if (params->version != DART_INITIALIZE_PARAMS_CURRENT_VERSION) { |
1087 return strdup( | 1085 return strdup( |
1088 "Dart_Initialize: " | 1086 "Dart_Initialize: " |
1089 "Invalid Dart_InitializeParams version."); | 1087 "Invalid Dart_InitializeParams version."); |
1090 } | 1088 } |
1091 | 1089 |
1092 return Dart::InitOnce( | 1090 return Dart::InitOnce( |
1093 params->vm_snapshot_data, params->vm_snapshot_instructions, | 1091 params->vm_snapshot_data, params->vm_snapshot_instructions, |
1094 params->create, params->shutdown, params->cleanup, params->thread_exit, | 1092 params->create, params->shutdown, params->cleanup, params->thread_exit, |
1095 params->file_open, params->file_read, params->file_write, | 1093 params->file_open, params->file_read, params->file_write, |
1096 params->file_close, params->entropy_source, params->get_service_assets); | 1094 params->file_close, params->entropy_source, params->get_service_assets, |
| 1095 params->start_kernel_isolate); |
1097 } | 1096 } |
1098 | 1097 |
1099 DART_EXPORT char* Dart_Cleanup() { | 1098 DART_EXPORT char* Dart_Cleanup() { |
1100 CHECK_NO_ISOLATE(Isolate::Current()); | 1099 CHECK_NO_ISOLATE(Isolate::Current()); |
1101 const char* err_msg = Dart::Cleanup(); | 1100 const char* err_msg = Dart::Cleanup(); |
1102 if (err_msg != NULL) { | 1101 if (err_msg != NULL) { |
1103 return strdup(err_msg); | 1102 return strdup(err_msg); |
1104 } | 1103 } |
1105 return NULL; | 1104 return NULL; |
1106 } | 1105 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 return CreateIsolate(script_uri, main, snapshot_data, snapshot_instructions, | 1219 return CreateIsolate(script_uri, main, snapshot_data, snapshot_instructions, |
1221 -1, NULL, flags, callback_data, error); | 1220 -1, NULL, flags, callback_data, error); |
1222 } | 1221 } |
1223 | 1222 |
1224 DART_EXPORT Dart_Isolate Dart_CreateIsolateFromKernel(const char* script_uri, | 1223 DART_EXPORT Dart_Isolate Dart_CreateIsolateFromKernel(const char* script_uri, |
1225 const char* main, | 1224 const char* main, |
1226 void* kernel_program, | 1225 void* kernel_program, |
1227 Dart_IsolateFlags* flags, | 1226 Dart_IsolateFlags* flags, |
1228 void* callback_data, | 1227 void* callback_data, |
1229 char** error) { | 1228 char** error) { |
| 1229 // Setup default flags in case none were passed. |
| 1230 Dart_IsolateFlags api_flags; |
| 1231 if (flags == NULL) { |
| 1232 Isolate::FlagsInitialize(&api_flags); |
| 1233 flags = &api_flags; |
| 1234 } |
| 1235 flags->use_dart_frontend = true; |
1230 return CreateIsolate(script_uri, main, NULL, NULL, -1, | 1236 return CreateIsolate(script_uri, main, NULL, NULL, -1, |
1231 reinterpret_cast<kernel::Program*>(kernel_program), | 1237 reinterpret_cast<kernel::Program*>(kernel_program), |
1232 flags, callback_data, error); | 1238 flags, callback_data, error); |
1233 } | 1239 } |
1234 | 1240 |
1235 DART_EXPORT void Dart_ShutdownIsolate() { | 1241 DART_EXPORT void Dart_ShutdownIsolate() { |
1236 Thread* T = Thread::Current(); | 1242 Thread* T = Thread::Current(); |
1237 Isolate* I = T->isolate(); | 1243 Isolate* I = T->isolate(); |
1238 CHECK_ISOLATE(I); | 1244 CHECK_ISOLATE(I); |
1239 I->WaitForOutstandingSpawns(); | 1245 I->WaitForOutstandingSpawns(); |
(...skipping 3869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5109 } | 5115 } |
5110 if (column_offset < 0) { | 5116 if (column_offset < 0) { |
5111 return Api::NewError("%s: argument 'column_offset' must be positive number", | 5117 return Api::NewError("%s: argument 'column_offset' must be positive number", |
5112 CURRENT_FUNC); | 5118 CURRENT_FUNC); |
5113 } | 5119 } |
5114 CHECK_CALLBACK_STATE(T); | 5120 CHECK_CALLBACK_STATE(T); |
5115 CHECK_COMPILATION_ALLOWED(I); | 5121 CHECK_COMPILATION_ALLOWED(I); |
5116 | 5122 |
5117 Dart_Handle result; | 5123 Dart_Handle result; |
5118 #if !defined(DART_PRECOMPILED_RUNTIME) | 5124 #if !defined(DART_PRECOMPILED_RUNTIME) |
5119 if (FLAG_use_dart_frontend && !KernelIsolate::IsKernelIsolate(I)) { | 5125 if (I->use_dart_frontend()) { |
5120 if ((source == Api::Null()) || (source == NULL)) { | 5126 if ((source == Api::Null()) || (source == NULL)) { |
5121 RETURN_NULL_ERROR(source); | 5127 RETURN_NULL_ERROR(source); |
5122 } | 5128 } |
5123 void* kernel_pgm = reinterpret_cast<void*>(source); | 5129 void* kernel_pgm = reinterpret_cast<void*>(source); |
5124 result = LoadKernelProgram(T, resolved_url_str, kernel_pgm); | 5130 result = LoadKernelProgram(T, resolved_url_str, kernel_pgm); |
5125 if (::Dart_IsError(result)) { | 5131 if (::Dart_IsError(result)) { |
5126 return result; | 5132 return result; |
5127 } | 5133 } |
5128 library ^= Library::LookupLibrary(T, resolved_url_str); | 5134 library ^= Library::LookupLibrary(T, resolved_url_str); |
5129 if (library.IsNull()) { | 5135 if (library.IsNull()) { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5463 API_TIMELINE_DURATION; | 5469 API_TIMELINE_DURATION; |
5464 DARTSCOPE(Thread::Current()); | 5470 DARTSCOPE(Thread::Current()); |
5465 Isolate* I = T->isolate(); | 5471 Isolate* I = T->isolate(); |
5466 | 5472 |
5467 const String& url_str = Api::UnwrapStringHandle(Z, url); | 5473 const String& url_str = Api::UnwrapStringHandle(Z, url); |
5468 if (url_str.IsNull()) { | 5474 if (url_str.IsNull()) { |
5469 RETURN_TYPE_ERROR(Z, url, String); | 5475 RETURN_TYPE_ERROR(Z, url, String); |
5470 } | 5476 } |
5471 Dart_Handle result; | 5477 Dart_Handle result; |
5472 #if !defined(DART_PRECOMPILED_RUNTIME) | 5478 #if !defined(DART_PRECOMPILED_RUNTIME) |
5473 // Kernel isolate is loaded from script in case of dart_bootstrap | 5479 if (I->use_dart_frontend()) { |
5474 // even when FLAG_use_dart_frontend is true. Hence, do not interpret | |
5475 // |source| as a kernel if the current isolate is the kernel isolate. | |
5476 if (FLAG_use_dart_frontend && !KernelIsolate::IsKernelIsolate(I)) { | |
5477 result = LoadKernelProgram(T, url_str, reinterpret_cast<void*>(source)); | 5480 result = LoadKernelProgram(T, url_str, reinterpret_cast<void*>(source)); |
5478 if (::Dart_IsError(result)) { | 5481 if (::Dart_IsError(result)) { |
5479 return result; | 5482 return result; |
5480 } | 5483 } |
5481 return Api::NewHandle(T, Library::LookupLibrary(T, url_str)); | 5484 return Api::NewHandle(T, Library::LookupLibrary(T, url_str)); |
5482 } | 5485 } |
5483 #endif | 5486 #endif |
5484 if (::Dart_IsNull(resolved_url)) { | 5487 if (::Dart_IsNull(resolved_url)) { |
5485 resolved_url = url; | 5488 resolved_url = url; |
5486 } | 5489 } |
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6782 #endif | 6785 #endif |
6783 } | 6786 } |
6784 | 6787 |
6785 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6788 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
6786 #ifndef PRODUCT | 6789 #ifndef PRODUCT |
6787 Profiler::DumpStackTrace(context); | 6790 Profiler::DumpStackTrace(context); |
6788 #endif | 6791 #endif |
6789 } | 6792 } |
6790 | 6793 |
6791 } // namespace dart | 6794 } // namespace dart |
OLD | NEW |