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