| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 0, // New gen size 0; VM isolate should only allocate in old. | 124 0, // New gen size 0; VM isolate should only allocate in old. |
| 125 FLAG_old_gen_heap_size * MBInWords, | 125 FLAG_old_gen_heap_size * MBInWords, |
| 126 FLAG_external_max_size * MBInWords); | 126 FLAG_external_max_size * MBInWords); |
| 127 ObjectStore::Init(vm_isolate_); | 127 ObjectStore::Init(vm_isolate_); |
| 128 TargetCPUFeatures::InitOnce(); | 128 TargetCPUFeatures::InitOnce(); |
| 129 Object::InitOnce(vm_isolate_); | 129 Object::InitOnce(vm_isolate_); |
| 130 ArgumentsDescriptor::InitOnce(); | 130 ArgumentsDescriptor::InitOnce(); |
| 131 StubCode::InitOnce(); | 131 StubCode::InitOnce(); |
| 132 // Now that the needed stub has been generated, set the stack limit. | 132 // Now that the needed stub has been generated, set the stack limit. |
| 133 vm_isolate_->InitializeStackLimit(); | 133 vm_isolate_->InitializeStackLimit(); |
| 134 Symbols::InitOnce(vm_isolate_); | 134 if (vm_isolate_snapshot != NULL) { |
| 135 const Snapshot* snapshot = Snapshot::SetupFromBuffer(vm_isolate_snapshot); |
| 136 if (snapshot == NULL) { |
| 137 return "Invalid vm isolate snapshot seen."; |
| 138 } |
| 139 ASSERT(snapshot->kind() == Snapshot::kFull); |
| 140 VmIsolateSnapshotReader reader(snapshot->content(), |
| 141 snapshot->length(), |
| 142 zone.GetZone()); |
| 143 const Error& error = Error::Handle(reader.ReadVmIsolateSnapshot()); |
| 144 if (!error.IsNull()) { |
| 145 return error.ToCString(); |
| 146 } |
| 147 if (FLAG_trace_isolates) { |
| 148 OS::Print("Size of vm isolate snapshot = %" Pd "\n", |
| 149 snapshot->length()); |
| 150 vm_isolate_->heap()->PrintSizes(); |
| 151 vm_isolate_->megamorphic_cache_table()->PrintSizes(); |
| 152 intptr_t size; |
| 153 intptr_t capacity; |
| 154 Symbols::GetStats(vm_isolate_, &size, &capacity); |
| 155 OS::Print("VM Isolate: Number of symbols : %" Pd "\n", size); |
| 156 OS::Print("VM Isolate: Symbol table capacity : %" Pd "\n", capacity); |
| 157 } |
| 158 Symbols::InitOnceFromSnapshot(vm_isolate_); |
| 159 } else { |
| 160 Symbols::InitOnce(vm_isolate_); |
| 161 } |
| 135 Scanner::InitOnce(); | 162 Scanner::InitOnce(); |
| 136 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 163 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| 137 // Dart VM requires at least SSE2. | 164 // Dart VM requires at least SSE2. |
| 138 if (!TargetCPUFeatures::sse2_supported()) { | 165 if (!TargetCPUFeatures::sse2_supported()) { |
| 139 return "SSE2 is required."; | 166 return "SSE2 is required."; |
| 140 } | 167 } |
| 141 #endif | 168 #endif |
| 142 if (vm_isolate_snapshot != NULL) { | |
| 143 // Initializing the VM isolate from a snapshot is not implemented yet. | |
| 144 USE(vm_isolate_snapshot); | |
| 145 } | |
| 146 Object::FinalizeVMIsolate(vm_isolate_); | 169 Object::FinalizeVMIsolate(vm_isolate_); |
| 170 #if defined(DEBUG) |
| 171 vm_isolate_->heap()->Verify(kRequireMarked); |
| 172 #endif |
| 147 } | 173 } |
| 148 // There is a planned and known asymmetry here: We enter one scope for the VM | 174 // There is a planned and known asymmetry here: We enter one scope for the VM |
| 149 // isolate so that we can allocate the "persistent" scoped handles for the | 175 // isolate so that we can allocate the "persistent" scoped handles for the |
| 150 // predefined API values (such as Dart_True, Dart_False and Dart_Null). | 176 // predefined API values (such as Dart_True, Dart_False and Dart_Null). |
| 151 Dart_EnterScope(); | 177 Dart_EnterScope(); |
| 152 Api::InitHandles(); | 178 Api::InitHandles(); |
| 153 | 179 |
| 154 Thread::ExitIsolate(); // Unregister the VM isolate from this thread. | 180 Thread::ExitIsolate(); // Unregister the VM isolate from this thread. |
| 155 Isolate::SetCreateCallback(create); | 181 Isolate::SetCreateCallback(create); |
| 156 Isolate::SetInterruptCallback(interrupt); | 182 Isolate::SetInterruptCallback(interrupt); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); | 260 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); |
| 235 if (snapshot == NULL) { | 261 if (snapshot == NULL) { |
| 236 const String& message = String::Handle( | 262 const String& message = String::Handle( |
| 237 String::New("Invalid snapshot.")); | 263 String::New("Invalid snapshot.")); |
| 238 return ApiError::New(message); | 264 return ApiError::New(message); |
| 239 } | 265 } |
| 240 ASSERT(snapshot->kind() == Snapshot::kFull); | 266 ASSERT(snapshot->kind() == Snapshot::kFull); |
| 241 if (FLAG_trace_isolates) { | 267 if (FLAG_trace_isolates) { |
| 242 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length()); | 268 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length()); |
| 243 } | 269 } |
| 244 SnapshotReader reader(snapshot->content(), snapshot->length(), | 270 IsolateSnapshotReader reader(snapshot->content(), |
| 245 Snapshot::kFull, isolate, zone.GetZone()); | 271 snapshot->length(), |
| 272 isolate, |
| 273 zone.GetZone()); |
| 246 const Error& error = Error::Handle(reader.ReadFullSnapshot()); | 274 const Error& error = Error::Handle(reader.ReadFullSnapshot()); |
| 247 if (!error.IsNull()) { | 275 if (!error.IsNull()) { |
| 248 return error.raw(); | 276 return error.raw(); |
| 249 } | 277 } |
| 250 if (FLAG_trace_isolates) { | 278 if (FLAG_trace_isolates) { |
| 251 isolate->heap()->PrintSizes(); | 279 isolate->heap()->PrintSizes(); |
| 252 isolate->megamorphic_cache_table()->PrintSizes(); | 280 isolate->megamorphic_cache_table()->PrintSizes(); |
| 253 } | 281 } |
| 282 } else { |
| 283 // Populate the isolate's symbol table with all symbols from the |
| 284 // VM isolate. We do this so that when we generate a full snapshot |
| 285 // for the isolate we have a unified symbol table that we can then |
| 286 // read into the VM isolate. |
| 287 Symbols::AddPredefinedSymbolsToIsolate(); |
| 254 } | 288 } |
| 255 | 289 |
| 256 Object::VerifyBuiltinVtables(); | 290 Object::VerifyBuiltinVtables(); |
| 257 | 291 |
| 258 StubCode::Init(isolate); | 292 StubCode::Init(isolate); |
| 259 if (snapshot_buffer == NULL) { | 293 if (snapshot_buffer == NULL) { |
| 260 if (!isolate->object_store()->PreallocateObjects()) { | 294 if (!isolate->object_store()->PreallocateObjects()) { |
| 261 return isolate->object_store()->sticky_error(); | 295 return isolate->object_store()->sticky_error(); |
| 262 } | 296 } |
| 263 } | 297 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 return predefined_handles_->handles_.AllocateScopedHandle(); | 348 return predefined_handles_->handles_.AllocateScopedHandle(); |
| 315 } | 349 } |
| 316 | 350 |
| 317 | 351 |
| 318 bool Dart::IsReadOnlyHandle(uword address) { | 352 bool Dart::IsReadOnlyHandle(uword address) { |
| 319 ASSERT(predefined_handles_ != NULL); | 353 ASSERT(predefined_handles_ != NULL); |
| 320 return predefined_handles_->handles_.IsValidScopedHandle(address); | 354 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 321 } | 355 } |
| 322 | 356 |
| 323 } // namespace dart | 357 } // namespace dart |
| OLD | NEW |