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 "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 | 1358 |
1359 DART_EXPORT void Dart_ThreadEnableProfiling() { | 1359 DART_EXPORT void Dart_ThreadEnableProfiling() { |
1360 OSThread* os_thread = OSThread::Current(); | 1360 OSThread* os_thread = OSThread::Current(); |
1361 if (os_thread == NULL) { | 1361 if (os_thread == NULL) { |
1362 return; | 1362 return; |
1363 } | 1363 } |
1364 os_thread->EnableThreadInterrupts(); | 1364 os_thread->EnableThreadInterrupts(); |
1365 } | 1365 } |
1366 | 1366 |
1367 | 1367 |
| 1368 DART_EXPORT bool Dart_ShouldPauseOnStart() { |
| 1369 Isolate* isolate = Isolate::Current(); |
| 1370 CHECK_ISOLATE(isolate); |
| 1371 return isolate->message_handler()->should_pause_on_start(); |
| 1372 } |
| 1373 |
| 1374 |
| 1375 DART_EXPORT void Dart_SetShouldPauseOnStart(bool should_pause) { |
| 1376 Isolate* isolate = Isolate::Current(); |
| 1377 CHECK_ISOLATE(isolate); |
| 1378 return isolate->message_handler()->set_should_pause_on_start(should_pause); |
| 1379 } |
| 1380 |
| 1381 |
| 1382 DART_EXPORT bool Dart_IsPausedOnStart() { |
| 1383 Isolate* isolate = Isolate::Current(); |
| 1384 CHECK_ISOLATE(isolate); |
| 1385 return isolate->message_handler()->is_paused_on_start(); |
| 1386 } |
| 1387 |
| 1388 |
| 1389 DART_EXPORT void Dart_SetPausedOnStart(bool paused) { |
| 1390 Isolate* isolate = Isolate::Current(); |
| 1391 CHECK_ISOLATE(isolate); |
| 1392 if (isolate->message_handler()->is_paused_on_start() != paused) { |
| 1393 isolate->message_handler()->PausedOnStart(paused); |
| 1394 } |
| 1395 } |
| 1396 |
| 1397 |
| 1398 DART_EXPORT bool Dart_ShouldPauseOnExit() { |
| 1399 Isolate* isolate = Isolate::Current(); |
| 1400 CHECK_ISOLATE(isolate); |
| 1401 return isolate->message_handler()->should_pause_on_exit(); |
| 1402 } |
| 1403 |
| 1404 |
| 1405 DART_EXPORT void Dart_SetShouldPauseOnExit(bool should_pause) { |
| 1406 Isolate* isolate = Isolate::Current(); |
| 1407 CHECK_ISOLATE(isolate); |
| 1408 return isolate->message_handler()->set_should_pause_on_exit(should_pause); |
| 1409 } |
| 1410 |
| 1411 |
| 1412 DART_EXPORT bool Dart_IsPausedOnExit() { |
| 1413 Isolate* isolate = Isolate::Current(); |
| 1414 CHECK_ISOLATE(isolate); |
| 1415 return isolate->message_handler()->is_paused_on_exit(); |
| 1416 } |
| 1417 |
| 1418 |
| 1419 DART_EXPORT void Dart_SetPausedOnExit(bool paused) { |
| 1420 Isolate* isolate = Isolate::Current(); |
| 1421 CHECK_ISOLATE(isolate); |
| 1422 if (isolate->message_handler()->is_paused_on_exit() != paused) { |
| 1423 isolate->message_handler()->PausedOnExit(paused); |
| 1424 } |
| 1425 } |
| 1426 |
| 1427 |
1368 DART_EXPORT void Dart_ExitIsolate() { | 1428 DART_EXPORT void Dart_ExitIsolate() { |
1369 Thread* T = Thread::Current(); | 1429 Thread* T = Thread::Current(); |
1370 CHECK_ISOLATE(T->isolate()); | 1430 CHECK_ISOLATE(T->isolate()); |
1371 // The Thread structure is disassociated from the isolate, we do the | 1431 // The Thread structure is disassociated from the isolate, we do the |
1372 // safepoint transition explicity here instead of using the TransitionXXX | 1432 // safepoint transition explicity here instead of using the TransitionXXX |
1373 // scope objects as the original transition happened outside this scope in | 1433 // scope objects as the original transition happened outside this scope in |
1374 // Dart_EnterIsolate/Dart_CreateIsolate. | 1434 // Dart_EnterIsolate/Dart_CreateIsolate. |
1375 ASSERT(T->execution_state() == Thread::kThreadInNative); | 1435 ASSERT(T->execution_state() == Thread::kThreadInNative); |
1376 T->ExitSafepoint(); | 1436 T->ExitSafepoint(); |
1377 T->set_execution_state(Thread::kThreadInVM); | 1437 T->set_execution_state(Thread::kThreadInVM); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 TransitionNativeToVM transition(T); | 1632 TransitionNativeToVM transition(T); |
1573 if (I->message_handler()->HandleNextMessage() != MessageHandler::kOK) { | 1633 if (I->message_handler()->HandleNextMessage() != MessageHandler::kOK) { |
1574 Dart_Handle error = Api::NewHandle(T, I->object_store()->sticky_error()); | 1634 Dart_Handle error = Api::NewHandle(T, I->object_store()->sticky_error()); |
1575 I->object_store()->clear_sticky_error(); | 1635 I->object_store()->clear_sticky_error(); |
1576 return error; | 1636 return error; |
1577 } | 1637 } |
1578 return Api::Success(); | 1638 return Api::Success(); |
1579 } | 1639 } |
1580 | 1640 |
1581 | 1641 |
| 1642 DART_EXPORT Dart_Handle Dart_HandleMessages() { |
| 1643 Thread* T = Thread::Current(); |
| 1644 Isolate* I = T->isolate(); |
| 1645 CHECK_API_SCOPE(T); |
| 1646 CHECK_CALLBACK_STATE(T); |
| 1647 API_TIMELINE_BEGIN_END; |
| 1648 TransitionNativeToVM transition(T); |
| 1649 if (I->message_handler()->HandleAllMessages() != MessageHandler::kOK) { |
| 1650 Dart_Handle error = Api::NewHandle(T, I->object_store()->sticky_error()); |
| 1651 I->object_store()->clear_sticky_error(); |
| 1652 return error; |
| 1653 } |
| 1654 return Api::Success(); |
| 1655 } |
| 1656 |
| 1657 |
1582 DART_EXPORT bool Dart_HandleServiceMessages() { | 1658 DART_EXPORT bool Dart_HandleServiceMessages() { |
1583 Thread* T = Thread::Current(); | 1659 Thread* T = Thread::Current(); |
1584 Isolate* I = T->isolate(); | 1660 Isolate* I = T->isolate(); |
1585 CHECK_API_SCOPE(T); | 1661 CHECK_API_SCOPE(T); |
1586 CHECK_CALLBACK_STATE(T); | 1662 CHECK_CALLBACK_STATE(T); |
1587 API_TIMELINE_DURATION; | 1663 API_TIMELINE_DURATION; |
1588 TransitionNativeToVM transition(T); | 1664 TransitionNativeToVM transition(T); |
1589 ASSERT(I->GetAndClearResumeRequest() == false); | 1665 ASSERT(I->GetAndClearResumeRequest() == false); |
1590 MessageHandler::MessageStatus status = | 1666 MessageHandler::MessageStatus status = |
1591 I->message_handler()->HandleOOBMessages(); | 1667 I->message_handler()->HandleOOBMessages(); |
(...skipping 4423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6015 return Api::Success(); | 6091 return Api::Success(); |
6016 } | 6092 } |
6017 #endif // DART_PRECOMPILER | 6093 #endif // DART_PRECOMPILER |
6018 | 6094 |
6019 | 6095 |
6020 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { | 6096 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { |
6021 return Dart::IsRunningPrecompiledCode(); | 6097 return Dart::IsRunningPrecompiledCode(); |
6022 } | 6098 } |
6023 | 6099 |
6024 } // namespace dart | 6100 } // namespace dart |
OLD | NEW |