| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 | 71 |
| 72 const char* Dart::InitOnce(Dart_IsolateCreateCallback create, | 72 const char* Dart::InitOnce(Dart_IsolateCreateCallback create, |
| 73 Dart_IsolateInterruptCallback interrupt, | 73 Dart_IsolateInterruptCallback interrupt, |
| 74 Dart_IsolateUnhandledExceptionCallback unhandled, | 74 Dart_IsolateUnhandledExceptionCallback unhandled, |
| 75 Dart_IsolateShutdownCallback shutdown, | 75 Dart_IsolateShutdownCallback shutdown, |
| 76 Dart_FileOpenCallback file_open, | 76 Dart_FileOpenCallback file_open, |
| 77 Dart_FileReadCallback file_read, | 77 Dart_FileReadCallback file_read, |
| 78 Dart_FileWriteCallback file_write, | 78 Dart_FileWriteCallback file_write, |
| 79 Dart_FileCloseCallback file_close, | 79 Dart_FileCloseCallback file_close, |
| 80 Dart_EntropySource entropy_source, | 80 Dart_EntropySource entropy_source) { |
| 81 Dart_ServiceIsolateCreateCalback service_create) { | |
| 82 // TODO(iposva): Fix race condition here. | 81 // TODO(iposva): Fix race condition here. |
| 83 if (vm_isolate_ != NULL || !Flags::Initialized()) { | 82 if (vm_isolate_ != NULL || !Flags::Initialized()) { |
| 84 return "VM already initialized or flags not initialized."; | 83 return "VM already initialized or flags not initialized."; |
| 85 } | 84 } |
| 86 Isolate::SetFileCallbacks(file_open, file_read, file_write, file_close); | 85 Isolate::SetFileCallbacks(file_open, file_read, file_write, file_close); |
| 87 Isolate::SetEntropySourceCallback(entropy_source); | 86 Isolate::SetEntropySourceCallback(entropy_source); |
| 88 OS::InitOnce(); | 87 OS::InitOnce(); |
| 89 VirtualMemory::InitOnce(); | 88 VirtualMemory::InitOnce(); |
| 90 Isolate::InitOnce(); | 89 Isolate::InitOnce(); |
| 91 PortMap::InitOnce(); | 90 PortMap::InitOnce(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 Object::FinalizeVMIsolate(vm_isolate_); | 130 Object::FinalizeVMIsolate(vm_isolate_); |
| 132 } | 131 } |
| 133 // There is a planned and known asymmetry here: We enter one scope for the VM | 132 // There is a planned and known asymmetry here: We enter one scope for the VM |
| 134 // isolate so that we can allocate the "persistent" scoped handles for the | 133 // isolate so that we can allocate the "persistent" scoped handles for the |
| 135 // predefined API values (such as Dart_True, Dart_False and Dart_Null). | 134 // predefined API values (such as Dart_True, Dart_False and Dart_Null). |
| 136 Dart_EnterScope(); | 135 Dart_EnterScope(); |
| 137 Api::InitHandles(); | 136 Api::InitHandles(); |
| 138 | 137 |
| 139 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. | 138 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. |
| 140 Isolate::SetCreateCallback(create); | 139 Isolate::SetCreateCallback(create); |
| 141 Isolate::SetServiceCreateCallback(service_create); | |
| 142 Isolate::SetInterruptCallback(interrupt); | 140 Isolate::SetInterruptCallback(interrupt); |
| 143 Isolate::SetUnhandledExceptionCallback(unhandled); | 141 Isolate::SetUnhandledExceptionCallback(unhandled); |
| 144 Isolate::SetShutdownCallback(shutdown); | 142 Isolate::SetShutdownCallback(shutdown); |
| 143 |
| 144 Service::RunService(); |
| 145 |
| 145 return NULL; | 146 return NULL; |
| 146 } | 147 } |
| 147 | 148 |
| 148 | 149 |
| 149 const char* Dart::Cleanup() { | 150 const char* Dart::Cleanup() { |
| 150 #if 0 | 151 #if 0 |
| 151 // Ideally we should shutdown the VM isolate here, but the thread pool | 152 // Ideally we should shutdown the VM isolate here, but the thread pool |
| 152 // shutdown does not seem to ensure that all the threads have stopped | 153 // shutdown does not seem to ensure that all the threads have stopped |
| 153 // execution before it terminates, this results in racing isolates. | 154 // execution before it terminates, this results in racing isolates. |
| 154 if (vm_isolate_ == NULL) { | 155 if (vm_isolate_ == NULL) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 248 } |
| 248 isolate->megamorphic_cache_table()->InitMissHandler(); | 249 isolate->megamorphic_cache_table()->InitMissHandler(); |
| 249 | 250 |
| 250 isolate->heap()->EnableGrowthControl(); | 251 isolate->heap()->EnableGrowthControl(); |
| 251 isolate->set_init_callback_data(data); | 252 isolate->set_init_callback_data(data); |
| 252 Api::SetupAcquiredError(isolate); | 253 Api::SetupAcquiredError(isolate); |
| 253 if (FLAG_print_class_table) { | 254 if (FLAG_print_class_table) { |
| 254 isolate->class_table()->Print(); | 255 isolate->class_table()->Print(); |
| 255 } | 256 } |
| 256 | 257 |
| 258 Service::MaybeInjectVMServiceLibrary(isolate); |
| 259 |
| 260 Service::SendIsolateStartupMessage(); |
| 257 isolate->debugger()->NotifyIsolateCreated(); | 261 isolate->debugger()->NotifyIsolateCreated(); |
| 258 Service::SendIsolateStartupMessage(); | 262 |
| 259 // Create tag table. | 263 // Create tag table. |
| 260 isolate->set_tag_table( | 264 isolate->set_tag_table( |
| 261 GrowableObjectArray::Handle(GrowableObjectArray::New())); | 265 GrowableObjectArray::Handle(GrowableObjectArray::New())); |
| 262 // Set up default UserTag. | 266 // Set up default UserTag. |
| 263 const UserTag& default_tag = UserTag::Handle(UserTag::DefaultTag()); | 267 const UserTag& default_tag = UserTag::Handle(UserTag::DefaultTag()); |
| 264 isolate->set_current_tag(default_tag); | 268 isolate->set_current_tag(default_tag); |
| 265 | 269 |
| 266 return Error::null(); | 270 return Error::null(); |
| 267 } | 271 } |
| 268 | 272 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 291 return predefined_handles_->handles_.AllocateScopedHandle(); | 295 return predefined_handles_->handles_.AllocateScopedHandle(); |
| 292 } | 296 } |
| 293 | 297 |
| 294 | 298 |
| 295 bool Dart::IsReadOnlyHandle(uword address) { | 299 bool Dart::IsReadOnlyHandle(uword address) { |
| 296 ASSERT(predefined_handles_ != NULL); | 300 ASSERT(predefined_handles_ != NULL); |
| 297 return predefined_handles_->handles_.IsValidScopedHandle(address); | 301 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 298 } | 302 } |
| 299 | 303 |
| 300 } // namespace dart | 304 } // namespace dart |
| OLD | NEW |