| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_index_table.h" | 7 #include "vm/code_index_table.h" |
| 8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/freelist.h" | 10 #include "vm/freelist.h" |
| 11 #include "vm/handles.h" | 11 #include "vm/handles.h" |
| 12 #include "vm/heap.h" | 12 #include "vm/heap.h" |
| 13 #include "vm/isolate.h" | 13 #include "vm/isolate.h" |
| 14 #include "vm/object.h" | 14 #include "vm/object.h" |
| 15 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
| 16 #include "vm/port.h" | 16 #include "vm/port.h" |
| 17 #include "vm/snapshot.h" | 17 #include "vm/snapshot.h" |
| 18 #include "vm/stub_code.h" | 18 #include "vm/stub_code.h" |
| 19 #include "vm/virtual_memory.h" | 19 #include "vm/virtual_memory.h" |
| 20 #include "vm/zone.h" | 20 #include "vm/zone.h" |
| 21 | 21 |
| 22 namespace dart { | 22 namespace dart { |
| 23 | 23 |
| 24 DECLARE_FLAG(bool, trace_isolates); |
| 25 |
| 24 Isolate* Dart::vm_isolate_ = NULL; | 26 Isolate* Dart::vm_isolate_ = NULL; |
| 25 DebugInfo* Dart::pprof_symbol_generator_ = NULL; | 27 DebugInfo* Dart::pprof_symbol_generator_ = NULL; |
| 26 | 28 |
| 27 bool Dart::InitOnce(Dart_IsolateCreateCallback create, | 29 bool Dart::InitOnce(Dart_IsolateCreateCallback create, |
| 28 Dart_IsolateInterruptCallback interrupt) { | 30 Dart_IsolateInterruptCallback interrupt) { |
| 29 // TODO(iposva): Fix race condition here. | 31 // TODO(iposva): Fix race condition here. |
| 30 if (vm_isolate_ != NULL || !Flags::Initialized()) { | 32 if (vm_isolate_ != NULL || !Flags::Initialized()) { |
| 31 return false; | 33 return false; |
| 32 } | 34 } |
| 33 OS::InitOnce(); | 35 OS::InitOnce(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 if (snapshot_buffer == NULL) { | 79 if (snapshot_buffer == NULL) { |
| 78 const Error& error = Error::Handle(Object::Init(isolate)); | 80 const Error& error = Error::Handle(Object::Init(isolate)); |
| 79 if (!error.IsNull()) { | 81 if (!error.IsNull()) { |
| 80 return error.raw(); | 82 return error.raw(); |
| 81 } | 83 } |
| 82 } else { | 84 } else { |
| 83 // Initialize from snapshot (this should replicate the functionality | 85 // Initialize from snapshot (this should replicate the functionality |
| 84 // of Object::Init(..) in a regular isolate creation path. | 86 // of Object::Init(..) in a regular isolate creation path. |
| 85 Object::InitFromSnapshot(isolate); | 87 Object::InitFromSnapshot(isolate); |
| 86 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); | 88 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); |
| 89 if (FLAG_trace_isolates) { |
| 90 OS::Print("Size of isolate snapshot = %ld\n", snapshot->length()); |
| 91 } |
| 87 SnapshotReader reader(snapshot, isolate); | 92 SnapshotReader reader(snapshot, isolate); |
| 88 reader.ReadFullSnapshot(); | 93 reader.ReadFullSnapshot(); |
| 89 } | 94 } |
| 90 | 95 |
| 91 StubCode::Init(isolate); | 96 StubCode::Init(isolate); |
| 92 CodeIndexTable::Init(isolate); | 97 CodeIndexTable::Init(isolate); |
| 93 isolate->set_init_callback_data(data); | 98 isolate->set_init_callback_data(data); |
| 94 return Error::null(); | 99 return Error::null(); |
| 95 } | 100 } |
| 96 | 101 |
| 97 | 102 |
| 98 void Dart::ShutdownIsolate() { | 103 void Dart::ShutdownIsolate() { |
| 99 Isolate* isolate = Isolate::Current(); | 104 Isolate* isolate = Isolate::Current(); |
| 100 isolate->Shutdown(); | 105 isolate->Shutdown(); |
| 101 delete isolate; | 106 delete isolate; |
| 102 } | 107 } |
| 103 | 108 |
| 104 } // namespace dart | 109 } // namespace dart |
| OLD | NEW |