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

Unified Diff: vm/raw_object.cc

Issue 10271032: - Add extra checking when validating objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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 | « vm/raw_object.h ('k') | vm/stub_code_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/raw_object.cc
===================================================================
--- vm/raw_object.cc (revision 7183)
+++ vm/raw_object.cc (working copy)
@@ -4,6 +4,7 @@
#include "vm/raw_object.h"
+#include "vm/class_table.h"
#include "vm/freelist.h"
#include "vm/isolate.h"
#include "vm/object.h"
@@ -12,7 +13,9 @@
namespace dart {
-void RawObject::Validate() const {
+void RawObject::Validate(Isolate* isolate) const {
+ // Validation only happens in DEBUG builds.
+#if defined(DEBUG)
if (Object::null_class_ == reinterpret_cast<RawClass*>(kHeapObjectTag)) {
// Validation relies on properly initialized class classes. Skip if the
// VM is still being initialized.
@@ -30,8 +33,12 @@
ASSERT(raw_class_class->ptr()->instance_kind_ == kClass);
// Validate that the tags_ field is sensible.
- intptr_t tags = ptr()->tags_;
+ uword tags = ptr()->tags_;
ASSERT((tags & 0x000000f0) == 0);
+ intptr_t cid = ClassTag::decode(tags);
+ RawClass* tag_class = isolate->class_table()->At(cid);
+ ASSERT(tag_class == raw_class);
+#endif
}
@@ -177,7 +184,7 @@
}
}
ASSERT(instance_size != 0);
- intptr_t tags = ptr()->tags_;
+ uword tags = ptr()->tags_;
ASSERT((instance_size == SizeTag::decode(tags)) ||
(SizeTag::decode(tags) == 0) ||
FreeBit::decode(tags));
« no previous file with comments | « vm/raw_object.h ('k') | vm/stub_code_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698