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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 Heap::Init(isolate, | 217 Heap::Init(isolate, |
218 FLAG_new_gen_semi_max_size * MBInWords, | 218 FLAG_new_gen_semi_max_size * MBInWords, |
219 FLAG_old_gen_heap_size * MBInWords, | 219 FLAG_old_gen_heap_size * MBInWords, |
220 FLAG_external_max_size * MBInWords); | 220 FLAG_external_max_size * MBInWords); |
221 ObjectIdRing::Init(isolate); | 221 ObjectIdRing::Init(isolate); |
222 ObjectStore::Init(isolate); | 222 ObjectStore::Init(isolate); |
223 | 223 |
224 // Setup for profiling. | 224 // Setup for profiling. |
225 Profiler::InitProfilingForIsolate(isolate); | 225 Profiler::InitProfilingForIsolate(isolate); |
226 | 226 |
227 if (snapshot_buffer == NULL) { | 227 const Error& error = Error::Handle(Object::Init(isolate)); |
228 const Error& error = Error::Handle(Object::Init(isolate)); | 228 if (!error.IsNull()) { |
229 if (!error.IsNull()) { | 229 return error.raw(); |
230 return error.raw(); | 230 } |
231 } | 231 if (snapshot_buffer != NULL) { |
232 } else { | 232 // Read the snapshot and setup the initial state. |
233 // Initialize from snapshot (this should replicate the functionality | |
234 // of Object::Init(..) in a regular isolate creation path. | |
235 Object::InitFromSnapshot(isolate); | |
236 | 233 |
237 // TODO(turnidge): Remove once length is not part of the snapshot. | 234 // TODO(turnidge): Remove once length is not part of the snapshot. |
238 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); | 235 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); |
239 if (snapshot == NULL) { | 236 if (snapshot == NULL) { |
240 const String& message = String::Handle( | 237 const String& message = String::Handle( |
241 String::New("Invalid snapshot.")); | 238 String::New("Invalid snapshot.")); |
242 return ApiError::New(message); | 239 return ApiError::New(message); |
243 } | 240 } |
244 ASSERT(snapshot->kind() == Snapshot::kFull); | 241 ASSERT(snapshot->kind() == Snapshot::kFull); |
245 if (FLAG_trace_isolates) { | 242 if (FLAG_trace_isolates) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 return predefined_handles_->handles_.AllocateScopedHandle(); | 315 return predefined_handles_->handles_.AllocateScopedHandle(); |
319 } | 316 } |
320 | 317 |
321 | 318 |
322 bool Dart::IsReadOnlyHandle(uword address) { | 319 bool Dart::IsReadOnlyHandle(uword address) { |
323 ASSERT(predefined_handles_ != NULL); | 320 ASSERT(predefined_handles_ != NULL); |
324 return predefined_handles_->handles_.IsValidScopedHandle(address); | 321 return predefined_handles_->handles_.IsValidScopedHandle(address); |
325 } | 322 } |
326 | 323 |
327 } // namespace dart | 324 } // namespace dart |
OLD | NEW |