Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: runtime/vm/raw_object.h

Issue 975443003: Catch corrupted pointers earlier. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/disassembler_x64.cc ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef VM_RAW_OBJECT_H_ 5 #ifndef VM_RAW_OBJECT_H_
6 #define VM_RAW_OBJECT_H_ 6 #define VM_RAW_OBJECT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/atomic.h" 9 #include "vm/atomic.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return (size > kMaxSizeTag) ? 0 : (size >> kObjectAlignmentLog2); 277 return (size > kMaxSizeTag) ? 0 : (size >> kObjectAlignmentLog2);
278 } 278 }
279 static intptr_t TagValueToSize(intptr_t value) { 279 static intptr_t TagValueToSize(intptr_t value) {
280 return value << kObjectAlignmentLog2; 280 return value << kObjectAlignmentLog2;
281 } 281 }
282 }; 282 };
283 283
284 class ClassIdTag : 284 class ClassIdTag :
285 public BitField<intptr_t, kClassIdTagPos, kClassIdTagSize> {}; // NOLINT 285 public BitField<intptr_t, kClassIdTagPos, kClassIdTagSize> {}; // NOLINT
286 286
287 bool IsWellFormed() const {
288 uword value = reinterpret_cast<uword>(this);
289 return (value & kSmiTagMask) == 0 ||
290 Utils::IsAligned(value - kHeapObjectTag, kWordSize);
291 }
287 bool IsHeapObject() const { 292 bool IsHeapObject() const {
293 ASSERT(IsWellFormed());
288 uword value = reinterpret_cast<uword>(this); 294 uword value = reinterpret_cast<uword>(this);
289 return (value & kSmiTagMask) == kHeapObjectTag; 295 return (value & kSmiTagMask) == kHeapObjectTag;
290 } 296 }
291 // Assumes this is a heap object. 297 // Assumes this is a heap object.
292 bool IsNewObject() const { 298 bool IsNewObject() const {
293 ASSERT(IsHeapObject()); 299 ASSERT(IsHeapObject());
294 uword addr = reinterpret_cast<uword>(this); 300 uword addr = reinterpret_cast<uword>(this);
295 return (addr & kNewObjectAlignmentOffset) == kNewObjectAlignmentOffset; 301 return (addr & kNewObjectAlignmentOffset) == kNewObjectAlignmentOffset;
296 } 302 }
297 // Assumes this is a heap object. 303 // Assumes this is a heap object.
298 bool IsOldObject() const { 304 bool IsOldObject() const {
299 ASSERT(IsHeapObject()); 305 ASSERT(IsHeapObject());
300 uword addr = reinterpret_cast<uword>(this); 306 uword addr = reinterpret_cast<uword>(this);
301 return (addr & kNewObjectAlignmentOffset) == kOldObjectAlignmentOffset; 307 return (addr & kNewObjectAlignmentOffset) == kOldObjectAlignmentOffset;
302 } 308 }
303 // Assumes this is a heap object. 309 // Assumes this is a heap object.
304 bool IsVMHeapObject() const; 310 bool IsVMHeapObject() const;
305 311
306 // Like !IsHeapObject() || IsOldObject(), but compiles to a single branch. 312 // Like !IsHeapObject() || IsOldObject(), but compiles to a single branch.
307 bool IsSmiOrOldObject() const { 313 bool IsSmiOrOldObject() const {
314 ASSERT(IsWellFormed());
308 COMPILE_ASSERT(kHeapObjectTag == 1); 315 COMPILE_ASSERT(kHeapObjectTag == 1);
309 COMPILE_ASSERT(kNewObjectAlignmentOffset == kWordSize); 316 COMPILE_ASSERT(kNewObjectAlignmentOffset == kWordSize);
310 static const uword kNewObjectBits = 317 static const uword kNewObjectBits =
311 (kNewObjectAlignmentOffset | kHeapObjectTag); 318 (kNewObjectAlignmentOffset | kHeapObjectTag);
312 const uword addr = reinterpret_cast<uword>(this); 319 const uword addr = reinterpret_cast<uword>(this);
313 return (addr & kNewObjectBits) != kNewObjectBits; 320 return (addr & kNewObjectBits) != kNewObjectBits;
314 } 321 }
315 322
316 // Support for GC marking bit. 323 // Support for GC marking bit.
317 bool IsMarked() const { 324 bool IsMarked() const {
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2169 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2163 kTypedDataInt8ArrayViewCid + 15); 2170 kTypedDataInt8ArrayViewCid + 15);
2164 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2171 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2165 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2172 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2166 return (kNullCid - kTypedDataInt8ArrayCid); 2173 return (kNullCid - kTypedDataInt8ArrayCid);
2167 } 2174 }
2168 2175
2169 } // namespace dart 2176 } // namespace dart
2170 2177
2171 #endif // VM_RAW_OBJECT_H_ 2178 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/disassembler_x64.cc ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698