| 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 RawApiError* SnapshotReader::NewApiError() { | 667 RawApiError* SnapshotReader::NewApiError() { |
| 670 ALLOC_NEW_OBJECT(ApiError, Object::api_error_class()); | 668 ALLOC_NEW_OBJECT(ApiError, Object::api_error_class()); |
| 671 } | 669 } |
| 672 | 670 |
| 673 | 671 |
| 674 RawLanguageError* SnapshotReader::NewLanguageError() { | 672 RawLanguageError* SnapshotReader::NewLanguageError() { |
| 675 ALLOC_NEW_OBJECT(LanguageError, Object::language_error_class()); | 673 ALLOC_NEW_OBJECT(LanguageError, Object::language_error_class()); |
| 676 } | 674 } |
| 677 | 675 |
| 678 | 676 |
| 677 RawUnhandledException* SnapshotReader::NewUnhandledException() { |
| 678 ALLOC_NEW_OBJECT(UnhandledException, Object::unhandled_exception_class()); |
| 679 } |
| 680 |
| 681 |
| 679 RawObject* SnapshotReader::NewInteger(int64_t value) { | 682 RawObject* SnapshotReader::NewInteger(int64_t value) { |
| 680 ASSERT((value & kSmiTagMask) == kSmiTag); | 683 ASSERT((value & kSmiTagMask) == kSmiTag); |
| 681 value = value >> kSmiTagShift; | 684 value = value >> kSmiTagShift; |
| 682 if ((value <= Smi::kMaxValue) && (value >= Smi::kMinValue)) { | 685 if ((value <= Smi::kMaxValue) && (value >= Smi::kMinValue)) { |
| 683 return Smi::New(value); | 686 return Smi::New(value); |
| 684 } | 687 } |
| 685 if (kind_ == Snapshot::kFull) { | 688 if (kind_ == Snapshot::kFull) { |
| 686 return NewMint(value); | 689 return NewMint(value); |
| 687 } | 690 } |
| 688 return Mint::NewCanonical(value); | 691 return Mint::NewCanonical(value); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 717 ASSERT(isolate()->no_gc_scope_depth() != 0); | 720 ASSERT(isolate()->no_gc_scope_depth() != 0); |
| 718 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 721 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
| 719 Heap* heap = isolate()->heap(); | 722 Heap* heap = isolate()->heap(); |
| 720 | 723 |
| 721 uword address = heap->TryAllocate(size, Heap::kOld); | 724 uword address = heap->TryAllocate(size, Heap::kOld); |
| 722 if (address == 0) { | 725 if (address == 0) { |
| 723 // Use the preallocated out of memory exception to avoid calling | 726 // Use the preallocated out of memory exception to avoid calling |
| 724 // into dart code or allocating any code. | 727 // into dart code or allocating any code. |
| 725 // We do a longjmp at this point to unwind out of the entire | 728 // We do a longjmp at this point to unwind out of the entire |
| 726 // read part and return the error object back. | 729 // read part and return the error object back. |
| 727 const Instance& exception = | 730 const UnhandledException& error = UnhandledException::Handle( |
| 728 Instance::Handle(object_store()->out_of_memory()); | 731 object_store()->preallocated_unhandled_exception()); |
| 729 ErrorHandle()->set_exception(exception); | 732 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 730 Isolate::Current()->long_jump_base()->Jump(1, *ErrorHandle()); | |
| 731 } | 733 } |
| 732 #if defined(DEBUG) | 734 #if defined(DEBUG) |
| 733 // Zap the uninitialized memory area. | 735 // Zap the uninitialized memory area. |
| 734 uword current = address; | 736 uword current = address; |
| 735 uword end = address + size; | 737 uword end = address + size; |
| 736 while (current < end) { | 738 while (current < end) { |
| 737 *reinterpret_cast<intptr_t*>(current) = kZapUninitializedWord; | 739 *reinterpret_cast<intptr_t*>(current) = kZapUninitializedWord; |
| 738 current += kWordSize; | 740 current += kWordSize; |
| 739 } | 741 } |
| 740 #endif // defined(DBEUG) | 742 #endif // defined(DBEUG) |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 NoGCScope no_gc; | 1607 NoGCScope no_gc; |
| 1606 WriteObject(obj.raw()); | 1608 WriteObject(obj.raw()); |
| 1607 UnmarkAll(); | 1609 UnmarkAll(); |
| 1608 } else { | 1610 } else { |
| 1609 ThrowException(exception_type(), exception_msg()); | 1611 ThrowException(exception_type(), exception_msg()); |
| 1610 } | 1612 } |
| 1611 } | 1613 } |
| 1612 | 1614 |
| 1613 | 1615 |
| 1614 } // namespace dart | 1616 } // namespace dart |
| OLD | NEW |