| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 predefined_handles_ = new ReadOnlyHandles(); | 113 predefined_handles_ = new ReadOnlyHandles(); |
| 114 // Create the VM isolate and finish the VM initialization. | 114 // Create the VM isolate and finish the VM initialization. |
| 115 ASSERT(thread_pool_ == NULL); | 115 ASSERT(thread_pool_ == NULL); |
| 116 thread_pool_ = new ThreadPool(); | 116 thread_pool_ = new ThreadPool(); |
| 117 { | 117 { |
| 118 Thread* T = Thread::Current(); | 118 Thread* T = Thread::Current(); |
| 119 ASSERT(T != NULL); | 119 ASSERT(T != NULL); |
| 120 ASSERT(vm_isolate_ == NULL); | 120 ASSERT(vm_isolate_ == NULL); |
| 121 ASSERT(Flags::Initialized()); | 121 ASSERT(Flags::Initialized()); |
| 122 const bool is_vm_isolate = true; | 122 const bool is_vm_isolate = true; |
| 123 const bool precompiled = instructions_snapshot != NULL; |
| 123 | 124 |
| 124 // Setup default flags for the VM isolate. | 125 // Setup default flags for the VM isolate. |
| 125 Isolate::Flags vm_flags; | 126 Isolate::Flags vm_flags; |
| 126 Dart_IsolateFlags api_flags; | 127 Dart_IsolateFlags api_flags; |
| 127 vm_flags.CopyTo(&api_flags); | 128 vm_flags.CopyTo(&api_flags); |
| 128 vm_isolate_ = Isolate::Init("vm-isolate", api_flags, is_vm_isolate); | 129 vm_isolate_ = Isolate::Init("vm-isolate", api_flags, is_vm_isolate); |
| 130 vm_isolate_->set_compilation_allowed(!precompiled); |
| 129 // Verify assumptions about executing in the VM isolate. | 131 // Verify assumptions about executing in the VM isolate. |
| 130 ASSERT(vm_isolate_ == Isolate::Current()); | 132 ASSERT(vm_isolate_ == Isolate::Current()); |
| 131 ASSERT(vm_isolate_ == Thread::Current()->isolate()); | 133 ASSERT(vm_isolate_ == Thread::Current()->isolate()); |
| 132 | 134 |
| 133 StackZone zone(T); | 135 StackZone zone(T); |
| 134 HandleScope handle_scope(T); | 136 HandleScope handle_scope(T); |
| 135 Object::InitNull(vm_isolate_); | 137 Object::InitNull(vm_isolate_); |
| 136 ObjectStore::Init(vm_isolate_); | 138 ObjectStore::Init(vm_isolate_); |
| 137 TargetCPUFeatures::InitOnce(); | 139 TargetCPUFeatures::InitOnce(); |
| 138 Object::InitOnce(vm_isolate_); | 140 Object::InitOnce(vm_isolate_); |
| 139 ArgumentsDescriptor::InitOnce(); | 141 ArgumentsDescriptor::InitOnce(); |
| 140 StubCode::InitOnce(); | 142 // When precompiled the stub code is initialized from the snapshot. |
| 141 Thread::InitOnceAfterObjectAndStubCode(); | 143 if (!precompiled) { |
| 142 // Now that the needed stub has been generated, set the stack limit. | 144 StubCode::InitOnce(); |
| 143 vm_isolate_->InitializeStackLimit(); | 145 } |
| 144 if (vm_isolate_snapshot != NULL) { | 146 if (vm_isolate_snapshot != NULL) { |
| 145 const Snapshot* snapshot = Snapshot::SetupFromBuffer(vm_isolate_snapshot); | 147 const Snapshot* snapshot = Snapshot::SetupFromBuffer(vm_isolate_snapshot); |
| 146 if (snapshot == NULL) { | 148 if (snapshot == NULL) { |
| 147 return "Invalid vm isolate snapshot seen."; | 149 return "Invalid vm isolate snapshot seen."; |
| 148 } | 150 } |
| 149 ASSERT(snapshot->kind() == Snapshot::kFull); | 151 ASSERT(snapshot->kind() == Snapshot::kFull); |
| 150 VmIsolateSnapshotReader reader(snapshot->content(), | 152 VmIsolateSnapshotReader reader(snapshot->content(), |
| 151 snapshot->length(), | 153 snapshot->length(), |
| 152 instructions_snapshot, | 154 instructions_snapshot, |
| 153 T); | 155 T); |
| 154 const Error& error = Error::Handle(reader.ReadVmIsolateSnapshot()); | 156 const Error& error = Error::Handle(reader.ReadVmIsolateSnapshot()); |
| 155 if (!error.IsNull()) { | 157 if (!error.IsNull()) { |
| 156 return error.ToCString(); | 158 return error.ToCString(); |
| 157 } | 159 } |
| 158 if (FLAG_trace_isolates) { | 160 if (FLAG_trace_isolates) { |
| 159 OS::Print("Size of vm isolate snapshot = %" Pd "\n", | 161 OS::Print("Size of vm isolate snapshot = %" Pd "\n", |
| 160 snapshot->length()); | 162 snapshot->length()); |
| 161 vm_isolate_->heap()->PrintSizes(); | 163 vm_isolate_->heap()->PrintSizes(); |
| 162 MegamorphicCacheTable::PrintSizes(vm_isolate_); | 164 MegamorphicCacheTable::PrintSizes(vm_isolate_); |
| 163 intptr_t size; | 165 intptr_t size; |
| 164 intptr_t capacity; | 166 intptr_t capacity; |
| 165 Symbols::GetStats(vm_isolate_, &size, &capacity); | 167 Symbols::GetStats(vm_isolate_, &size, &capacity); |
| 166 OS::Print("VM Isolate: Number of symbols : %" Pd "\n", size); | 168 OS::Print("VM Isolate: Number of symbols : %" Pd "\n", size); |
| 167 OS::Print("VM Isolate: Symbol table capacity : %" Pd "\n", capacity); | 169 OS::Print("VM Isolate: Symbol table capacity : %" Pd "\n", capacity); |
| 168 } | 170 } |
| 169 } else { | 171 } else { |
| 170 Symbols::InitOnce(vm_isolate_); | 172 Symbols::InitOnce(vm_isolate_); |
| 171 } | 173 } |
| 174 Thread::InitOnceAfterObjectAndStubCode(); |
| 175 // Now that the needed stub has been generated, set the stack limit. |
| 176 vm_isolate_->InitializeStackLimit(); |
| 172 Scanner::InitOnce(); | 177 Scanner::InitOnce(); |
| 173 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 178 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| 174 // Dart VM requires at least SSE2. | 179 // Dart VM requires at least SSE2. |
| 175 if (!TargetCPUFeatures::sse2_supported()) { | 180 if (!TargetCPUFeatures::sse2_supported()) { |
| 176 return "SSE2 is required."; | 181 return "SSE2 is required."; |
| 177 } | 182 } |
| 178 #endif | 183 #endif |
| 179 Object::FinalizeVMIsolate(vm_isolate_); | 184 Object::FinalizeVMIsolate(vm_isolate_); |
| 180 #if defined(DEBUG) | 185 #if defined(DEBUG) |
| 181 vm_isolate_->heap()->Verify(kRequireMarked); | 186 vm_isolate_->heap()->Verify(kRequireMarked); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 return predefined_handles_->handles_.IsValidScopedHandle(address); | 409 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 405 } | 410 } |
| 406 | 411 |
| 407 | 412 |
| 408 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { | 413 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { |
| 409 ASSERT(predefined_handles_ != NULL); | 414 ASSERT(predefined_handles_ != NULL); |
| 410 return predefined_handles_->api_handles_.IsValidHandle(handle); | 415 return predefined_handles_->api_handles_.IsValidHandle(handle); |
| 411 } | 416 } |
| 412 | 417 |
| 413 } // namespace dart | 418 } // namespace dart |
| OLD | NEW |