Modularize to avoid inline vs. not ShapeHasher static woes (595615, r=dbaron)

This commit is contained in:
Brendan Eich 2010-09-12 09:34:56 -07:00
parent 0366d26673
commit 7bcb596924
3 changed files with 38 additions and 29 deletions

View File

@ -438,6 +438,37 @@ PropertyTree::getChild(JSContext *cx, Shape *parent, const Shape &child)
} }
#ifdef DEBUG #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 void
Shape::dump(JSContext *cx, FILE *fp) const Shape::dump(JSContext *cx, FILE *fp) const
{ {
@ -495,9 +526,6 @@ Shape::dump(JSContext *cx, FILE *fp) const
fprintf(fp, "shortid %d\n", shortid); fprintf(fp, "shortid %d\n", shortid);
} }
#endif
#ifdef DEBUG
static void static void
MeterKidCount(JSBasicStats *bs, uintN nkids) MeterKidCount(JSBasicStats *bs, uintN nkids)

View File

@ -63,8 +63,8 @@ struct ShapeHasher {
typedef js::Shape *Key; typedef js::Shape *Key;
typedef const js::Shape *Lookup; typedef const js::Shape *Lookup;
static HashNumber hash(const Lookup l); static inline HashNumber hash(const Lookup l);
static bool match(Key k, Lookup l); static inline bool match(Key k, Lookup l);
}; };
typedef HashSet<js::Shape *, ShapeHasher, SystemAllocPolicy> KidsHash; typedef HashSet<js::Shape *, ShapeHasher, SystemAllocPolicy> KidsHash;
@ -117,6 +117,10 @@ class KidsPointer {
JS_ASSERT((reinterpret_cast<jsuword>(hash) & TAG) == 0); JS_ASSERT((reinterpret_cast<jsuword>(hash) & TAG) == 0);
w = reinterpret_cast<jsuword>(hash) | HASH; w = reinterpret_cast<jsuword>(hash) | HASH;
} }
#ifdef DEBUG
void checkConsistency(const js::Shape *aKid) const;
#endif
}; };
class PropertyTree class PropertyTree

View File

@ -687,30 +687,7 @@ JSObject::checkShapeConsistency()
} }
if (prev) { if (prev) {
JS_ASSERT(prev->slotSpan >= shape->slotSpan); JS_ASSERT(prev->slotSpan >= shape->slotSpan);
if (shape->kids.isShape()) { shape->kids.checkConsistency(prev);
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);
}
} }
prev = shape; prev = shape;
} }