| 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/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 #endif | 132 #endif |
| 133 PremarkingVisitor premarker(vm_isolate_); | 133 PremarkingVisitor premarker(vm_isolate_); |
| 134 vm_isolate_->heap()->WriteProtect(false); | 134 vm_isolate_->heap()->WriteProtect(false); |
| 135 vm_isolate_->heap()->IterateOldObjects(&premarker); | 135 vm_isolate_->heap()->IterateOldObjects(&premarker); |
| 136 vm_isolate_->heap()->WriteProtect(true); | 136 vm_isolate_->heap()->WriteProtect(true); |
| 137 } | 137 } |
| 138 // There is a planned and known asymmetry here: We enter one scope for the VM | 138 // There is a planned and known asymmetry here: We enter one scope for the VM |
| 139 // isolate so that we can allocate the "persistent" scoped handles for the | 139 // isolate so that we can allocate the "persistent" scoped handles for the |
| 140 // predefined API values (such as Dart_True, Dart_False and Dart_Null). | 140 // predefined API values (such as Dart_True, Dart_False and Dart_Null). |
| 141 START_TIMER(vm_isolate_, time_native_execution); | |
| 142 Dart_EnterScope(); | 141 Dart_EnterScope(); |
| 143 Api::InitHandles(); | 142 Api::InitHandles(); |
| 144 | 143 |
| 145 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. | 144 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. |
| 146 Isolate::SetCreateCallback(create); | 145 Isolate::SetCreateCallback(create); |
| 147 Isolate::SetServiceCreateCallback(service_create); | 146 Isolate::SetServiceCreateCallback(service_create); |
| 148 Isolate::SetInterruptCallback(interrupt); | 147 Isolate::SetInterruptCallback(interrupt); |
| 149 Isolate::SetUnhandledExceptionCallback(unhandled); | 148 Isolate::SetUnhandledExceptionCallback(unhandled); |
| 150 Isolate::SetShutdownCallback(shutdown); | 149 Isolate::SetShutdownCallback(shutdown); |
| 151 return NULL; | 150 return NULL; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 165 | 164 |
| 166 delete thread_pool_; | 165 delete thread_pool_; |
| 167 thread_pool_ = NULL; | 166 thread_pool_ = NULL; |
| 168 | 167 |
| 169 // Set the VM isolate as current isolate. | 168 // Set the VM isolate as current isolate. |
| 170 Isolate::SetCurrent(vm_isolate_); | 169 Isolate::SetCurrent(vm_isolate_); |
| 171 | 170 |
| 172 // There is a planned and known asymmetry here: We exit one scope for the VM | 171 // There is a planned and known asymmetry here: We exit one scope for the VM |
| 173 // isolate to account for the scope that was entered in Dart_InitOnce. | 172 // isolate to account for the scope that was entered in Dart_InitOnce. |
| 174 Dart_ExitScope(); | 173 Dart_ExitScope(); |
| 175 STOP_TIMER(vm_isolate_, time_native_execution); | |
| 176 | 174 |
| 177 ShutdownIsolate(); | 175 ShutdownIsolate(); |
| 178 vm_isolate_ = NULL; | 176 vm_isolate_ = NULL; |
| 179 #endif | 177 #endif |
| 180 | 178 |
| 181 Profiler::Shutdown(); | 179 Profiler::Shutdown(); |
| 182 CodeObservers::DeleteAll(); | 180 CodeObservers::DeleteAll(); |
| 183 | 181 |
| 184 return NULL; | 182 return NULL; |
| 185 } | 183 } |
| 186 | 184 |
| 187 | 185 |
| 188 Isolate* Dart::CreateIsolate(const char* name_prefix) { | 186 Isolate* Dart::CreateIsolate(const char* name_prefix) { |
| 189 // Create a new isolate. | 187 // Create a new isolate. |
| 190 Isolate* isolate = Isolate::Init(name_prefix); | 188 Isolate* isolate = Isolate::Init(name_prefix); |
| 191 ASSERT(isolate != NULL); | 189 ASSERT(isolate != NULL); |
| 192 return isolate; | 190 return isolate; |
| 193 } | 191 } |
| 194 | 192 |
| 195 | 193 |
| 196 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { | 194 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { |
| 197 // Initialize the new isolate. | 195 // Initialize the new isolate. |
| 196 TIMERSCOPE(time_isolate_initialization); |
| 198 Isolate* isolate = Isolate::Current(); | 197 Isolate* isolate = Isolate::Current(); |
| 199 TIMERSCOPE(isolate, time_isolate_initialization); | |
| 200 ASSERT(isolate != NULL); | 198 ASSERT(isolate != NULL); |
| 201 StackZone zone(isolate); | 199 StackZone zone(isolate); |
| 202 HandleScope handle_scope(isolate); | 200 HandleScope handle_scope(isolate); |
| 203 Heap::Init(isolate); | 201 Heap::Init(isolate); |
| 204 ObjectIdRing::Init(isolate); | 202 ObjectIdRing::Init(isolate); |
| 205 ObjectStore::Init(isolate); | 203 ObjectStore::Init(isolate); |
| 206 | 204 |
| 207 if (snapshot_buffer == NULL) { | 205 if (snapshot_buffer == NULL) { |
| 208 const Error& error = Error::Handle(Object::Init(isolate)); | 206 const Error& error = Error::Handle(Object::Init(isolate)); |
| 209 if (!error.IsNull()) { | 207 if (!error.IsNull()) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 return predefined_handles_->handles_.AllocateScopedHandle(); | 272 return predefined_handles_->handles_.AllocateScopedHandle(); |
| 275 } | 273 } |
| 276 | 274 |
| 277 | 275 |
| 278 bool Dart::IsReadOnlyHandle(uword address) { | 276 bool Dart::IsReadOnlyHandle(uword address) { |
| 279 ASSERT(predefined_handles_ != NULL); | 277 ASSERT(predefined_handles_ != NULL); |
| 280 return predefined_handles_->handles_.IsValidScopedHandle(address); | 278 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 281 } | 279 } |
| 282 | 280 |
| 283 } // namespace dart | 281 } // namespace dart |
| OLD | NEW |