From c4ef452bd6e1f1b4b88dc917b99fd657c1aa8536 Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Fri, 3 Oct 2014 10:04:19 +0100 Subject: [PATCH] Bug 650161 - We don't need special fixup for CCWs after compacting GC r=terrence --- js/src/jscompartment.cpp | 37 +--------------------------- js/src/jscompartment.h | 1 - js/src/jsgc.cpp | 52 +++++++++++++++++++--------------------- 3 files changed, 25 insertions(+), 65 deletions(-) diff --git a/js/src/jscompartment.cpp b/js/src/jscompartment.cpp index 66446ae7d5a..f43d31bf750 100644 --- a/js/src/jscompartment.cpp +++ b/js/src/jscompartment.cpp @@ -512,9 +512,7 @@ JSCompartment::markCrossCompartmentWrappers(JSTracer *trc) * We have a cross-compartment wrapper. Its private pointer may * point into the compartment being collected, so we should mark it. */ - Value referent = wrapper->private_(); - MarkValueRoot(trc, &referent, "cross-compartment wrapper"); - MOZ_ASSERT(referent == wrapper->private_()); + MarkSlot(trc, wrapper->slotOfPrivate(), "cross-compartment wrapper"); } } } @@ -654,39 +652,6 @@ JSCompartment::sweepCrossCompartmentWrappers() #ifdef JSGC_COMPACTING -/* - * Fixup wrappers with moved keys or values. - */ -void -JSCompartment::fixupCrossCompartmentWrappers(JSTracer *trc) -{ - for (WrapperMap::Enum e(crossCompartmentWrappers); !e.empty(); e.popFront()) { - Value val = e.front().value(); - if (IsForwarded(val)) { - val = Forwarded(val); - e.front().value().set(val); - } - - // CrossCompartmentKey's hash does not depend on the debugger object, - // so update it but do not rekey if it changes - CrossCompartmentKey key = e.front().key(); - if (key.debugger) - key.debugger = MaybeForwarded(key.debugger); - if (key.wrapped && IsForwarded(key.wrapped)) { - key.wrapped = Forwarded(key.wrapped); - e.rekeyFront(key, key); - } - - if (!zone()->isCollecting() && val.isObject()) { - // Call the trace hook to update any pointers to relocated things. - JSObject *obj = &val.toObject(); - const Class *clasp = obj->getClass(); - if (clasp->trace) - clasp->trace(trc, obj); - } - } -} - void JSCompartment::fixupAfterMovingGC() { fixupGlobal(); diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h index 0d3f9e64602..7af8b6fd3d3 100644 --- a/js/src/jscompartment.h +++ b/js/src/jscompartment.h @@ -367,7 +367,6 @@ struct JSCompartment #ifdef JSGC_COMPACTING void fixupInitialShapeTable(); void fixupNewTypeObjectTable(js::types::TypeObjectWithNewScriptSet &table); - void fixupCrossCompartmentWrappers(JSTracer *trc); void fixupAfterMovingGC(); void fixupGlobal(); #endif diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 39b9626623b..4fda5b8a6a4 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -2344,32 +2344,27 @@ MovingTracer::Visit(JSTracer *jstrc, void **thingp, JSGCTraceKind kind) void GCRuntime::sweepZoneAfterCompacting(Zone *zone) { + MOZ_ASSERT(zone->isCollecting()); FreeOp *fop = rt->defaultFreeOp(); - if (zone->isCollecting()) { - zone->discardJitCode(fop); - zone->sweepAnalysis(fop, rt->gc.releaseObservedTypes && !zone->isPreservingCode()); - zone->sweepBreakpoints(fop); + zone->discardJitCode(fop); + zone->sweepAnalysis(fop, rt->gc.releaseObservedTypes && !zone->isPreservingCode()); + zone->sweepBreakpoints(fop); - for (CompartmentsInZoneIter c(zone); !c.done(); c.next()) { - c->sweepInnerViews(); - c->sweepCrossCompartmentWrappers(); - c->sweepBaseShapeTable(); - c->sweepInitialShapeTable(); - c->sweepTypeObjectTables(); - c->sweepRegExps(); - c->sweepCallsiteClones(); - c->sweepSavedStacks(); - c->sweepGlobalObject(fop); - c->sweepSelfHostingScriptSource(); - c->sweepDebugScopes(); - c->sweepJitCompartment(fop); - c->sweepWeakMaps(); - c->sweepNativeIterators(); - } - } else { - /* Update cross compartment wrappers into moved zones. */ - for (CompartmentsInZoneIter c(zone); !c.done(); c.next()) - c->sweepCrossCompartmentWrappers(); + for (CompartmentsInZoneIter c(zone); !c.done(); c.next()) { + c->sweepInnerViews(); + c->sweepCrossCompartmentWrappers(); + c->sweepBaseShapeTable(); + c->sweepInitialShapeTable(); + c->sweepTypeObjectTables(); + c->sweepRegExps(); + c->sweepCallsiteClones(); + c->sweepSavedStacks(); + c->sweepGlobalObject(fop); + c->sweepSelfHostingScriptSource(); + c->sweepDebugScopes(); + c->sweepJitCompartment(fop); + c->sweepWeakMaps(); + c->sweepNativeIterators(); } } @@ -2417,7 +2412,7 @@ GCRuntime::updatePointersToRelocatedCells() // Fixup cross compartment wrappers as we assert the existence of wrappers in the map. for (CompartmentsIter comp(rt, SkipAtoms); !comp.done(); comp.next()) - comp->fixupCrossCompartmentWrappers(&trc); + comp->sweepCrossCompartmentWrappers(); // Fixup generators as these are not normally traced. for (ContextIter i(rt); !i.done(); i.next()) { @@ -2458,9 +2453,10 @@ GCRuntime::updatePointersToRelocatedCells() // Sweep everything to fix up weak pointers WatchpointMap::sweepAll(rt); Debugger::sweepAll(rt->defaultFreeOp()); - - for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) - rt->gc.sweepZoneAfterCompacting(zone); + for (GCZonesIter zone(rt); !zone.done(); zone.next()) { + if (!rt->isAtomsZone(zone)) + rt->gc.sweepZoneAfterCompacting(zone); + } // Type inference may put more blocks here to free. rt->freeLifoAlloc.freeAll();