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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 ASSERT(kHeaderSize == sizeof(Snapshot)); | 129 ASSERT(kHeaderSize == sizeof(Snapshot)); |
130 ASSERT(kLengthIndex == length_offset()); | 130 ASSERT(kLengthIndex == length_offset()); |
131 ASSERT((kSnapshotFlagIndex * sizeof(int64_t)) == kind_offset()); | 131 ASSERT((kSnapshotFlagIndex * sizeof(int64_t)) == kind_offset()); |
132 ASSERT((kHeapObjectTag & kInlined)); | 132 ASSERT((kHeapObjectTag & kInlined)); |
133 // The kWatchedBit and kMarkBit are only set during GC operations. This | 133 // The kWatchedBit and kMarkBit are only set during GC operations. This |
134 // allows the two low bits in the header to be used for snapshotting. | 134 // allows the two low bits in the header to be used for snapshotting. |
135 ASSERT(kObjectId == | 135 ASSERT(kObjectId == |
136 ((1 << RawObject::kWatchedBit) | (1 << RawObject::kMarkBit))); | 136 ((1 << RawObject::kWatchedBit) | (1 << RawObject::kMarkBit))); |
137 ASSERT((kObjectAlignmentMask & kObjectId) == kObjectId); | 137 ASSERT((kObjectAlignmentMask & kObjectId) == kObjectId); |
138 const Snapshot* snapshot = reinterpret_cast<const Snapshot*>(raw_memory); | 138 const Snapshot* snapshot = reinterpret_cast<const Snapshot*>(raw_memory); |
| 139 // If the raw length is negative or greater than what the local machine can |
| 140 // handle, then signal an error. |
| 141 int64_t snapshot_length = ReadUnaligned(&snapshot->unaligned_length_); |
| 142 if ((snapshot_length < 0) || (snapshot_length > kIntptrMax)) { |
| 143 return NULL; |
| 144 } |
139 return snapshot; | 145 return snapshot; |
140 } | 146 } |
141 | 147 |
142 | 148 |
143 RawSmi* BaseReader::ReadAsSmi() { | 149 RawSmi* BaseReader::ReadAsSmi() { |
144 intptr_t value = ReadIntptrValue(); | 150 intptr_t value = ReadIntptrValue(); |
145 ASSERT((value & kSmiTagMask) == kSmiTag); | 151 ASSERT((value & kSmiTagMask) == kSmiTag); |
146 return reinterpret_cast<RawSmi*>(value); | 152 return reinterpret_cast<RawSmi*>(value); |
147 } | 153 } |
148 | 154 |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1635 NoGCScope no_gc; | 1641 NoGCScope no_gc; |
1636 WriteObject(obj.raw()); | 1642 WriteObject(obj.raw()); |
1637 UnmarkAll(); | 1643 UnmarkAll(); |
1638 } else { | 1644 } else { |
1639 ThrowException(exception_type(), exception_msg()); | 1645 ThrowException(exception_type(), exception_msg()); |
1640 } | 1646 } |
1641 } | 1647 } |
1642 | 1648 |
1643 | 1649 |
1644 } // namespace dart | 1650 } // namespace dart |
OLD | NEW |