| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 | 137 |
| 138 // TODO(5411462): Temporary setup of snapshot for testing purposes, | 138 // TODO(5411462): Temporary setup of snapshot for testing purposes, |
| 139 // the actual creation of a snapshot maybe done differently. | 139 // the actual creation of a snapshot maybe done differently. |
| 140 const Snapshot* Snapshot::SetupFromBuffer(const void* raw_memory) { | 140 const Snapshot* Snapshot::SetupFromBuffer(const void* raw_memory) { |
| 141 ASSERT(raw_memory != NULL); | 141 ASSERT(raw_memory != NULL); |
| 142 ASSERT(kHeaderSize == sizeof(Snapshot)); | 142 ASSERT(kHeaderSize == sizeof(Snapshot)); |
| 143 ASSERT(kLengthIndex == length_offset()); | 143 ASSERT(kLengthIndex == length_offset()); |
| 144 ASSERT((kSnapshotFlagIndex * sizeof(int64_t)) == kind_offset()); | 144 ASSERT((kSnapshotFlagIndex * sizeof(int64_t)) == kind_offset()); |
| 145 ASSERT((kHeapObjectTag & kInlined)); | 145 ASSERT((kHeapObjectTag & kInlined)); |
| 146 // The kWatchedBit and kMarkBit are only set during GC operations. This | |
| 147 // allows the two low bits in the header to be used for snapshotting. | |
| 148 ASSERT(kObjectId == | |
| 149 ((1 << RawObject::kWatchedBit) | (1 << RawObject::kMarkBit))); | |
| 150 ASSERT((kObjectAlignmentMask & kObjectId) == kObjectId); | |
| 151 const Snapshot* snapshot = reinterpret_cast<const Snapshot*>(raw_memory); | 146 const Snapshot* snapshot = reinterpret_cast<const Snapshot*>(raw_memory); |
| 152 // If the raw length is negative or greater than what the local machine can | 147 // If the raw length is negative or greater than what the local machine can |
| 153 // handle, then signal an error. | 148 // handle, then signal an error. |
| 154 int64_t snapshot_length = ReadUnaligned(&snapshot->unaligned_length_); | 149 int64_t snapshot_length = ReadUnaligned(&snapshot->unaligned_length_); |
| 155 if ((snapshot_length < 0) || (snapshot_length > kIntptrMax)) { | 150 if ((snapshot_length < 0) || (snapshot_length > kIntptrMax)) { |
| 156 return NULL; | 151 return NULL; |
| 157 } | 152 } |
| 158 return snapshot; | 153 return snapshot; |
| 159 } | 154 } |
| 160 | 155 |
| (...skipping 2669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2830 if (setjmp(*jump.Set()) == 0) { | 2825 if (setjmp(*jump.Set()) == 0) { |
| 2831 NoSafepointScope no_safepoint; | 2826 NoSafepointScope no_safepoint; |
| 2832 WriteObject(obj.raw()); | 2827 WriteObject(obj.raw()); |
| 2833 } else { | 2828 } else { |
| 2834 ThrowException(exception_type(), exception_msg()); | 2829 ThrowException(exception_type(), exception_msg()); |
| 2835 } | 2830 } |
| 2836 } | 2831 } |
| 2837 | 2832 |
| 2838 | 2833 |
| 2839 } // namespace dart | 2834 } // namespace dart |
| OLD | NEW |