Chromium Code Reviews| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 predefined_handles_ = new ReadOnlyHandles(); | 112 predefined_handles_ = new ReadOnlyHandles(); |
| 113 // Create the VM isolate and finish the VM initialization. | 113 // Create the VM isolate and finish the VM initialization. |
| 114 ASSERT(thread_pool_ == NULL); | 114 ASSERT(thread_pool_ == NULL); |
| 115 thread_pool_ = new ThreadPool(); | 115 thread_pool_ = new ThreadPool(); |
| 116 { | 116 { |
| 117 Thread* T = Thread::Current(); | 117 Thread* T = Thread::Current(); |
| 118 ASSERT(T != NULL); | 118 ASSERT(T != NULL); |
| 119 ASSERT(vm_isolate_ == NULL); | 119 ASSERT(vm_isolate_ == NULL); |
| 120 ASSERT(Flags::Initialized()); | 120 ASSERT(Flags::Initialized()); |
| 121 const bool is_vm_isolate = true; | 121 const bool is_vm_isolate = true; |
| 122 const bool precompiled = instructions_snapshot != NULL; | |
| 122 | 123 |
| 123 // Setup default flags for the VM isolate. | 124 // Setup default flags for the VM isolate. |
| 124 Isolate::Flags vm_flags; | 125 Isolate::Flags vm_flags; |
| 125 Dart_IsolateFlags api_flags; | 126 Dart_IsolateFlags api_flags; |
| 126 vm_flags.CopyTo(&api_flags); | 127 vm_flags.CopyTo(&api_flags); |
| 127 vm_isolate_ = Isolate::Init("vm-isolate", api_flags, is_vm_isolate); | 128 vm_isolate_ = Isolate::Init("vm-isolate", api_flags, is_vm_isolate); |
| 129 vm_isolate_->set_compilation_allowed(!precompiled); | |
| 128 // Verify assumptions about executing in the VM isolate. | 130 // Verify assumptions about executing in the VM isolate. |
| 129 ASSERT(vm_isolate_ == Isolate::Current()); | 131 ASSERT(vm_isolate_ == Isolate::Current()); |
| 130 ASSERT(vm_isolate_ == Thread::Current()->isolate()); | 132 ASSERT(vm_isolate_ == Thread::Current()->isolate()); |
| 131 | 133 |
| 132 StackZone zone(T); | 134 StackZone zone(T); |
| 133 HandleScope handle_scope(T); | 135 HandleScope handle_scope(T); |
| 134 Object::InitNull(vm_isolate_); | 136 Object::InitNull(vm_isolate_); |
| 135 ObjectStore::Init(vm_isolate_); | 137 ObjectStore::Init(vm_isolate_); |
| 136 TargetCPUFeatures::InitOnce(); | 138 TargetCPUFeatures::InitOnce(); |
| 137 Object::InitOnce(vm_isolate_); | 139 Object::InitOnce(vm_isolate_); |
| 138 ArgumentsDescriptor::InitOnce(); | 140 ArgumentsDescriptor::InitOnce(); |
| 139 StubCode::InitOnce(); | 141 if (precompiled) { |
| 140 Thread::InitOnceAfterObjectAndStubCode(); | 142 // Stub code loaded from snapshot. |
| 141 // Now that the needed stub has been generated, set the stack limit. | 143 } else { |
| 142 vm_isolate_->InitializeStackLimit(); | 144 StubCode::InitOnce(); |
| 145 } | |
|
siva
2015/09/14 20:32:59
Would read better as:
// When precompiling the st
rmacnak
2015/09/15 17:56:42
Done.
| |
| 143 if (vm_isolate_snapshot != NULL) { | 146 if (vm_isolate_snapshot != NULL) { |
| 144 const Snapshot* snapshot = Snapshot::SetupFromBuffer(vm_isolate_snapshot); | 147 const Snapshot* snapshot = Snapshot::SetupFromBuffer(vm_isolate_snapshot); |
| 145 if (snapshot == NULL) { | 148 if (snapshot == NULL) { |
| 146 return "Invalid vm isolate snapshot seen."; | 149 return "Invalid vm isolate snapshot seen."; |
| 147 } | 150 } |
| 148 ASSERT(snapshot->kind() == Snapshot::kFull); | 151 ASSERT(snapshot->kind() == Snapshot::kFull); |
| 149 VmIsolateSnapshotReader reader(snapshot->content(), | 152 VmIsolateSnapshotReader reader(snapshot->content(), |
| 150 snapshot->length(), | 153 snapshot->length(), |
| 151 instructions_snapshot, | 154 instructions_snapshot, |
| 152 T); | 155 T); |
| 153 const Error& error = Error::Handle(reader.ReadVmIsolateSnapshot()); | 156 const Error& error = Error::Handle(reader.ReadVmIsolateSnapshot()); |
| 154 if (!error.IsNull()) { | 157 if (!error.IsNull()) { |
| 155 return error.ToCString(); | 158 return error.ToCString(); |
| 156 } | 159 } |
| 157 if (FLAG_trace_isolates) { | 160 if (FLAG_trace_isolates) { |
| 158 OS::Print("Size of vm isolate snapshot = %" Pd "\n", | 161 OS::Print("Size of vm isolate snapshot = %" Pd "\n", |
| 159 snapshot->length()); | 162 snapshot->length()); |
| 160 vm_isolate_->heap()->PrintSizes(); | 163 vm_isolate_->heap()->PrintSizes(); |
| 161 vm_isolate_->megamorphic_cache_table()->PrintSizes(); | 164 vm_isolate_->megamorphic_cache_table()->PrintSizes(); |
| 162 intptr_t size; | 165 intptr_t size; |
| 163 intptr_t capacity; | 166 intptr_t capacity; |
| 164 Symbols::GetStats(vm_isolate_, &size, &capacity); | 167 Symbols::GetStats(vm_isolate_, &size, &capacity); |
| 165 OS::Print("VM Isolate: Number of symbols : %" Pd "\n", size); | 168 OS::Print("VM Isolate: Number of symbols : %" Pd "\n", size); |
| 166 OS::Print("VM Isolate: Symbol table capacity : %" Pd "\n", capacity); | 169 OS::Print("VM Isolate: Symbol table capacity : %" Pd "\n", capacity); |
| 167 } | 170 } |
| 168 } else { | 171 } else { |
| 169 Symbols::InitOnce(vm_isolate_); | 172 Symbols::InitOnce(vm_isolate_); |
|
siva
2015/09/14 20:32:59
Maybe the if (!precompiled) check from above shoul
rmacnak
2015/09/15 17:56:42
Yes, precompiled implies there is a vm isolate sna
| |
| 170 } | 173 } |
| 174 Thread::InitOnceAfterObjectAndStubCode(); | |
| 175 // Now that the needed stub has been generated, set the stack limit. | |
| 176 vm_isolate_->InitializeStackLimit(); | |
| 171 Scanner::InitOnce(); | 177 Scanner::InitOnce(); |
| 172 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 178 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| 173 // Dart VM requires at least SSE2. | 179 // Dart VM requires at least SSE2. |
| 174 if (!TargetCPUFeatures::sse2_supported()) { | 180 if (!TargetCPUFeatures::sse2_supported()) { |
| 175 return "SSE2 is required."; | 181 return "SSE2 is required."; |
| 176 } | 182 } |
| 177 #endif | 183 #endif |
| 178 Object::FinalizeVMIsolate(vm_isolate_); | 184 Object::FinalizeVMIsolate(vm_isolate_); |
| 179 #if defined(DEBUG) | 185 #if defined(DEBUG) |
| 180 vm_isolate_->heap()->Verify(kRequireMarked); | 186 vm_isolate_->heap()->Verify(kRequireMarked); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 return predefined_handles_->handles_.IsValidScopedHandle(address); | 387 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 382 } | 388 } |
| 383 | 389 |
| 384 | 390 |
| 385 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { | 391 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { |
| 386 ASSERT(predefined_handles_ != NULL); | 392 ASSERT(predefined_handles_ != NULL); |
| 387 return predefined_handles_->api_handles_.IsValidHandle(handle); | 393 return predefined_handles_->api_handles_.IsValidHandle(handle); |
| 388 } | 394 } |
| 389 | 395 |
| 390 } // namespace dart | 396 } // namespace dart |
| OLD | NEW |