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/freelist.h" | 9 #include "vm/freelist.h" |
10 #include "vm/handles.h" | 10 #include "vm/handles.h" |
11 #include "vm/heap.h" | 11 #include "vm/heap.h" |
12 #include "vm/isolate.h" | 12 #include "vm/isolate.h" |
| 13 #include "vm/longjump.h" |
13 #include "vm/object.h" | 14 #include "vm/object.h" |
14 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
15 #include "vm/port.h" | 16 #include "vm/port.h" |
16 #include "vm/snapshot.h" | 17 #include "vm/snapshot.h" |
17 #include "vm/stub_code.h" | 18 #include "vm/stub_code.h" |
18 #include "vm/virtual_memory.h" | 19 #include "vm/virtual_memory.h" |
19 #include "vm/zone.h" | 20 #include "vm/zone.h" |
20 | 21 |
21 namespace dart { | 22 namespace dart { |
22 | 23 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 56 |
56 | 57 |
57 Isolate* Dart::CreateIsolate(const char* name_prefix) { | 58 Isolate* Dart::CreateIsolate(const char* name_prefix) { |
58 // Create a new isolate. | 59 // Create a new isolate. |
59 Isolate* isolate = Isolate::Init(name_prefix); | 60 Isolate* isolate = Isolate::Init(name_prefix); |
60 ASSERT(isolate != NULL); | 61 ASSERT(isolate != NULL); |
61 return isolate; | 62 return isolate; |
62 } | 63 } |
63 | 64 |
64 | 65 |
65 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { | 66 void Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { |
66 // Initialize the new isolate. | 67 // Initialize the new isolate. |
67 TIMERSCOPE(time_isolate_initialization); | 68 TIMERSCOPE(time_isolate_initialization); |
68 Isolate* isolate = Isolate::Current(); | 69 Isolate* isolate = Isolate::Current(); |
69 ASSERT(isolate != NULL); | 70 ASSERT(isolate != NULL); |
70 Zone zone(isolate); | 71 Zone zone(isolate); |
71 HandleScope handle_scope(isolate); | 72 HandleScope handle_scope(isolate); |
72 Heap::Init(isolate); | 73 Heap::Init(isolate); |
73 ObjectStore::Init(isolate); | 74 ObjectStore::Init(isolate); |
74 | 75 |
75 if (snapshot_buffer == NULL) { | 76 if (snapshot_buffer == NULL) { |
76 const Error& error = Error::Handle(Object::Init(isolate)); | 77 Object::Init(isolate); |
77 if (!error.IsNull()) { | |
78 return error.raw(); | |
79 } | |
80 } else { | 78 } else { |
81 // Initialize from snapshot (this should replicate the functionality | 79 // Initialize from snapshot (this should replicate the functionality |
82 // of Object::Init(..) in a regular isolate creation path. | 80 // of Object::Init(..) in a regular isolate creation path. |
83 Object::InitFromSnapshot(isolate); | 81 Object::InitFromSnapshot(isolate); |
84 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); | 82 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); |
85 SnapshotReader reader(snapshot, isolate); | 83 SnapshotReader reader(snapshot, isolate); |
86 reader.ReadFullSnapshot(); | 84 reader.ReadFullSnapshot(); |
87 } | 85 } |
88 | 86 |
89 StubCode::Init(isolate); | 87 StubCode::Init(isolate); |
90 CodeIndexTable::Init(isolate); | 88 CodeIndexTable::Init(isolate); |
91 isolate->set_init_callback_data(data); | 89 isolate->set_init_callback_data(data); |
92 return Error::null(); | |
93 } | 90 } |
94 | 91 |
95 | 92 |
96 void Dart::ShutdownIsolate() { | 93 void Dart::ShutdownIsolate() { |
97 Isolate* isolate = Isolate::Current(); | 94 Isolate* isolate = Isolate::Current(); |
98 isolate->Shutdown(); | 95 isolate->Shutdown(); |
99 delete isolate; | 96 delete isolate; |
100 } | 97 } |
101 | 98 |
102 } // namespace dart | 99 } // namespace dart |
OLD | NEW |