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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/disassembler_x64.cc ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/raw_object.h
===================================================================
--- runtime/vm/raw_object.h (revision 44128)
+++ runtime/vm/raw_object.h (working copy)
@@ -284,7 +284,13 @@
class ClassIdTag :
public BitField<intptr_t, kClassIdTagPos, kClassIdTagSize> {}; // NOLINT
+ bool IsWellFormed() const {
+ uword value = reinterpret_cast<uword>(this);
+ return (value & kSmiTagMask) == 0 ||
+ Utils::IsAligned(value - kHeapObjectTag, kWordSize);
+ }
bool IsHeapObject() const {
+ ASSERT(IsWellFormed());
uword value = reinterpret_cast<uword>(this);
return (value & kSmiTagMask) == kHeapObjectTag;
}
@@ -305,6 +311,7 @@
// Like !IsHeapObject() || IsOldObject(), but compiles to a single branch.
bool IsSmiOrOldObject() const {
+ ASSERT(IsWellFormed());
COMPILE_ASSERT(kHeapObjectTag == 1);
COMPILE_ASSERT(kNewObjectAlignmentOffset == kWordSize);
static const uword kNewObjectBits =
« 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