Chromium Code Reviews| 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 if ((snapshot->length_ < 0) || (snapshot->length_ > kIntptrMax)) { | |
|
Ivan Posva
2014/07/28 16:54:37
This test is essential. I commented on the bug alr
| |
| 142 return NULL; | |
| 143 } | |
| 144 return snapshot; | 139 return snapshot; |
| 145 } | 140 } |
| 146 | 141 |
| 147 | 142 |
| 148 RawSmi* BaseReader::ReadAsSmi() { | 143 RawSmi* BaseReader::ReadAsSmi() { |
| 149 intptr_t value = ReadIntptrValue(); | 144 intptr_t value = ReadIntptrValue(); |
| 150 ASSERT((value & kSmiTagMask) == kSmiTag); | 145 ASSERT((value & kSmiTagMask) == kSmiTag); |
| 151 return reinterpret_cast<RawSmi*>(value); | 146 return reinterpret_cast<RawSmi*>(value); |
| 152 } | 147 } |
| 153 | 148 |
| (...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1640 NoGCScope no_gc; | 1635 NoGCScope no_gc; |
| 1641 WriteObject(obj.raw()); | 1636 WriteObject(obj.raw()); |
| 1642 UnmarkAll(); | 1637 UnmarkAll(); |
| 1643 } else { | 1638 } else { |
| 1644 ThrowException(exception_type(), exception_msg()); | 1639 ThrowException(exception_type(), exception_msg()); |
| 1645 } | 1640 } |
| 1646 } | 1641 } |
| 1647 | 1642 |
| 1648 | 1643 |
| 1649 } // namespace dart | 1644 } // namespace dart |
| OLD | NEW |