| OLD | NEW |
| 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 Loading... |
| 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 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1775 NoGCScope no_gc; | 1767 NoGCScope no_gc; |
| 1776 WriteObject(obj.raw()); | 1768 WriteObject(obj.raw()); |
| 1777 UnmarkAll(); | 1769 UnmarkAll(); |
| 1778 } else { | 1770 } else { |
| 1779 ThrowException(exception_type(), exception_msg()); | 1771 ThrowException(exception_type(), exception_msg()); |
| 1780 } | 1772 } |
| 1781 } | 1773 } |
| 1782 | 1774 |
| 1783 | 1775 |
| 1784 } // namespace dart | 1776 } // namespace dart |
| OLD | NEW |