Bug 730933 - Make IsAboutToBeFinalized indirect; r=billm

This additionally moves the interface into js::gc:: and renames it to
CheckFooMarked.
This commit is contained in:
Terrence Cole
2012-05-23 10:34:29 -07:00
parent 0e13ab9b13
commit 21763adf0c
16 changed files with 224 additions and 118 deletions

View File

@@ -165,7 +165,7 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, RuntimeAllocPolicy>, publ
private:
bool markValue(JSTracer *trc, Value *x) {
if (gc::IsMarked(*x))
if (gc::IsMarked(x))
return false;
gc::Mark(trc, x, "WeakMap entry");
return true;
@@ -178,11 +178,16 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, RuntimeAllocPolicy>, publ
bool markIteratively(JSTracer *trc) {
bool markedAny = false;
for (Range r = Base::all(); !r.empty(); r.popFront()) {
for (Enum e(*this); !e.empty(); e.popFront()) {
/* If the entry is live, ensure its key and value are marked. */
if (gc::IsMarked(r.front().key) && markValue(trc, &r.front().value))
markedAny = true;
JS_ASSERT_IF(gc::IsMarked(r.front().key), gc::IsMarked(r.front().value));
Key k(e.front().key);
bool keyIsMarked = gc::IsMarked(&k);
if (keyIsMarked) {
if (markValue(trc, &e.front().value))
markedAny = true;
e.rekeyFront(k);
}
JS_ASSERT_IF(keyIsMarked, gc::IsMarked(&e.front().value));
}
return markedAny;
}
@@ -190,7 +195,8 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, RuntimeAllocPolicy>, publ
void sweep(JSTracer *trc) {
/* Remove all entries whose keys remain unmarked. */
for (Enum e(*this); !e.empty(); e.popFront()) {
if (!gc::IsMarked(e.front().key))
Key k(e.front().key);
if (!gc::IsMarked(&k))
e.removeFront();
}
@@ -200,8 +206,12 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, RuntimeAllocPolicy>, publ
* known-live part of the graph.
*/
for (Range r = Base::all(); !r.empty(); r.popFront()) {
JS_ASSERT(gc::IsMarked(r.front().key));
JS_ASSERT(gc::IsMarked(r.front().value));
Key k(r.front().key);
Value v(r.front().value);
JS_ASSERT(gc::IsMarked(&k));
JS_ASSERT(gc::IsMarked(&v));
JS_ASSERT(k == r.front().key);
JS_ASSERT(v == r.front().value);
}
#endif
}