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

Unified Diff: runtime/vm/object.cc

Issue 17104002: Fix a bug in instance canonicalization and add debug mode checks that we are not missing any fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 24044)
+++ runtime/vm/object.cc (working copy)
@@ -9202,6 +9202,28 @@
}
+#if defined(DEBUG)
+class CheckForPointers : public ObjectPointerVisitor {
+ public:
+ explicit CheckForPointers(Isolate* isolate)
+ : ObjectPointerVisitor(isolate), has_pointers_(false) {}
+
+ bool has_pointers() const { return has_pointers_; }
+
+ void VisitPointers(RawObject** first, RawObject** last) {
+ if (first != last) {
+ has_pointers_ = true;
+ }
+ }
+
+ private:
+ bool has_pointers_;
+
+ DISALLOW_COPY_AND_ASSIGN(CheckForPointers);
+};
+#endif // DEBUG
+
+
RawInstance* Instance::CheckAndCanonicalize(const char** error_str) const {
ASSERT(!IsNull());
if (this->IsCanonical()) {
@@ -9211,7 +9233,7 @@
const Class& cls = Class::Handle(this->clazz());
// TODO(srdjan): Check that predefined classes do not have fields that need
// to be checked/canonicalized as well.
- if ((cls.id() >= kNumPredefinedCids) || cls.IsArray()) {
+ if ((cls.id() >= kNumPredefinedCids) || IsArray()) {
// Iterate over all fields, canonicalize numbers and strings, expect all
// other instances to be canonical otherwise report error (return
// Instance::null()).
@@ -9238,6 +9260,13 @@
}
}
}
+ } else {
+#if defined(DEBUG)
+ // Make sure that we are not missing any fields.
+ CheckForPointers has_pointers(Isolate::Current());
+ this->raw()->VisitPointers(&has_pointers);
+ ASSERT(!has_pointers.has_pointers());
+#endif // DEBUG
}
Array& constants = Array::Handle(cls.constants());
const intptr_t constants_len = constants.Length();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698