bug 660441 - removal of cx parameter from IsAboutToBeFinalized. r=anygregor

This commit is contained in:
Igor Bukanov 2012-02-08 01:51:32 +01:00
parent 79119f394a
commit 68b70a8965
22 changed files with 90 additions and 114 deletions

View File

@ -27,7 +27,7 @@ JSBool
GCCallback(JSContext *cx, JSGCStatus status)
{
if (status == JSGC_MARK_END)
sw.strOk = !JS_IsAboutToBeFinalized(cx, sw.str);
sw.strOk = !JS_IsAboutToBeFinalized(sw.str);
return true;
}

View File

@ -18,7 +18,7 @@ TestAboutToBeFinalizedCallback(JSContext *cx, JSGCStatus status)
for (jsuint i = 0; i != checkPointersLength; ++i) {
void *p = checkPointers[i];
JS_ASSERT(p);
if (JS_IsAboutToBeFinalized(cx, p))
if (JS_IsAboutToBeFinalized(p))
checkPointers[i] = NULL;
}
}

View File

@ -2897,11 +2897,11 @@ JS_SetGCCallbackRT(JSRuntime *rt, JSGCCallback cb)
}
JS_PUBLIC_API(JSBool)
JS_IsAboutToBeFinalized(JSContext *cx, void *thing)
JS_IsAboutToBeFinalized(void *thing)
{
JS_ASSERT(thing);
JS_ASSERT(!cx->runtime->gcIncrementalTracer);
return IsAboutToBeFinalized(cx, (gc::Cell *)thing);
gc::Cell *t = static_cast<gc::Cell *>(thing);
JS_ASSERT(!t->compartment()->rt->gcIncrementalTracer);
return IsAboutToBeFinalized(t);
}
JS_PUBLIC_API(void)
@ -2995,7 +2995,7 @@ JS_SetNativeStackQuota(JSRuntime *rt, size_t stackSize)
rt->nativeStackQuota = stackSize;
if (!rt->nativeStackBase)
return;
#if JS_STACK_GROWTH_DIRECTION > 0
if (stackSize == 0) {
rt->nativeStackLimit = UINTPTR_MAX;

View File

@ -3250,7 +3250,7 @@ extern JS_PUBLIC_API(JSBool)
JS_IsGCMarkingTracer(JSTracer *trc);
extern JS_PUBLIC_API(JSBool)
JS_IsAboutToBeFinalized(JSContext *cx, void *thing);
JS_IsAboutToBeFinalized(void *thing);
typedef enum JSGCParamKey {
/* Maximum nominal heap before last ditch GC. */

View File

@ -401,20 +401,20 @@ js_TraceAtomState(JSTracer *trc)
}
void
js_SweepAtomState(JSContext *cx)
js_SweepAtomState(JSRuntime *rt)
{
JSAtomState *state = &cx->runtime->atomState;
JSAtomState *state = &rt->atomState;
for (AtomSet::Enum e(state->atoms); !e.empty(); e.popFront()) {
AtomStateEntry entry = e.front();
if (entry.isTagged()) {
/* Pinned or interned key cannot be finalized. */
JS_ASSERT(!IsAboutToBeFinalized(cx, entry.asPtr()));
JS_ASSERT(!IsAboutToBeFinalized(entry.asPtr()));
continue;
}
if (IsAboutToBeFinalized(cx, entry.asPtr()))
if (IsAboutToBeFinalized(entry.asPtr()))
e.removeFront();
}
}

View File

@ -541,7 +541,7 @@ extern void
js_TraceAtomState(JSTracer *trc);
extern void
js_SweepAtomState(JSContext *cx);
js_SweepAtomState(JSRuntime *rt);
extern bool
js_InitCommonAtoms(JSContext *cx);

View File

@ -450,11 +450,11 @@ JSCompartment::sweep(JSContext *cx, bool releaseTypes)
{
/* Remove dead wrappers from the table. */
for (WrapperMap::Enum e(crossCompartmentWrappers); !e.empty(); e.popFront()) {
JS_ASSERT_IF(IsAboutToBeFinalized(cx, e.front().key) &&
!IsAboutToBeFinalized(cx, e.front().value),
JS_ASSERT_IF(IsAboutToBeFinalized(e.front().key) &&
!IsAboutToBeFinalized(e.front().value),
e.front().key.isString());
if (IsAboutToBeFinalized(cx, e.front().key) ||
IsAboutToBeFinalized(cx, e.front().value)) {
if (IsAboutToBeFinalized(e.front().key) ||
IsAboutToBeFinalized(e.front().value)) {
e.removeFront();
}
}
@ -466,7 +466,7 @@ JSCompartment::sweep(JSContext *cx, bool releaseTypes)
sweepNewTypeObjectTable(cx, newTypeObjects);
sweepNewTypeObjectTable(cx, lazyTypeObjects);
if (emptyTypeObject && IsAboutToBeFinalized(cx, emptyTypeObject))
if (emptyTypeObject && IsAboutToBeFinalized(emptyTypeObject))
emptyTypeObject = NULL;
newObjectCache.reset();
@ -745,7 +745,7 @@ JSCompartment::sweepBreakpoints(JSContext *cx)
JSScript *script = i.get<JSScript>();
if (!script->hasAnyBreakpointsOrStepMode())
continue;
bool scriptGone = IsAboutToBeFinalized(cx, script);
bool scriptGone = IsAboutToBeFinalized(script);
for (unsigned i = 0; i < script->length; i++) {
BreakpointSite *site = script->getBreakpointSite(script->code + i);
if (!site)
@ -755,7 +755,7 @@ JSCompartment::sweepBreakpoints(JSContext *cx)
Breakpoint *nextbp;
for (Breakpoint *bp = site->firstBreakpoint(); bp; bp = nextbp) {
nextbp = bp->nextInSite();
if (scriptGone || IsAboutToBeFinalized(cx, bp->debugger->toJSObject()))
if (scriptGone || IsAboutToBeFinalized(bp->debugger->toJSObject()))
bp->destroy(cx);
}
}

View File

@ -282,11 +282,11 @@ typedef void
void *v, JSGCTraceKind vkind);
struct WeakMapTracer {
JSContext *context;
JSRuntime *runtime;
WeakMapTraceCallback callback;
WeakMapTracer(JSContext *cx, WeakMapTraceCallback cb)
: context(cx), callback(cb) {}
WeakMapTracer(JSRuntime *rt, WeakMapTraceCallback cb)
: runtime(rt), callback(cb) {}
};
extern JS_FRIEND_API(void)

View File

@ -836,13 +836,10 @@ PickChunk(JSCompartment *comp)
}
JS_FRIEND_API(bool)
IsAboutToBeFinalized(JSContext *cx, const Cell *thing)
IsAboutToBeFinalized(const Cell *thing)
{
JS_ASSERT(cx);
JSCompartment *thingCompartment = reinterpret_cast<const Cell *>(thing)->compartment();
JSRuntime *rt = cx->runtime;
JS_ASSERT(rt == thingCompartment->rt);
JSRuntime *rt = thingCompartment->rt;
if (rt->gcCurrentCompartment != NULL && rt->gcCurrentCompartment != thingCompartment)
return false;
@ -850,10 +847,10 @@ IsAboutToBeFinalized(JSContext *cx, const Cell *thing)
}
bool
IsAboutToBeFinalized(JSContext *cx, const Value &v)
IsAboutToBeFinalized(const Value &v)
{
JS_ASSERT(v.isMarkable());
return IsAboutToBeFinalized(cx, (Cell *)v.toGCThing());
return IsAboutToBeFinalized((Cell *)v.toGCThing());
}
/* Lifetime for type sets attached to scripts containing observed types. */
@ -2751,10 +2748,10 @@ SweepPhase(JSContext *cx, GCMarker *gcmarker, JSGCInvocationKind gckind)
/* Finalize unreachable (key,value) pairs in all weak maps. */
WeakMapBase::sweepAll(gcmarker);
js_SweepAtomState(cx);
js_SweepAtomState(rt);
/* Collect watch points associated with unreachable objects. */
WatchpointMap::sweepAll(cx);
WatchpointMap::sweepAll(rt);
if (!rt->gcCurrentCompartment)
Debugger::sweepAll(cx);

View File

@ -1358,10 +1358,10 @@ extern void
js_UnlockGCThingRT(JSRuntime *rt, void *thing);
extern JS_FRIEND_API(bool)
IsAboutToBeFinalized(JSContext *cx, const js::gc::Cell *thing);
IsAboutToBeFinalized(const js::gc::Cell *thing);
extern bool
IsAboutToBeFinalized(JSContext *cx, const js::Value &value);
IsAboutToBeFinalized(const js::Value &value);
extern void
js_TraceStackFrame(JSTracer *trc, js::StackFrame *fp);

View File

@ -221,23 +221,23 @@ Mark(JSTracer *trc, const MarkablePtr<JSXML> &xml, const char *name)
}
inline bool
IsMarked(JSContext *cx, const js::Value &v)
IsMarked(const js::Value &v)
{
if (v.isMarkable())
return !IsAboutToBeFinalized(cx, v);
return !IsAboutToBeFinalized(v);
return true;
}
inline bool
IsMarked(JSContext *cx, JSObject *o)
IsMarked(JSObject *o)
{
return !IsAboutToBeFinalized(cx, o);
return !IsAboutToBeFinalized(o);
}
inline bool
IsMarked(JSContext *cx, Cell *cell)
IsMarked(Cell *cell)
{
return !IsAboutToBeFinalized(cx, cell);
return !IsAboutToBeFinalized(cell);
}
} /* namespace gc */

