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

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

Issue 130563005: Fix dartbug.com/15963: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 AllocateUninitialized(cls_, Class::InstanceSize())); 471 AllocateUninitialized(cls_, Class::InstanceSize()));
472 Instance fake; 472 Instance fake;
473 obj->ptr()->handle_vtable_ = fake.vtable(); 473 obj->ptr()->handle_vtable_ = fake.vtable();
474 cls_ = obj; 474 cls_ = obj;
475 cls_.set_id(kIllegalCid); 475 cls_.set_id(kIllegalCid);
476 isolate()->RegisterClass(cls_); 476 isolate()->RegisterClass(cls_);
477 return cls_.raw(); 477 return cls_.raw();
478 } 478 }
479 479
480 480
481 RawInstance* SnapshotReader::NewInstance() {
482 ASSERT(kind_ == Snapshot::kFull);
483 ASSERT(isolate()->no_gc_scope_depth() != 0);
484 cls_ = object_store()->object_class();
485 RawInstance* obj = reinterpret_cast<RawInstance*>(
486 AllocateUninitialized(cls_, Instance::InstanceSize()));
487 return obj;
488 }
489
490
481 RawMint* SnapshotReader::NewMint(int64_t value) { 491 RawMint* SnapshotReader::NewMint(int64_t value) {
482 ASSERT(kind_ == Snapshot::kFull); 492 ASSERT(kind_ == Snapshot::kFull);
483 ASSERT(isolate()->no_gc_scope_depth() != 0); 493 ASSERT(isolate()->no_gc_scope_depth() != 0);
484 cls_ = object_store()->mint_class(); 494 cls_ = object_store()->mint_class();
485 RawMint* obj = reinterpret_cast<RawMint*>( 495 RawMint* obj = reinterpret_cast<RawMint*>(
486 AllocateUninitialized(cls_, Mint::InstanceSize())); 496 AllocateUninitialized(cls_, Mint::InstanceSize()));
487 obj->ptr()->value_ = value; 497 obj->ptr()->value_ = value;
488 return obj; 498 return obj;
489 } 499 }
490 500
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 if (address == 0) { 704 if (address == 0) {
695 // Use the preallocated out of memory exception to avoid calling 705 // Use the preallocated out of memory exception to avoid calling
696 // into dart code or allocating any code. 706 // into dart code or allocating any code.
697 // We do a longjmp at this point to unwind out of the entire 707 // We do a longjmp at this point to unwind out of the entire
698 // read part and return the error object back. 708 // read part and return the error object back.
699 const Instance& exception = 709 const Instance& exception =
700 Instance::Handle(object_store()->out_of_memory()); 710 Instance::Handle(object_store()->out_of_memory());
701 ErrorHandle()->set_exception(exception); 711 ErrorHandle()->set_exception(exception);
702 Isolate::Current()->long_jump_base()->Jump(1, *ErrorHandle()); 712 Isolate::Current()->long_jump_base()->Jump(1, *ErrorHandle());
703 } 713 }
714 // Make sure to initialize the last word, as this can be left untouched in
715 // case the object deserialized has an alignment tail.
716 *reinterpret_cast<RawObject**>(address + size - kWordSize) = Object::null();
717
704 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); 718 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
705 uword tags = 0; 719 uword tags = 0;
706 intptr_t index = cls.id(); 720 intptr_t index = cls.id();
707 ASSERT(index != kIllegalCid); 721 ASSERT(index != kIllegalCid);
708 tags = RawObject::ClassIdTag::update(index, tags); 722 tags = RawObject::ClassIdTag::update(index, tags);
709 tags = RawObject::SizeTag::update(size, tags); 723 tags = RawObject::SizeTag::update(size, tags);
710 raw_obj->ptr()->tags_ = tags; 724 raw_obj->ptr()->tags_ = tags;
711 return raw_obj; 725 return raw_obj;
712 } 726 }
713 727
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 NoGCScope no_gc; 1518 NoGCScope no_gc;
1505 WriteObject(obj.raw()); 1519 WriteObject(obj.raw());
1506 UnmarkAll(); 1520 UnmarkAll();
1507 } else { 1521 } else {
1508 ThrowException(exception_type(), exception_msg()); 1522 ThrowException(exception_type(), exception_msg());
1509 } 1523 }
1510 } 1524 }
1511 1525
1512 1526
1513 } // namespace dart 1527 } // 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