diff --git a/js/src/jspropertytree.cpp b/js/src/jspropertytree.cpp index 0b7875fe7a8..a42c19b6108 100644 --- a/js/src/jspropertytree.cpp +++ b/js/src/jspropertytree.cpp @@ -438,6 +438,37 @@ PropertyTree::getChild(JSContext *cx, Shape *parent, const Shape &child) } #ifdef DEBUG + +void +KidsPointer::checkConsistency(const Shape *aKid) const +{ + if (isShape()) { + JS_ASSERT(toShape() == aKid); + } else if (isChunk()) { + bool found = false; + for (KidsChunk *chunk = toChunk(); chunk; chunk = chunk->next) { + for (uintN i = 0; i < MAX_KIDS_PER_CHUNK; i++) { + if (!chunk->kids[i]) { + JS_ASSERT(!chunk->next); + for (uintN j = i + 1; j < MAX_KIDS_PER_CHUNK; j++) + JS_ASSERT(!chunk->kids[j]); + break; + } + if (chunk->kids[i] == aKid) { + JS_ASSERT(!found); + found = true; + } + } + } + JS_ASSERT(found); + } else { + JS_ASSERT(isHash()); + KidsHash *hash = toHash(); + KidsHash::Ptr ptr = hash->lookup(aKid); + JS_ASSERT(*ptr == aKid); + } +} + void Shape::dump(JSContext *cx, FILE *fp) const { @@ -495,9 +526,6 @@ Shape::dump(JSContext *cx, FILE *fp) const fprintf(fp, "shortid %d\n", shortid); } -#endif - -#ifdef DEBUG static void MeterKidCount(JSBasicStats *bs, uintN nkids) diff --git a/js/src/jspropertytree.h b/js/src/jspropertytree.h index 8703f9ee022..1b58de257d0 100644 --- a/js/src/jspropertytree.h +++ b/js/src/jspropertytree.h @@ -63,8 +63,8 @@ struct ShapeHasher { typedef js::Shape *Key; typedef const js::Shape *Lookup; - static HashNumber hash(const Lookup l); - static bool match(Key k, Lookup l); + static inline HashNumber hash(const Lookup l); + static inline bool match(Key k, Lookup l); }; typedef HashSet KidsHash; @@ -117,6 +117,10 @@ class KidsPointer { JS_ASSERT((reinterpret_cast(hash) & TAG) == 0); w = reinterpret_cast(hash) | HASH; } + +#ifdef DEBUG + void checkConsistency(const js::Shape *aKid) const; +#endif }; class PropertyTree diff --git a/js/src/jsscope.cpp b/js/src/jsscope.cpp index 43b7d3fa1ca..1c2148f9b2a 100644 --- a/js/src/jsscope.cpp +++ b/js/src/jsscope.cpp @@ -687,30 +687,7 @@ JSObject::checkShapeConsistency() } if (prev) { JS_ASSERT(prev->slotSpan >= shape->slotSpan); - if (shape->kids.isShape()) { - JS_ASSERT(shape->kids.toShape() == prev); - } else if (shape->kids.isChunk()) { - bool found = false; - for (KidsChunk *chunk = shape->kids.toChunk(); chunk; chunk = chunk->next) { - for (uintN i = 0; i < MAX_KIDS_PER_CHUNK; i++) { - if (!chunk->kids[i]) { - JS_ASSERT(!chunk->next); - for (uintN j = i + 1; j < MAX_KIDS_PER_CHUNK; j++) - JS_ASSERT(!chunk->kids[j]); - JS_ASSERT(found); - } - if (chunk->kids[i] == prev) { - JS_ASSERT(!found); - found = true; - } - } - } - } else { - JS_ASSERT(shape->kids.isHash()); - KidsHash *hash = shape->kids.toHash(); - KidsHash::Ptr ptr = hash->lookup(prev); - JS_ASSERT(*ptr == prev); - } + shape->kids.checkConsistency(prev); } prev = shape; }