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 "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1657 | 1657 |
1658 | 1658 |
1659 DART_EXPORT Dart_Handle Dart_RunLoop() { | 1659 DART_EXPORT Dart_Handle Dart_RunLoop() { |
1660 Thread* T = Thread::Current(); | 1660 Thread* T = Thread::Current(); |
1661 Isolate* I = T->isolate(); | 1661 Isolate* I = T->isolate(); |
1662 CHECK_ISOLATE_SCOPE(I); | 1662 CHECK_ISOLATE_SCOPE(I); |
1663 CHECK_CALLBACK_STATE(T); | 1663 CHECK_CALLBACK_STATE(T); |
1664 Monitor monitor; | 1664 Monitor monitor; |
1665 MonitorLocker ml(&monitor); | 1665 MonitorLocker ml(&monitor); |
1666 { | 1666 { |
1667 SwitchIsolateScope switch_scope(NULL); | 1667 // The message handler run loop does not expect to have a current isolate |
1668 | 1668 // so we exit the isolate here and enter it again after the runloop is done. |
| 1669 Thread::ExitIsolate(); |
1669 RunLoopData data; | 1670 RunLoopData data; |
1670 data.monitor = &monitor; | 1671 data.monitor = &monitor; |
1671 data.done = false; | 1672 data.done = false; |
1672 I->message_handler()->Run( | 1673 I->message_handler()->Run( |
1673 Dart::thread_pool(), | 1674 Dart::thread_pool(), |
1674 NULL, RunLoopDone, reinterpret_cast<uword>(&data)); | 1675 NULL, RunLoopDone, reinterpret_cast<uword>(&data)); |
1675 while (!data.done) { | 1676 while (!data.done) { |
1676 ml.Wait(); | 1677 ml.Wait(); |
1677 } | 1678 } |
| 1679 Thread::EnterIsolate(I); |
1678 } | 1680 } |
1679 if (I->object_store()->sticky_error() != Object::null()) { | 1681 if (I->object_store()->sticky_error() != Object::null()) { |
1680 Dart_Handle error = Api::NewHandle(I, I->object_store()->sticky_error()); | 1682 Dart_Handle error = Api::NewHandle(I, I->object_store()->sticky_error()); |
1681 I->object_store()->clear_sticky_error(); | 1683 I->object_store()->clear_sticky_error(); |
1682 return error; | 1684 return error; |
1683 } | 1685 } |
1684 if (FLAG_print_class_table) { | 1686 if (FLAG_print_class_table) { |
1685 HANDLESCOPE(T); | 1687 HANDLESCOPE(T); |
1686 I->class_table()->Print(); | 1688 I->class_table()->Print(); |
1687 } | 1689 } |
(...skipping 4396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6084 ApiReallocate); | 6086 ApiReallocate); |
6085 writer.WriteFullSnapshot(); | 6087 writer.WriteFullSnapshot(); |
6086 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 6088 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
6087 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 6089 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
6088 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); | 6090 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); |
6089 | 6091 |
6090 return Api::Success(); | 6092 return Api::Success(); |
6091 } | 6093 } |
6092 | 6094 |
6093 } // namespace dart | 6095 } // namespace dart |
OLD | NEW |