Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: runtime/vm/snapshot.cc

Issue 324433003: In SnapshotReader, changes BackRefNode to be a ValueObject. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/snapshot.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 168
169 RawObject* SnapshotReader::ReadObject() { 169 RawObject* SnapshotReader::ReadObject() {
170 const Instance& null_object = Instance::Handle(); 170 const Instance& null_object = Instance::Handle();
171 *ErrorHandle() = UnhandledException::New(null_object, null_object); 171 *ErrorHandle() = UnhandledException::New(null_object, null_object);
172 // Setup for long jump in case there is an exception while reading. 172 // Setup for long jump in case there is an exception while reading.
173 LongJumpScope jump; 173 LongJumpScope jump;
174 if (setjmp(*jump.Set()) == 0) { 174 if (setjmp(*jump.Set()) == 0) {
175 Object& obj = Object::Handle(ReadObjectImpl()); 175 Object& obj = Object::Handle(ReadObjectImpl());
176 for (intptr_t i = 0; i < backward_references_.length(); i++) { 176 for (intptr_t i = 0; i < backward_references_.length(); i++) {
177 if (!backward_references_[i]->is_deserialized()) { 177 if (!backward_references_[i].is_deserialized()) {
178 ReadObjectImpl(); 178 ReadObjectImpl();
179 backward_references_[i]->set_state(kIsDeserialized); 179 backward_references_[i].set_state(kIsDeserialized);
180 } 180 }
181 } 181 }
182 return obj.raw(); 182 return obj.raw();
183 } else { 183 } else {
184 // An error occurred while reading, return the error object. 184 // An error occurred while reading, return the error object.
185 const Error& err = Error::Handle(isolate()->object_store()->sticky_error()); 185 const Error& err = Error::Handle(isolate()->object_store()->sticky_error());
186 isolate()->object_store()->clear_sticky_error(); 186 isolate()->object_store()->clear_sticky_error();
187 return err.raw(); 187 return err.raw();
188 } 188 }
189 } 189 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 334 }
335 return obj_.raw(); 335 return obj_.raw();
336 } 336 }
337 337
338 338
339 void SnapshotReader::AddBackRef(intptr_t id, 339 void SnapshotReader::AddBackRef(intptr_t id,
340 Object* obj, 340 Object* obj,
341 DeserializeState state) { 341 DeserializeState state) {
342 intptr_t index = (id - kMaxPredefinedObjectIds); 342 intptr_t index = (id - kMaxPredefinedObjectIds);
343 ASSERT(index == backward_references_.length()); 343 ASSERT(index == backward_references_.length());
344 BackRefNode* node = new BackRefNode(obj, state); 344 BackRefNode node(obj, state);
345 ASSERT(node != NULL);
346 backward_references_.Add(node); 345 backward_references_.Add(node);
347 } 346 }
348 347
349 348
350 Object* SnapshotReader::GetBackRef(intptr_t id) { 349 Object* SnapshotReader::GetBackRef(intptr_t id) {
351 ASSERT(id >= kMaxPredefinedObjectIds); 350 ASSERT(id >= kMaxPredefinedObjectIds);
352 intptr_t index = (id - kMaxPredefinedObjectIds); 351 intptr_t index = (id - kMaxPredefinedObjectIds);
353 if (index < backward_references_.length()) { 352 if (index < backward_references_.length()) {
354 return backward_references_[index]->reference(); 353 return backward_references_[index].reference();
355 } 354 }
356 return NULL; 355 return NULL;
357 } 356 }
358 357
359 358
360 void SnapshotReader::ReadFullSnapshot() { 359 void SnapshotReader::ReadFullSnapshot() {
361 ASSERT(kind_ == Snapshot::kFull); 360 ASSERT(kind_ == Snapshot::kFull);
362 Isolate* isolate = Isolate::Current(); 361 Isolate* isolate = Isolate::Current();
363 ASSERT(isolate != NULL); 362 ASSERT(isolate != NULL);
364 ObjectStore* object_store = isolate->object_store(); 363 ObjectStore* object_store = isolate->object_store();
365 ASSERT(object_store != NULL); 364 ASSERT(object_store != NULL);
366 NoGCScope no_gc; 365 NoGCScope no_gc;
367 366
368 // TODO(asiva): Add a check here to ensure we have the right heap 367 // TODO(asiva): Add a check here to ensure we have the right heap
369 // size for the full snapshot being read. 368 // size for the full snapshot being read.
370 369
371 // Read in all the objects stored in the object store. 370 // Read in all the objects stored in the object store.
372 intptr_t num_flds = (object_store->to() - object_store->from()); 371 intptr_t num_flds = (object_store->to() - object_store->from());
373 for (intptr_t i = 0; i <= num_flds; i++) { 372 for (intptr_t i = 0; i <= num_flds; i++) {
374 *(object_store->from() + i) = ReadObjectImpl(); 373 *(object_store->from() + i) = ReadObjectImpl();
375 } 374 }
376 for (intptr_t i = 0; i < backward_references_.length(); i++) { 375 for (intptr_t i = 0; i < backward_references_.length(); i++) {
377 if (!backward_references_[i]->is_deserialized()) { 376 if (!backward_references_[i].is_deserialized()) {
378 ReadObjectImpl(); 377 ReadObjectImpl();
379 backward_references_[i]->set_state(kIsDeserialized); 378 backward_references_[i].set_state(kIsDeserialized);
380 } 379 }
381 } 380 }
382 381
383 // Validate the class table. 382 // Validate the class table.
384 #if defined(DEBUG) 383 #if defined(DEBUG)
385 isolate->ValidateClassTable(); 384 isolate->ValidateClassTable();
386 #endif 385 #endif
387 386
388 // Setup native resolver for bootstrap impl. 387 // Setup native resolver for bootstrap impl.
389 Bootstrap::SetupNativeResolver(); 388 Bootstrap::SetupNativeResolver();
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 NoGCScope no_gc; 1572 NoGCScope no_gc;
1574 WriteObject(obj.raw()); 1573 WriteObject(obj.raw());
1575 UnmarkAll(); 1574 UnmarkAll();
1576 } else { 1575 } else {
1577 ThrowException(exception_type(), exception_msg()); 1576 ThrowException(exception_type(), exception_msg());
1578 } 1577 }
1579 } 1578 }
1580 1579
1581 1580
1582 } // namespace dart 1581 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/snapshot.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698