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

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

Issue 792163003: Deletion barrier preparation: validate overwritten references. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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/raw_object.cc ('k') | runtime/vm/virtual_memory.h » ('j') | 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/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 ASSERT(IsObjectStoreClassId(class_id)); 818 ASSERT(IsObjectStoreClassId(class_id));
819 return class_id; 819 return class_id;
820 } 820 }
821 821
822 822
823 RawObject* SnapshotReader::AllocateUninitialized(intptr_t class_id, 823 RawObject* SnapshotReader::AllocateUninitialized(intptr_t class_id,
824 intptr_t size) { 824 intptr_t size) {
825 ASSERT(isolate()->no_gc_scope_depth() != 0); 825 ASSERT(isolate()->no_gc_scope_depth() != 0);
826 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 826 ASSERT(Utils::IsAligned(size, kObjectAlignment));
827 827
828 // Allocate memory where all words look like smis. This is currently
829 // only needed for DEBUG-mode validation in StorePointer/StoreSmi, but will
830 // be essential with the upcoming deletion barrier.
828 uword address = 831 uword address =
829 old_space()->TryAllocateDataBumpLocked(size, PageSpace::kForceGrowth); 832 old_space()->TryAllocateSmiInitializedLocked(size,
833 PageSpace::kForceGrowth);
830 if (address == 0) { 834 if (address == 0) {
831 // Use the preallocated out of memory exception to avoid calling 835 // Use the preallocated out of memory exception to avoid calling
832 // into dart code or allocating any code. 836 // into dart code or allocating any code.
833 // We do a longjmp at this point to unwind out of the entire 837 // We do a longjmp at this point to unwind out of the entire
834 // read part and return the error object back. 838 // read part and return the error object back.
835 const UnhandledException& error = UnhandledException::Handle( 839 const UnhandledException& error = UnhandledException::Handle(
836 object_store()->preallocated_unhandled_exception()); 840 object_store()->preallocated_unhandled_exception());
837 Isolate::Current()->long_jump_base()->Jump(1, error); 841 Isolate::Current()->long_jump_base()->Jump(1, error);
838 } 842 }
839 #if defined(DEBUG)
840 // Zap the uninitialized memory area.
841 uword current = address;
842 uword end = address + size;
843 while (current < end) {
844 *reinterpret_cast<intptr_t*>(current) = kZapUninitializedWord;
845 current += kWordSize;
846 }
847 #endif // defined(DBEUG)
848 // Make sure to initialize the last word, as this can be left untouched in
849 // case the object deserialized has an alignment tail.
850 *reinterpret_cast<RawObject**>(address + size - kWordSize) = Object::null();
851 VerifiedMemory::Accept(address, size); 843 VerifiedMemory::Accept(address, size);
852 844
853 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); 845 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
854 uword tags = 0; 846 uword tags = 0;
855 ASSERT(class_id != kIllegalCid); 847 ASSERT(class_id != kIllegalCid);
856 tags = RawObject::ClassIdTag::update(class_id, tags); 848 tags = RawObject::ClassIdTag::update(class_id, tags);
857 tags = RawObject::SizeTag::update(size, tags); 849 tags = RawObject::SizeTag::update(size, tags);
858 raw_obj->ptr()->tags_ = tags; 850 raw_obj->ptr()->tags_ = tags;
859 return raw_obj; 851 return raw_obj;
860 } 852 }
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 NoGCScope no_gc; 1786 NoGCScope no_gc;
1795 WriteObject(obj.raw()); 1787 WriteObject(obj.raw());
1796 UnmarkAll(); 1788 UnmarkAll();
1797 } else { 1789 } else {
1798 ThrowException(exception_type(), exception_msg()); 1790 ThrowException(exception_type(), exception_msg());
1799 } 1791 }
1800 } 1792 }
1801 1793
1802 1794
1803 } // namespace dart 1795 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.cc ('k') | runtime/vm/virtual_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698