| 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 "vm/dart.h" | 5 #include "vm/dart.h" |
| 6 | 6 |
| 7 #include "vm/code_observers.h" | 7 #include "vm/code_observers.h" |
| 8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
| 9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // to ensure that the handles area is not trashed by automatic running of C++ | 63 // to ensure that the handles area is not trashed by automatic running of C++ |
| 64 // static destructors when 'exit()" is called by any isolate. There might be | 64 // static destructors when 'exit()" is called by any isolate. There might be |
| 65 // other isolates running at the same time and trashing the handles area will | 65 // other isolates running at the same time and trashing the handles area will |
| 66 // have unintended consequences. | 66 // have unintended consequences. |
| 67 class ReadOnlyHandles { | 67 class ReadOnlyHandles { |
| 68 public: | 68 public: |
| 69 ReadOnlyHandles() { } | 69 ReadOnlyHandles() { } |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 VMHandles handles_; | 72 VMHandles handles_; |
| 73 LocalHandles api_handles_; |
| 73 | 74 |
| 74 friend class Dart; | 75 friend class Dart; |
| 75 DISALLOW_COPY_AND_ASSIGN(ReadOnlyHandles); | 76 DISALLOW_COPY_AND_ASSIGN(ReadOnlyHandles); |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 | 79 |
| 79 const char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot, | 80 const char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot, |
| 80 Dart_IsolateCreateCallback create, | 81 Dart_IsolateCreateCallback create, |
| 81 Dart_IsolateInterruptCallback interrupt, | 82 Dart_IsolateInterruptCallback interrupt, |
| 82 Dart_IsolateUnhandledExceptionCallback unhandled, | 83 Dart_IsolateUnhandledExceptionCallback unhandled, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // Dart VM requires at least SSE2. | 172 // Dart VM requires at least SSE2. |
| 172 if (!TargetCPUFeatures::sse2_supported()) { | 173 if (!TargetCPUFeatures::sse2_supported()) { |
| 173 return "SSE2 is required."; | 174 return "SSE2 is required."; |
| 174 } | 175 } |
| 175 #endif | 176 #endif |
| 176 Object::FinalizeVMIsolate(vm_isolate_); | 177 Object::FinalizeVMIsolate(vm_isolate_); |
| 177 #if defined(DEBUG) | 178 #if defined(DEBUG) |
| 178 vm_isolate_->heap()->Verify(kRequireMarked); | 179 vm_isolate_->heap()->Verify(kRequireMarked); |
| 179 #endif | 180 #endif |
| 180 } | 181 } |
| 181 // There is a planned and known asymmetry here: We enter one scope for the VM | 182 // Allocate the "persistent" scoped handles for the predefined API |
| 182 // isolate so that we can allocate the "persistent" scoped handles for the | 183 // values (such as Dart_True, Dart_False and Dart_Null). |
| 183 // predefined API values (such as Dart_True, Dart_False and Dart_Null). | |
| 184 Dart_EnterScope(); | |
| 185 Api::InitHandles(); | 184 Api::InitHandles(); |
| 186 | 185 |
| 187 Thread::ExitIsolate(); // Unregister the VM isolate from this thread. | 186 Thread::ExitIsolate(); // Unregister the VM isolate from this thread. |
| 188 Isolate::SetCreateCallback(create); | 187 Isolate::SetCreateCallback(create); |
| 189 Isolate::SetInterruptCallback(interrupt); | 188 Isolate::SetInterruptCallback(interrupt); |
| 190 Isolate::SetUnhandledExceptionCallback(unhandled); | 189 Isolate::SetUnhandledExceptionCallback(unhandled); |
| 191 Isolate::SetShutdownCallback(shutdown); | 190 Isolate::SetShutdownCallback(shutdown); |
| 192 | 191 |
| 193 ServiceIsolate::Run(); | 192 ServiceIsolate::Run(); |
| 194 | 193 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } | 352 } |
| 354 | 353 |
| 355 | 354 |
| 356 uword Dart::AllocateReadOnlyHandle() { | 355 uword Dart::AllocateReadOnlyHandle() { |
| 357 ASSERT(Isolate::Current() == Dart::vm_isolate()); | 356 ASSERT(Isolate::Current() == Dart::vm_isolate()); |
| 358 ASSERT(predefined_handles_ != NULL); | 357 ASSERT(predefined_handles_ != NULL); |
| 359 return predefined_handles_->handles_.AllocateScopedHandle(); | 358 return predefined_handles_->handles_.AllocateScopedHandle(); |
| 360 } | 359 } |
| 361 | 360 |
| 362 | 361 |
| 362 LocalHandle* Dart::AllocateReadOnlyApiHandle() { |
| 363 ASSERT(Isolate::Current() == Dart::vm_isolate()); |
| 364 ASSERT(predefined_handles_ != NULL); |
| 365 return predefined_handles_->api_handles_.AllocateHandle(); |
| 366 } |
| 367 |
| 368 |
| 363 bool Dart::IsReadOnlyHandle(uword address) { | 369 bool Dart::IsReadOnlyHandle(uword address) { |
| 364 ASSERT(predefined_handles_ != NULL); | 370 ASSERT(predefined_handles_ != NULL); |
| 365 return predefined_handles_->handles_.IsValidScopedHandle(address); | 371 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 366 } | 372 } |
| 367 | 373 |
| 368 } // namespace dart | 374 } // namespace dart |
| OLD | NEW |