| 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 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1294 snapshot_length, kernel_program, callback_data)); | 1294 snapshot_length, kernel_program, callback_data)); |
| 1295 if (error_obj.IsNull()) { | 1295 if (error_obj.IsNull()) { |
| 1296 #if defined(DART_NO_SNAPSHOT) && !defined(PRODUCT) | 1296 #if defined(DART_NO_SNAPSHOT) && !defined(PRODUCT) |
| 1297 if (FLAG_check_function_fingerprints && kernel_program == NULL) { | 1297 if (FLAG_check_function_fingerprints && kernel_program == NULL) { |
| 1298 Library::CheckFunctionFingerprints(); | 1298 Library::CheckFunctionFingerprints(); |
| 1299 } | 1299 } |
| 1300 #endif // defined(DART_NO_SNAPSHOT) && !defined(PRODUCT). | 1300 #endif // defined(DART_NO_SNAPSHOT) && !defined(PRODUCT). |
| 1301 // We exit the API scope entered above. | 1301 // We exit the API scope entered above. |
| 1302 Dart_ExitScope(); | 1302 Dart_ExitScope(); |
| 1303 // A Thread structure has been associated to the thread, we do the | 1303 // A Thread structure has been associated to the thread, we do the |
| 1304 // safepoint transition explicity here instead of using the | 1304 // safepoint transition explicitly here instead of using the |
| 1305 // TransitionXXX scope objects as the reverse transition happens | 1305 // TransitionXXX scope objects as the reverse transition happens |
| 1306 // outside this scope in Dart_ShutdownIsolate/Dart_ExitIsolate. | 1306 // outside this scope in Dart_ShutdownIsolate/Dart_ExitIsolate. |
| 1307 T->set_execution_state(Thread::kThreadInNative); | 1307 T->set_execution_state(Thread::kThreadInNative); |
| 1308 T->EnterSafepoint(); | 1308 T->EnterSafepoint(); |
| 1309 return Api::CastIsolate(I); | 1309 return Api::CastIsolate(I); |
| 1310 } | 1310 } |
| 1311 *error = strdup(error_obj.ToErrorCString()); | 1311 *error = strdup(error_obj.ToErrorCString()); |
| 1312 // We exit the API scope entered above. | 1312 // We exit the API scope entered above. |
| 1313 Dart_ExitScope(); | 1313 Dart_ExitScope(); |
| 1314 } | 1314 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1345 DART_EXPORT void Dart_ShutdownIsolate() { | 1345 DART_EXPORT void Dart_ShutdownIsolate() { |
| 1346 Thread* T = Thread::Current(); | 1346 Thread* T = Thread::Current(); |
| 1347 Isolate* I = T->isolate(); | 1347 Isolate* I = T->isolate(); |
| 1348 CHECK_ISOLATE(I); | 1348 CHECK_ISOLATE(I); |
| 1349 I->WaitForOutstandingSpawns(); | 1349 I->WaitForOutstandingSpawns(); |
| 1350 { | 1350 { |
| 1351 StackZone zone(T); | 1351 StackZone zone(T); |
| 1352 HandleScope handle_scope(T); | 1352 HandleScope handle_scope(T); |
| 1353 Dart::RunShutdownCallback(); | 1353 Dart::RunShutdownCallback(); |
| 1354 // The Thread structure is disassociated from the isolate, we do the | 1354 // The Thread structure is disassociated from the isolate, we do the |
| 1355 // safepoint transition explicity here instead of using the TransitionXXX | 1355 // safepoint transition explicitly here instead of using the TransitionXXX |
| 1356 // scope objects as the original transition happened outside this scope in | 1356 // scope objects as the original transition happened outside this scope in |
| 1357 // Dart_EnterIsolate/Dart_CreateIsolate. | 1357 // Dart_EnterIsolate/Dart_CreateIsolate. |
| 1358 T->ExitSafepoint(); | 1358 T->ExitSafepoint(); |
| 1359 T->set_execution_state(Thread::kThreadInVM); | 1359 T->set_execution_state(Thread::kThreadInVM); |
| 1360 ServiceIsolate::SendIsolateShutdownMessage(); | 1360 ServiceIsolate::SendIsolateShutdownMessage(); |
| 1361 } | 1361 } |
| 1362 Dart::ShutdownIsolate(); | 1362 Dart::ShutdownIsolate(); |
| 1363 } | 1363 } |
| 1364 | 1364 |
| 1365 | 1365 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 CHECK_NO_ISOLATE(Isolate::Current()); | 1397 CHECK_NO_ISOLATE(Isolate::Current()); |
| 1398 // TODO(16615): Validate isolate parameter. | 1398 // TODO(16615): Validate isolate parameter. |
| 1399 Isolate* iso = reinterpret_cast<Isolate*>(isolate); | 1399 Isolate* iso = reinterpret_cast<Isolate*>(isolate); |
| 1400 if (!Thread::EnterIsolate(iso)) { | 1400 if (!Thread::EnterIsolate(iso)) { |
| 1401 FATAL( | 1401 FATAL( |
| 1402 "Unable to Enter Isolate : " | 1402 "Unable to Enter Isolate : " |
| 1403 "Multiple mutators entering an isolate / " | 1403 "Multiple mutators entering an isolate / " |
| 1404 "Dart VM is shutting down"); | 1404 "Dart VM is shutting down"); |
| 1405 } | 1405 } |
| 1406 // A Thread structure has been associated to the thread, we do the | 1406 // A Thread structure has been associated to the thread, we do the |
| 1407 // safepoint transition explicity here instead of using the | 1407 // safepoint transition explicitly here instead of using the |
| 1408 // TransitionXXX scope objects as the reverse transition happens | 1408 // TransitionXXX scope objects as the reverse transition happens |
| 1409 // outside this scope in Dart_ExitIsolate/Dart_ShutdownIsolate. | 1409 // outside this scope in Dart_ExitIsolate/Dart_ShutdownIsolate. |
| 1410 Thread* T = Thread::Current(); | 1410 Thread* T = Thread::Current(); |
| 1411 T->set_execution_state(Thread::kThreadInNative); | 1411 T->set_execution_state(Thread::kThreadInNative); |
| 1412 T->EnterSafepoint(); | 1412 T->EnterSafepoint(); |
| 1413 } | 1413 } |
| 1414 | 1414 |
| 1415 | 1415 |
| 1416 DART_EXPORT void Dart_ThreadDisableProfiling() { | 1416 DART_EXPORT void Dart_ThreadDisableProfiling() { |
| 1417 OSThread* os_thread = OSThread::Current(); | 1417 OSThread* os_thread = OSThread::Current(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 return error; | 1539 return error; |
| 1540 } | 1540 } |
| 1541 return Dart_Null(); | 1541 return Dart_Null(); |
| 1542 } | 1542 } |
| 1543 | 1543 |
| 1544 | 1544 |
| 1545 DART_EXPORT void Dart_ExitIsolate() { | 1545 DART_EXPORT void Dart_ExitIsolate() { |
| 1546 Thread* T = Thread::Current(); | 1546 Thread* T = Thread::Current(); |
| 1547 CHECK_ISOLATE(T->isolate()); | 1547 CHECK_ISOLATE(T->isolate()); |
| 1548 // The Thread structure is disassociated from the isolate, we do the | 1548 // The Thread structure is disassociated from the isolate, we do the |
| 1549 // safepoint transition explicity here instead of using the TransitionXXX | 1549 // safepoint transition explicitly here instead of using the TransitionXXX |
| 1550 // scope objects as the original transition happened outside this scope in | 1550 // scope objects as the original transition happened outside this scope in |
| 1551 // Dart_EnterIsolate/Dart_CreateIsolate. | 1551 // Dart_EnterIsolate/Dart_CreateIsolate. |
| 1552 ASSERT(T->execution_state() == Thread::kThreadInNative); | 1552 ASSERT(T->execution_state() == Thread::kThreadInNative); |
| 1553 T->ExitSafepoint(); | 1553 T->ExitSafepoint(); |
| 1554 T->set_execution_state(Thread::kThreadInVM); | 1554 T->set_execution_state(Thread::kThreadInVM); |
| 1555 Thread::ExitIsolate(); | 1555 Thread::ExitIsolate(); |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 | 1558 |
| 1559 static uint8_t* ApiReallocate(uint8_t* ptr, | 1559 static uint8_t* ApiReallocate(uint8_t* ptr, |
| (...skipping 4316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5876 // futures of loadLibrary calls (deferred library loading). | 5876 // futures of loadLibrary calls (deferred library loading). |
| 5877 DART_EXPORT Dart_Handle Dart_FinalizeLoading(bool complete_futures) { | 5877 DART_EXPORT Dart_Handle Dart_FinalizeLoading(bool complete_futures) { |
| 5878 API_TIMELINE_DURATION; | 5878 API_TIMELINE_DURATION; |
| 5879 DARTSCOPE(Thread::Current()); | 5879 DARTSCOPE(Thread::Current()); |
| 5880 Isolate* I = T->isolate(); | 5880 Isolate* I = T->isolate(); |
| 5881 CHECK_CALLBACK_STATE(T); | 5881 CHECK_CALLBACK_STATE(T); |
| 5882 | 5882 |
| 5883 I->DoneLoading(); | 5883 I->DoneLoading(); |
| 5884 | 5884 |
| 5885 // TODO(hausner): move the remaining code below (finalization and | 5885 // TODO(hausner): move the remaining code below (finalization and |
| 5886 // invoing of _completeDeferredLoads) into Isolate::DoneLoading(). | 5886 // invoking of _completeDeferredLoads) into Isolate::DoneLoading(). |
| 5887 | 5887 |
| 5888 // Finalize all classes if needed. | 5888 // Finalize all classes if needed. |
| 5889 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T); | 5889 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T); |
| 5890 if (::Dart_IsError(state)) { | 5890 if (::Dart_IsError(state)) { |
| 5891 return state; | 5891 return state; |
| 5892 } | 5892 } |
| 5893 | 5893 |
| 5894 I->DoneFinalizing(); | 5894 I->DoneFinalizing(); |
| 5895 | 5895 |
| 5896 // Now that the newly loaded classes are finalized, notify the debugger | 5896 // Now that the newly loaded classes are finalized, notify the debugger |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6964 } | 6964 } |
| 6965 | 6965 |
| 6966 | 6966 |
| 6967 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6967 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
| 6968 #ifndef PRODUCT | 6968 #ifndef PRODUCT |
| 6969 Profiler::DumpStackTrace(context); | 6969 Profiler::DumpStackTrace(context); |
| 6970 #endif | 6970 #endif |
| 6971 } | 6971 } |
| 6972 | 6972 |
| 6973 } // namespace dart | 6973 } // namespace dart |
| OLD | NEW |