| 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();
|
|
|