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