| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/flags.h" | 8 #include "vm/flags.h" |
| 9 #include "vm/handles.h" | 9 #include "vm/handles.h" |
| 10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 return false; | 30 return false; |
| 31 } | 31 } |
| 32 OS::InitOnce(); | 32 OS::InitOnce(); |
| 33 Flags::ProcessCommandLineFlags(argc, argv); | 33 Flags::ProcessCommandLineFlags(argc, argv); |
| 34 VirtualMemory::InitOnce(); | 34 VirtualMemory::InitOnce(); |
| 35 Isolate::InitOnce(); | 35 Isolate::InitOnce(); |
| 36 // Create the VM isolate and finish the VM initialization. | 36 // Create the VM isolate and finish the VM initialization. |
| 37 { | 37 { |
| 38 ASSERT(vm_isolate_ == NULL); | 38 ASSERT(vm_isolate_ == NULL); |
| 39 vm_isolate_ = Isolate::Init(); | 39 vm_isolate_ = Isolate::Init(); |
| 40 Zone zone; | 40 Zone zone(vm_isolate_); |
| 41 HandleScope handle_scope; | 41 HandleScope handle_scope(vm_isolate_); |
| 42 Heap::Init(vm_isolate_); | 42 Heap::Init(vm_isolate_); |
| 43 ObjectStore::Init(vm_isolate_); | 43 ObjectStore::Init(vm_isolate_); |
| 44 Object::InitOnce(); | 44 Object::InitOnce(); |
| 45 StubCode::InitOnce(); | 45 StubCode::InitOnce(); |
| 46 PortMap::InitOnce(); | 46 PortMap::InitOnce(); |
| 47 Scanner::InitOnce(); | 47 Scanner::InitOnce(); |
| 48 } | 48 } |
| 49 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. | 49 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. |
| 50 Isolate::SetInitCallback(callback); | 50 Isolate::SetInitCallback(callback); |
| 51 return true; | 51 return true; |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 Isolate* Dart::CreateIsolate() { | 55 Isolate* Dart::CreateIsolate() { |
| 56 // Create and initialize a new isolate. | 56 // Create and initialize a new isolate. |
| 57 Isolate* isolate = Isolate::Init(); | 57 Isolate* isolate = Isolate::Init(); |
| 58 ASSERT(isolate != NULL); | 58 ASSERT(isolate != NULL); |
| 59 return isolate; | 59 return isolate; |
| 60 } | 60 } |
| 61 | 61 |
| 62 | 62 |
| 63 void Dart::InitializeIsolate(const Dart_Snapshot* snapshot_buffer, void* data) { | 63 void Dart::InitializeIsolate(const Dart_Snapshot* snapshot_buffer, void* data) { |
| 64 // Initialize the new isolate. | 64 // Initialize the new isolate. |
| 65 Isolate* isolate = Isolate::Current(); | 65 Isolate* isolate = Isolate::Current(); |
| 66 ASSERT(isolate != NULL); | 66 ASSERT(isolate != NULL); |
| 67 Zone zone; | 67 Zone zone(isolate); |
| 68 HandleScope handle_scope; | 68 HandleScope handle_scope(isolate); |
| 69 Heap::Init(isolate); | 69 Heap::Init(isolate); |
| 70 ObjectStore::Init(isolate); | 70 ObjectStore::Init(isolate); |
| 71 | 71 |
| 72 if (snapshot_buffer == NULL) { | 72 if (snapshot_buffer == NULL) { |
| 73 Object::Init(isolate); | 73 Object::Init(isolate); |
| 74 } else { | 74 } else { |
| 75 // Initialize from snapshot (this should replicate the functionality | 75 // Initialize from snapshot (this should replicate the functionality |
| 76 // of Object::Init(..) in a regular isolate creation path. | 76 // of Object::Init(..) in a regular isolate creation path. |
| 77 Object::InitFromSnapshot(isolate); | 77 Object::InitFromSnapshot(isolate); |
| 78 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); | 78 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 93 } | 93 } |
| 94 | 94 |
| 95 | 95 |
| 96 void Dart::ShutdownIsolate() { | 96 void Dart::ShutdownIsolate() { |
| 97 Isolate* isolate = Isolate::Current(); | 97 Isolate* isolate = Isolate::Current(); |
| 98 isolate->Shutdown(); | 98 isolate->Shutdown(); |
| 99 delete isolate; | 99 delete isolate; |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace dart | 102 } // namespace dart |
| OLD | NEW |