View File

@ -5033,7 +5033,7 @@ TypeMonitorCallSlow(JSContext *cx, JSObject *callee,
}
static inline bool
IsAboutToBeFinalized(JSContext *cx, TypeObjectKey *key)
IsAboutToBeFinalized(TypeObjectKey *key)
{
/* Mask out the low bit indicating whether this is a type or JS object. */
return !reinterpret_cast<const gc::Cell *>(uintptr_t(key) & ~1)->isMarked();
@ -5946,7 +5946,7 @@ TypeSet::sweep(JSContext *cx, JSCompartment *compartment)
objectCount = 0;
for (unsigned i = 0; i < oldCapacity; i++) {
TypeObjectKey *object = oldArray[i];
if (object && !IsAboutToBeFinalized(cx, object)) {
if (object && !IsAboutToBeFinalized(object)) {
TypeObjectKey **pentry =
HashSetInsert<TypeObjectKey *,TypeObjectKey,TypeObjectKey>
(compartment, objectSet, objectCount, object);
@ -5959,7 +5959,7 @@ TypeSet::sweep(JSContext *cx, JSCompartment *compartment)
setBaseObjectCount(objectCount);
} else if (objectCount == 1) {
TypeObjectKey *object = (TypeObjectKey *) objectSet;
if (IsAboutToBeFinalized(cx, object)) {
if (IsAboutToBeFinalized(object)) {
objectSet = NULL;
setBaseObjectCount(0);
}
@ -6159,7 +6159,7 @@ TypeCompartment::sweep(JSContext *cx)
const AllocationSiteKey &key = e.front().key;
TypeObject *object = e.front().value;
if (IsAboutToBeFinalized(cx, key.script) || !object->isMarked())
if (IsAboutToBeFinalized(key.script) || !object->isMarked())
e.removeFront();
}
}
@ -6221,7 +6221,7 @@ TypeScript::Sweep(JSContext *cx, JSScript *script)
Type type = result->type;
if (!type.isUnknown() && !type.isAnyObject() && type.isObject() &&
IsAboutToBeFinalized(cx, type.objectKey())) {
IsAboutToBeFinalized(type.objectKey())) {
*presult = result->next;
cx->delete_(result);
} else {

View File

@ -196,11 +196,10 @@ WatchpointMap::markAllIteratively(JSTracer *trc)
bool
WatchpointMap::markIteratively(JSTracer *trc)
{
JSContext *cx = trc->context;
bool marked = false;
for (Map::Range r = map.all(); !r.empty(); r.popFront()) {
Map::Entry &e = r.front();
bool objectIsLive = !IsAboutToBeFinalized(cx, e.key.object);
bool objectIsLive = !IsAboutToBeFinalized(e.key.object);
if (objectIsLive || e.value.held) {
if (!objectIsLive) {
MarkObject(trc, e.key.object, "held Watchpoint object");
@ -211,7 +210,7 @@ WatchpointMap::markIteratively(JSTracer *trc)
JS_ASSERT(JSID_IS_STRING(id) || JSID_IS_INT(id));
MarkId(trc, id, "WatchKey::id");
if (e.value.closure && IsAboutToBeFinalized(cx, e.value.closure)) {
if (e.value.closure && IsAboutToBeFinalized(e.value.closure)) {
MarkObject(trc, e.value.closure, "Watchpoint::closure");
marked = true;
}
@ -236,26 +235,25 @@ WatchpointMap::markAll(JSTracer *trc)
}
void
WatchpointMap::sweepAll(JSContext *cx)
WatchpointMap::sweepAll(JSRuntime *rt)
{
JSRuntime *rt = cx->runtime;
if (rt->gcCurrentCompartment) {
if (WatchpointMap *wpmap = rt->gcCurrentCompartment->watchpointMap)
wpmap->sweep(cx);
wpmap->sweep();
} else {
for (CompartmentsIter c(rt); !c.done(); c.next()) {
if (WatchpointMap *wpmap = c->watchpointMap)
wpmap->sweep(cx);
wpmap->sweep();
}
}
}
void
WatchpointMap::sweep(JSContext *cx)
WatchpointMap::sweep()
{
for (Map::Enum r(map); !r.empty(); r.popFront()) {
Map::Entry &e = r.front();
if (IsAboutToBeFinalized(cx, e.key.object)) {
if (IsAboutToBeFinalized(e.key.object)) {
JS_ASSERT(!e.value.held);
r.removeFront();
}
@ -265,7 +263,7 @@ WatchpointMap::sweep(JSContext *cx)
void
WatchpointMap::traceAll(WeakMapTracer *trc)
{
JSRuntime *rt = trc->context->runtime;
JSRuntime *rt = trc->runtime;
for (JSCompartment **c = rt->compartments.begin(); c != rt->compartments.end(); ++c) {
if (WatchpointMap *wpmap = (*c)->watchpointMap)
wpmap->trace(trc);

View File

@ -91,8 +91,8 @@ class WatchpointMap {
static bool markAllIteratively(JSTracer *trc);
bool markIteratively(JSTracer *trc);
void markAll(JSTracer *trc);
static void sweepAll(JSContext *cx);
void sweep(JSContext *cx);
static void sweepAll(JSRuntime *rt);
void sweep();
static void traceAll(WeakMapTracer *trc);
void trace(WeakMapTracer *trc);

View File

@ -81,7 +81,7 @@ WeakMapBase::sweepAll(JSTracer *tracer)
void
WeakMapBase::traceAllMappings(WeakMapTracer *tracer)
{
JSRuntime *rt = tracer->context->runtime;
JSRuntime *rt = tracer->runtime;
for (WeakMapBase *m = rt->gcWeakMapList; m; m = m->next)
m->traceMappings(tracer);
}

View File

@ -261,7 +261,7 @@ class DefaultMarkPolicy<HeapValue> {
DefaultMarkPolicy(JSTracer *t) : tracer(t) { }
bool isMarked(const HeapValue &x) {
if (x.isMarkable())
return !IsAboutToBeFinalized(tracer->context, x);
return !IsAboutToBeFinalized(x);
return true;
}
bool mark(const HeapValue &x) {
@ -279,7 +279,7 @@ class DefaultMarkPolicy<HeapPtrObject> {
public:
DefaultMarkPolicy(JSTracer *t) : tracer(t) { }
bool isMarked(const HeapPtrObject &x) {
return !IsAboutToBeFinalized(tracer->context, x);
return !IsAboutToBeFinalized(x);
}
bool mark(const HeapPtrObject &x) {
if (isMarked(x))
@ -296,7 +296,7 @@ class DefaultMarkPolicy<HeapPtrScript> {
public:
DefaultMarkPolicy(JSTracer *t) : tracer(t) { }
bool isMarked(const HeapPtrScript &x) {
return !IsAboutToBeFinalized(tracer->context, x);
return !IsAboutToBeFinalized(x);
}
bool mark(const HeapPtrScript &x) {
if (isMarked(x))

View File

@ -399,7 +399,7 @@ Debugger::getHook(Hook hook) const
}
bool
Debugger::hasAnyLiveHooks(JSContext *cx) const
Debugger::hasAnyLiveHooks() const
{
if (!enabled)
return false;
@ -414,7 +414,7 @@ Debugger::hasAnyLiveHooks(JSContext *cx) const
/* If any breakpoints are in live scripts, return true. */
for (Breakpoint *bp = firstBreakpoint(); bp; bp = bp->nextInDebugger()) {
if (!IsAboutToBeFinalized(cx, bp->site->script))
if (!IsAboutToBeFinalized(bp->site->script))
return true;
}
@ -1063,14 +1063,14 @@ Debugger::markKeysInCompartment(JSTracer *tracer)
const ObjectMap &objStorage = objects;
for (ObjectMap::Range r = objStorage.all(); !r.empty(); r.popFront()) {
const HeapPtrObject &key = r.front().key;
if (key->compartment() == comp && IsAboutToBeFinalized(tracer->context, key))
if (key->compartment() == comp && IsAboutToBeFinalized(key))
gc::MarkObject(tracer, key, "cross-compartment WeakMap key");
}
const ObjectMap &envStorage = environments;
for (ObjectMap::Range r = envStorage.all(); !r.empty(); r.popFront()) {
const HeapPtrObject &key = r.front().key;
if (key->compartment() == comp && IsAboutToBeFinalized(tracer->context, key))
if (key->compartment() == comp && IsAboutToBeFinalized(key))
js::gc::MarkObject(tracer, key, "cross-compartment WeakMap key");
}
@ -1079,7 +1079,7 @@ Debugger::markKeysInCompartment(JSTracer *tracer)
const ScriptMap &scriptStorage = scripts;
for (ScriptMap::Range r = scriptStorage.all(); !r.empty(); r.popFront()) {
const HeapPtrScript &key = r.front().key;
if (key->compartment() == comp && IsAboutToBeFinalized(tracer->context, key))
if (key->compartment() == comp && IsAboutToBeFinalized(key))
gc::MarkScript(tracer, key, "cross-compartment WeakMap key");
}
}
@ -1143,8 +1143,7 @@ Debugger::markAllIteratively(GCMarker *trc)
* Find all Debugger objects in danger of GC. This code is a little
* convoluted since the easiest way to find them is via their debuggees.
*/
JSContext *cx = trc->context;
JSRuntime *rt = cx->runtime;
JSRuntime *rt = trc->runtime;
JSCompartment *comp = rt->gcCurrentCompartment;
for (JSCompartment **c = rt->compartments.begin(); c != rt->compartments.end(); c++) {
JSCompartment *dc = *c;
@ -1159,7 +1158,7 @@ Debugger::markAllIteratively(GCMarker *trc)
const GlobalObjectSet &debuggees = dc->getDebuggees();
for (GlobalObjectSet::Range r = debuggees.all(); !r.empty(); r.popFront()) {
GlobalObject *global = r.front();
if (IsAboutToBeFinalized(cx, global))
if (IsAboutToBeFinalized(global))
continue;
/*
@ -1181,8 +1180,8 @@ Debugger::markAllIteratively(GCMarker *trc)
if (comp && comp != dbgobj->compartment())
continue;
bool dbgMarked = !IsAboutToBeFinalized(cx, dbgobj);
if (!dbgMarked && dbg->hasAnyLiveHooks(cx)) {
bool dbgMarked = !IsAboutToBeFinalized(dbgobj);
if (!dbgMarked && dbg->hasAnyLiveHooks()) {
/*
* obj could be reachable only via its live, enabled
* debugger hooks, which may yet be called.
@ -1195,13 +1194,13 @@ Debugger::markAllIteratively(GCMarker *trc)
if (dbgMarked) {
/* Search for breakpoints to mark. */
for (Breakpoint *bp = dbg->firstBreakpoint(); bp; bp = bp->nextInDebugger()) {
if (!IsAboutToBeFinalized(cx, bp->site->script)) {
if (!IsAboutToBeFinalized(bp->site->script)) {
/*
* The debugger and the script are both live.
* Therefore the breakpoint handler is live.
*/
const HeapPtrObject &handler = bp->getHandler();
if (IsAboutToBeFinalized(cx, handler)) {
if (IsAboutToBeFinalized(handler)) {
MarkObject(trc, bp->getHandler(), "breakpoint handler");
markedAny = true;
}
@ -1260,7 +1259,7 @@ Debugger::sweepAll(JSContext *cx)
for (JSCList *p = &rt->debuggerList; (p = JS_NEXT_LINK(p)) != &rt->debuggerList;) {
Debugger *dbg = Debugger::fromLinks(p);
if (IsAboutToBeFinalized(cx, dbg->object)) {
if (IsAboutToBeFinalized(dbg->object)) {
/*
* dbg is being GC'd. Detach it from its debuggees. In the case of
* runtime-wide GC, the debuggee might be GC'd too. Since detaching
@ -1281,7 +1280,7 @@ Debugger::sweepAll(JSContext *cx)
GlobalObjectSet &debuggees = (*c)->getDebuggees();
for (GlobalObjectSet::Enum e(debuggees); !e.empty(); e.popFront()) {
GlobalObject *global = e.front();
if (IsAboutToBeFinalized(cx, global))
if (IsAboutToBeFinalized(global))
detachAllDebuggersFromGlobal(cx, global, &e);
}
}

View File

@ -203,7 +203,7 @@ class Debugger {
static JSFunctionSpec methods[];
JSObject *getHook(Hook hook) const;
bool hasAnyLiveHooks(JSContext *cx) const;
bool hasAnyLiveHooks() const;
static JSTrapStatus slowPathOnEnterFrame(JSContext *cx, Value *vp);
static void slowPathOnLeaveFrame(JSContext *cx);

View File

@ -95,29 +95,19 @@ const char* XPCJSRuntime::mStrings[] = {
/***************************************************************************/
// data holder class for the enumerator callback below
struct JSDyingJSObjectData
{
JSContext* cx;
nsTArray<nsXPCWrappedJS*>* array;
};
static JSDHashOperator
WrappedJSDyingJSObjectFinder(JSDHashTable *table, JSDHashEntryHdr *hdr,
uint32_t number, void *arg)
{
JSDyingJSObjectData* data = (JSDyingJSObjectData*) arg;
nsTArray<nsXPCWrappedJS*>* array = static_cast<nsTArray<nsXPCWrappedJS*>*>(arg);
nsXPCWrappedJS* wrapper = ((JSObject2WrappedJSMap::Entry*)hdr)->value;
NS_ASSERTION(wrapper, "found a null JS wrapper!");
// walk the wrapper chain and find any whose JSObject is to be finalized
while (wrapper) {
if (wrapper->IsSubjectToFinalization()) {
js::AutoSwitchCompartment sc(data->cx,
wrapper->GetJSObjectPreserveColor());
if (JS_IsAboutToBeFinalized(data->cx,
wrapper->GetJSObjectPreserveColor()))
data->array->AppendElement(wrapper);
if (JS_IsAboutToBeFinalized(wrapper->GetJSObjectPreserveColor()))
array->AppendElement(wrapper);
}
wrapper = wrapper->GetNextWrapper();
}
@ -608,11 +598,10 @@ static JSDHashOperator
SweepWaiverWrappers(JSDHashTable *table, JSDHashEntryHdr *hdr,
uint32_t number, void *arg)
{
JSContext *cx = (JSContext *)arg;
JSObject *key = ((JSObject2JSObjectMap::Entry *)hdr)->key;
JSObject *value = ((JSObject2JSObjectMap::Entry *)hdr)->value;
if (JS_IsAboutToBeFinalized(cx, key) || JS_IsAboutToBeFinalized(cx, value))
if (JS_IsAboutToBeFinalized(key) || JS_IsAboutToBeFinalized(value))
return JS_DHASH_REMOVE;
return JS_DHASH_NEXT;
}
@ -620,8 +609,7 @@ SweepWaiverWrappers(JSDHashTable *table, JSDHashEntryHdr *hdr,
static PLDHashOperator
SweepExpandos(XPCWrappedNative *wn, JSObject *&expando, void *arg)
{
JSContext *cx = (JSContext *)arg;
return JS_IsAboutToBeFinalized(cx, wn->GetFlatJSObjectPreserveColor())
return JS_IsAboutToBeFinalized(wn->GetFlatJSObjectPreserveColor())
? PL_DHASH_REMOVE
: PL_DHASH_NEXT;
}
@ -632,9 +620,9 @@ SweepCompartment(nsCStringHashKey& aKey, JSCompartment *compartment, void *aClos
xpc::CompartmentPrivate *priv = (xpc::CompartmentPrivate *)
JS_GetCompartmentPrivate((JSContext *)aClosure, compartment);
if (priv->waiverWrapperMap)
priv->waiverWrapperMap->Enumerate(SweepWaiverWrappers, (JSContext *)aClosure);
priv->waiverWrapperMap->Enumerate(SweepWaiverWrappers, nsnull);
if (priv->expandoMap)
priv->expandoMap->Enumerate(SweepExpandos, (JSContext *)aClosure);
priv->expandoMap->Enumerate(SweepExpandos, nsnull);
return PL_DHASH_NEXT;
}
@ -675,18 +663,14 @@ JSBool XPCJSRuntime::GCCallback(JSContext *cx, JSGCStatus status)
nsTArray<nsXPCWrappedJS*>* dyingWrappedJSArray =
&self->mWrappedJSToReleaseArray;
{
JSDyingJSObjectData data = {cx, dyingWrappedJSArray};
// Add any wrappers whose JSObjects are to be finalized to
// this array. Note that we do not want to be changing the
// refcount of these wrappers.
// We add them to the array now and Release the array members
// later to avoid the posibility of doing any JS GCThing
// allocations during the gc cycle.
self->mWrappedJSMap->
Enumerate(WrappedJSDyingJSObjectFinder, &data);
}
// Add any wrappers whose JSObjects are to be finalized to
// this array. Note that we do not want to be changing the
// refcount of these wrappers.
// We add them to the array now and Release the array members
// later to avoid the posibility of doing any JS GCThing
// allocations during the gc cycle.
self->mWrappedJSMap->
Enumerate(WrappedJSDyingJSObjectFinder, dyingWrappedJSArray);
// Find dying scopes.
XPCWrappedNativeScope::FinishedMarkPhaseOfGC(cx, self);

View File

@ -1276,7 +1276,7 @@ XPCWrappedNative::FlatJSObjectFinalized(JSContext *cx)
for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++) {
JSObject* jso = to->GetJSObject();
if (jso) {
NS_ASSERTION(JS_IsAboutToBeFinalized(cx, jso), "bad!");
NS_ASSERTION(JS_IsAboutToBeFinalized(jso), "bad!");
JS_SetPrivate(cx, jso, nsnull);
to->JSObjectFinalized();
}

View File

@ -418,10 +418,8 @@ XPCWrappedNativeScope::FinishedMarkPhaseOfGC(JSContext* cx, XPCJSRuntime* rt)
while (cur) {
XPCWrappedNativeScope* next = cur->mNext;
js::AutoSwitchCompartment sc(cx, cur->mGlobalJSObject);
if (cur->mGlobalJSObject &&
JS_IsAboutToBeFinalized(cx, cur->mGlobalJSObject)) {
JS_IsAboutToBeFinalized(cur->mGlobalJSObject)) {
cur->mGlobalJSObject.finalize(cx);
cur->mScriptObjectPrincipal = nsnull;
if (cur->GetCachedDOMPrototypes().IsInitialized())
@ -436,11 +434,11 @@ XPCWrappedNativeScope::FinishedMarkPhaseOfGC(JSContext* cx, XPCJSRuntime* rt)
cur = nsnull;
} else {
if (cur->mPrototypeJSObject &&
JS_IsAboutToBeFinalized(cx, cur->mPrototypeJSObject)) {
JS_IsAboutToBeFinalized(cur->mPrototypeJSObject)) {
cur->mPrototypeJSObject.finalize(cx);
}
if (cur->mPrototypeNoHelper &&
JS_IsAboutToBeFinalized(cx, cur->mPrototypeNoHelper)) {
JS_IsAboutToBeFinalized(cur->mPrototypeNoHelper)) {
cur->mPrototypeNoHelper = nsnull;
}
}

View File

@ -504,7 +504,7 @@ struct NoteWeakMapsTracer : public js::WeakMapTracer
{
NoteWeakMapsTracer(JSContext *cx, js::WeakMapTraceCallback cb,
nsCycleCollectionTraversalCallback &cccb)
: js::WeakMapTracer(cx, cb), mCb(cccb), mChildTracer(cccb)
: js::WeakMapTracer(js::GetRuntime(cx), cb), mCb(cccb), mChildTracer(cccb)
{
JS_TracerInit(&mChildTracer, cx, TraceWeakMappingChild);
}