| 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/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 | 136 |
| 137 // TODO(5411462): Temporary setup of snapshot for testing purposes, | 137 // TODO(5411462): Temporary setup of snapshot for testing purposes, |
| 138 // the actual creation of a snapshot maybe done differently. | 138 // the actual creation of a snapshot maybe done differently. |
| 139 const Snapshot* Snapshot::SetupFromBuffer(const void* raw_memory) { | 139 const Snapshot* Snapshot::SetupFromBuffer(const void* raw_memory) { |
| 140 ASSERT(raw_memory != NULL); | 140 ASSERT(raw_memory != NULL); |
| 141 ASSERT(kHeaderSize == sizeof(Snapshot)); | 141 ASSERT(kHeaderSize == sizeof(Snapshot)); |
| 142 ASSERT(kLengthIndex == length_offset()); | 142 ASSERT(kLengthIndex == length_offset()); |
| 143 ASSERT((kSnapshotFlagIndex * sizeof(int64_t)) == kind_offset()); | 143 ASSERT((kSnapshotFlagIndex * sizeof(int64_t)) == kind_offset()); |
| 144 ASSERT((kHeapObjectTag & kInlined)); | 144 ASSERT((kHeapObjectTag & kInlined)); |
| 145 // The kWatchedBit and kMarkBit are only set during GC operations. This | |
| 146 // allows the two low bits in the header to be used for snapshotting. | |
| 147 ASSERT(kObjectId == | |
| 148 ((1 << RawObject::kWatchedBit) | (1 << RawObject::kMarkBit))); | |
| 149 ASSERT((kObjectAlignmentMask & kObjectId) == kObjectId); | |
| 150 const Snapshot* snapshot = reinterpret_cast<const Snapshot*>(raw_memory); | 145 const Snapshot* snapshot = reinterpret_cast<const Snapshot*>(raw_memory); |
| 151 // If the raw length is negative or greater than what the local machine can | 146 // If the raw length is negative or greater than what the local machine can |
| 152 // handle, then signal an error. | 147 // handle, then signal an error. |
| 153 int64_t snapshot_length = ReadUnaligned(&snapshot->unaligned_length_); | 148 int64_t snapshot_length = ReadUnaligned(&snapshot->unaligned_length_); |
| 154 if ((snapshot_length < 0) || (snapshot_length > kIntptrMax)) { | 149 if ((snapshot_length < 0) || (snapshot_length > kIntptrMax)) { |
| 155 return NULL; | 150 return NULL; |
| 156 } | 151 } |
| 157 return snapshot; | 152 return snapshot; |
| 158 } | 153 } |
| 159 | 154 |
| (...skipping 2619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2779 if (setjmp(*jump.Set()) == 0) { | 2774 if (setjmp(*jump.Set()) == 0) { |
| 2780 NoSafepointScope no_safepoint; | 2775 NoSafepointScope no_safepoint; |
| 2781 WriteObject(obj.raw()); | 2776 WriteObject(obj.raw()); |
| 2782 } else { | 2777 } else { |
| 2783 ThrowException(exception_type(), exception_msg()); | 2778 ThrowException(exception_type(), exception_msg()); |
| 2784 } | 2779 } |
| 2785 } | 2780 } |
| 2786 | 2781 |
| 2787 | 2782 |
| 2788 } // namespace dart | 2783 } // namespace dart |
| OLD | NEW |