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

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

Issue 157053007: - Zap the allocated object when allocating uninitialized memory in debug. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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_snapshot.cc ('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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 if (address == 0) { 716 if (address == 0) {
717 // Use the preallocated out of memory exception to avoid calling 717 // Use the preallocated out of memory exception to avoid calling
718 // into dart code or allocating any code. 718 // into dart code or allocating any code.
719 // We do a longjmp at this point to unwind out of the entire 719 // We do a longjmp at this point to unwind out of the entire
720 // read part and return the error object back. 720 // read part and return the error object back.
721 const Instance& exception = 721 const Instance& exception =
722 Instance::Handle(object_store()->out_of_memory()); 722 Instance::Handle(object_store()->out_of_memory());
723 ErrorHandle()->set_exception(exception); 723 ErrorHandle()->set_exception(exception);
724 Isolate::Current()->long_jump_base()->Jump(1, *ErrorHandle()); 724 Isolate::Current()->long_jump_base()->Jump(1, *ErrorHandle());
725 } 725 }
726 #if defined(DEBUG)
727 // Zap the uninitialized memory area.
728 uword current = address;
729 uword end = address + size;
regis 2014/02/10 17:49:05 You could end at address + size - kWordSize, since
730 while (current < end) {
731 *reinterpret_cast<intptr_t*>(current) = kZapUninitializedWord;
732 current += kWordSize;
733 }
734 #endif // defined(DBEUG)
726 // Make sure to initialize the last word, as this can be left untouched in 735 // Make sure to initialize the last word, as this can be left untouched in
727 // case the object deserialized has an alignment tail. 736 // case the object deserialized has an alignment tail.
728 *reinterpret_cast<RawObject**>(address + size - kWordSize) = Object::null(); 737 *reinterpret_cast<RawObject**>(address + size - kWordSize) = Object::null();
729 738
730 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); 739 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
731 uword tags = 0; 740 uword tags = 0;
732 intptr_t index = cls.id(); 741 intptr_t index = cls.id();
733 ASSERT(index != kIllegalCid); 742 ASSERT(index != kIllegalCid);
734 tags = RawObject::ClassIdTag::update(index, tags); 743 tags = RawObject::ClassIdTag::update(index, tags);
735 tags = RawObject::SizeTag::update(size, tags); 744 tags = RawObject::SizeTag::update(size, tags);
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 NoGCScope no_gc; 1540 NoGCScope no_gc;
1532 WriteObject(obj.raw()); 1541 WriteObject(obj.raw());
1533 UnmarkAll(); 1542 UnmarkAll();
1534 } else { 1543 } else {
1535 ThrowException(exception_type(), exception_msg()); 1544 ThrowException(exception_type(), exception_msg());
1536 } 1545 }
1537 } 1546 }
1538 1547
1539 1548
1540 } // namespace dart 1549 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698