OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "vm/dart.h" | 5 #include "vm/dart.h" |
6 | 6 |
7 #include "vm/dart_api_state.h" | 7 #include "vm/dart_api_state.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/freelist.h" | 9 #include "vm/freelist.h" |
10 #include "vm/handles.h" | 10 #include "vm/handles.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 if (!obj->IsMarked()) { | 43 if (!obj->IsMarked()) { |
44 obj->SetMarkBit(); | 44 obj->SetMarkBit(); |
45 } | 45 } |
46 } | 46 } |
47 }; | 47 }; |
48 | 48 |
49 | 49 |
50 // TODO(turnidge): We should add a corresponding Dart::Cleanup. | 50 // TODO(turnidge): We should add a corresponding Dart::Cleanup. |
51 bool Dart::InitOnce(Dart_IsolateCreateCallback create, | 51 bool Dart::InitOnce(Dart_IsolateCreateCallback create, |
52 Dart_IsolateInterruptCallback interrupt, | 52 Dart_IsolateInterruptCallback interrupt, |
| 53 Dart_IsolateUnhandledExceptionCallback unhandled, |
53 Dart_IsolateShutdownCallback shutdown) { | 54 Dart_IsolateShutdownCallback shutdown) { |
54 // TODO(iposva): Fix race condition here. | 55 // TODO(iposva): Fix race condition here. |
55 if (vm_isolate_ != NULL || !Flags::Initialized()) { | 56 if (vm_isolate_ != NULL || !Flags::Initialized()) { |
56 return false; | 57 return false; |
57 } | 58 } |
58 OS::InitOnce(); | 59 OS::InitOnce(); |
59 VirtualMemory::InitOnce(); | 60 VirtualMemory::InitOnce(); |
60 Isolate::InitOnce(); | 61 Isolate::InitOnce(); |
61 PortMap::InitOnce(); | 62 PortMap::InitOnce(); |
62 FreeListElement::InitOnce(); | 63 FreeListElement::InitOnce(); |
(...skipping 18 matching lines...) Expand all Loading... |
81 // Dart VM requires at least SSE3. | 82 // Dart VM requires at least SSE3. |
82 if (!CPUFeatures::sse3_supported()) return false; | 83 if (!CPUFeatures::sse3_supported()) return false; |
83 #endif | 84 #endif |
84 PremarkingVisitor premarker(vm_isolate_); | 85 PremarkingVisitor premarker(vm_isolate_); |
85 vm_isolate_->heap()->IterateOldObjects(&premarker); | 86 vm_isolate_->heap()->IterateOldObjects(&premarker); |
86 vm_isolate_->heap()->WriteProtect(true); | 87 vm_isolate_->heap()->WriteProtect(true); |
87 } | 88 } |
88 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. | 89 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. |
89 Isolate::SetCreateCallback(create); | 90 Isolate::SetCreateCallback(create); |
90 Isolate::SetInterruptCallback(interrupt); | 91 Isolate::SetInterruptCallback(interrupt); |
| 92 Isolate::SetUnhandledExceptionCallback(unhandled); |
91 Isolate::SetShutdownCallback(shutdown); | 93 Isolate::SetShutdownCallback(shutdown); |
92 return true; | 94 return true; |
93 } | 95 } |
94 | 96 |
95 | 97 |
96 Isolate* Dart::CreateIsolate(const char* name_prefix) { | 98 Isolate* Dart::CreateIsolate(const char* name_prefix) { |
97 // Create a new isolate. | 99 // Create a new isolate. |
98 Isolate* isolate = Isolate::Init(name_prefix); | 100 Isolate* isolate = Isolate::Init(name_prefix); |
99 ASSERT(isolate != NULL); | 101 ASSERT(isolate != NULL); |
100 return isolate; | 102 return isolate; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 isolate->Shutdown(); | 185 isolate->Shutdown(); |
184 delete isolate; | 186 delete isolate; |
185 | 187 |
186 Dart_IsolateShutdownCallback callback = Isolate::ShutdownCallback(); | 188 Dart_IsolateShutdownCallback callback = Isolate::ShutdownCallback(); |
187 if (callback != NULL) { | 189 if (callback != NULL) { |
188 (callback)(callback_data); | 190 (callback)(callback_data); |
189 } | 191 } |
190 } | 192 } |
191 | 193 |
192 } // namespace dart | 194 } // namespace dart |
OLD | NEW |