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/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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 stream_(TokenStream::Handle(isolate)), | 160 stream_(TokenStream::Handle(isolate)), |
161 data_(ExternalTypedData::Handle(isolate)), | 161 data_(ExternalTypedData::Handle(isolate)), |
162 error_(UnhandledException::Handle(isolate)), | 162 error_(UnhandledException::Handle(isolate)), |
163 backward_references_((kind == Snapshot::kFull) ? | 163 backward_references_((kind == Snapshot::kFull) ? |
164 kNumInitialReferencesInFullSnapshot : | 164 kNumInitialReferencesInFullSnapshot : |
165 kNumInitialReferences) { | 165 kNumInitialReferences) { |
166 } | 166 } |
167 | 167 |
168 | 168 |
169 RawObject* SnapshotReader::ReadObject() { | 169 RawObject* SnapshotReader::ReadObject() { |
170 const Instance& null_object = Instance::Handle(); | |
171 *ErrorHandle() = UnhandledException::New(null_object, null_object); | |
172 // Setup for long jump in case there is an exception while reading. | 170 // Setup for long jump in case there is an exception while reading. |
173 LongJumpScope jump; | 171 LongJumpScope jump; |
174 if (setjmp(*jump.Set()) == 0) { | 172 if (setjmp(*jump.Set()) == 0) { |
175 Object& obj = Object::Handle(ReadObjectImpl()); | 173 Object& obj = Object::Handle(ReadObjectImpl()); |
176 for (intptr_t i = 0; i < backward_references_.length(); i++) { | 174 for (intptr_t i = 0; i < backward_references_.length(); i++) { |
177 if (!backward_references_[i].is_deserialized()) { | 175 if (!backward_references_[i].is_deserialized()) { |
178 ReadObjectImpl(); | 176 ReadObjectImpl(); |
179 backward_references_[i].set_state(kIsDeserialized); | 177 backward_references_[i].set_state(kIsDeserialized); |
180 } | 178 } |
181 } | 179 } |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
717 ASSERT(isolate()->no_gc_scope_depth() != 0); | 715 ASSERT(isolate()->no_gc_scope_depth() != 0); |
718 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 716 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
719 Heap* heap = isolate()->heap(); | 717 Heap* heap = isolate()->heap(); |
720 | 718 |
721 uword address = heap->TryAllocate(size, Heap::kOld); | 719 uword address = heap->TryAllocate(size, Heap::kOld); |
722 if (address == 0) { | 720 if (address == 0) { |
723 // Use the preallocated out of memory exception to avoid calling | 721 // Use the preallocated out of memory exception to avoid calling |
724 // into dart code or allocating any code. | 722 // into dart code or allocating any code. |
725 // We do a longjmp at this point to unwind out of the entire | 723 // We do a longjmp at this point to unwind out of the entire |
726 // read part and return the error object back. | 724 // read part and return the error object back. |
725 const Instance& null_object = Instance::Handle(); | |
726 *ErrorHandle() = UnhandledException::New(null_object, null_object); | |
siva
2014/07/14 16:20:03
TryAllocate just failed which means the heap is fu
Florian Schneider
2014/07/14 17:02:40
Good point. I'll try that instead.
| |
727 const Instance& exception = | 727 const Instance& exception = |
728 Instance::Handle(object_store()->out_of_memory()); | 728 Instance::Handle(object_store()->out_of_memory()); |
729 ErrorHandle()->set_exception(exception); | 729 ErrorHandle()->set_exception(exception); |
730 Isolate::Current()->long_jump_base()->Jump(1, *ErrorHandle()); | 730 Isolate::Current()->long_jump_base()->Jump(1, *ErrorHandle()); |
731 } | 731 } |
732 #if defined(DEBUG) | 732 #if defined(DEBUG) |
733 // Zap the uninitialized memory area. | 733 // Zap the uninitialized memory area. |
734 uword current = address; | 734 uword current = address; |
735 uword end = address + size; | 735 uword end = address + size; |
736 while (current < end) { | 736 while (current < end) { |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1605 NoGCScope no_gc; | 1605 NoGCScope no_gc; |
1606 WriteObject(obj.raw()); | 1606 WriteObject(obj.raw()); |
1607 UnmarkAll(); | 1607 UnmarkAll(); |
1608 } else { | 1608 } else { |
1609 ThrowException(exception_type(), exception_msg()); | 1609 ThrowException(exception_type(), exception_msg()); |
1610 } | 1610 } |
1611 } | 1611 } |
1612 | 1612 |
1613 | 1613 |
1614 } // namespace dart | 1614 } // namespace dart |
OLD | NEW |