mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 751618 - Zone renaming part 5 (r=jonco)
This commit is contained in:
parent
ada638a3a5
commit
a8af377c9a
@ -137,7 +137,7 @@ ComponentFinder<Node>::getResultsList()
|
||||
|
||||
template<class Node>
|
||||
/* static */ void
|
||||
ComponentFinder<Node>::mergeCompartmentGroups(Node *first)
|
||||
ComponentFinder<Node>::mergeGroups(Node *first)
|
||||
{
|
||||
for (Node *v = first; v; v = v->gcNextGraphNode)
|
||||
v->gcNextGraphComponent = NULL;
|
||||
|
@ -72,7 +72,7 @@ class ComponentFinder
|
||||
void addNode(Node *v);
|
||||
Node *getResultsList();
|
||||
|
||||
static void mergeCompartmentGroups(Node *first);
|
||||
static void mergeGroups(Node *first);
|
||||
|
||||
public:
|
||||
/* Call from implementation of GraphNodeBase::findOutgoingEdges(). */
|
||||
|
@ -475,7 +475,8 @@ struct JSCompartment : private JS::shadow::Zone, public js::gc::GraphNodeBase<JS
|
||||
void sweepCrossCompartmentWrappers();
|
||||
void purge();
|
||||
|
||||
void findOutgoingEdges(js::gc::ComponentFinder<JSCompartment> &finder);
|
||||
void findOutgoingEdgesFromCompartment(js::gc::ComponentFinder<JS::Zone> &finder);
|
||||
void findOutgoingEdges(js::gc::ComponentFinder<JS::Zone> &finder);
|
||||
|
||||
void setGCLastBytes(size_t lastBytes, js::JSGCInvocationKind gckind);
|
||||
void reduceGCTriggerBytes(size_t amount);
|
||||
|
@ -3170,15 +3170,8 @@ DropStringWrappers(JSRuntime *rt)
|
||||
*/
|
||||
|
||||
void
|
||||
JSCompartment::findOutgoingEdges(ComponentFinder<JSCompartment> &finder)
|
||||
JSCompartment::findOutgoingEdgesFromCompartment(ComponentFinder<JS::Zone> &finder)
|
||||
{
|
||||
/*
|
||||
* Any compartment may have a pointer to an atom in the atoms
|
||||
* compartment, and these aren't in the cross compartment map.
|
||||
*/
|
||||
if (rt->atomsCompartment->isGCMarking())
|
||||
finder.addEdgeTo(rt->atomsCompartment);
|
||||
|
||||
for (js::WrapperMap::Enum e(crossCompartmentWrappers); !e.empty(); e.popFront()) {
|
||||
CrossCompartmentKey::Kind kind = e.front().key.kind;
|
||||
JS_ASSERT(kind != CrossCompartmentKey::StringWrapper);
|
||||
@ -3190,7 +3183,7 @@ JSCompartment::findOutgoingEdges(ComponentFinder<JSCompartment> &finder)
|
||||
* after wrapped compartment.
|
||||
*/
|
||||
if (!other->isMarked(BLACK) || other->isMarked(GRAY)) {
|
||||
JSCompartment *w = other->compartment();
|
||||
JS::Zone *w = other->zone();
|
||||
if (w->isGCMarking())
|
||||
finder.addEdgeTo(w);
|
||||
}
|
||||
@ -3203,7 +3196,7 @@ JSCompartment::findOutgoingEdges(ComponentFinder<JSCompartment> &finder)
|
||||
* with call to Debugger::findCompartmentEdges below) that debugger
|
||||
* and debuggee objects are always swept in the same group.
|
||||
*/
|
||||
JSCompartment *w = other->compartment();
|
||||
JS::Zone *w = other->zone();
|
||||
if (w->isGCMarking())
|
||||
finder.addEdgeTo(w);
|
||||
}
|
||||
@ -3217,16 +3210,29 @@ JSCompartment::findOutgoingEdges(ComponentFinder<JSCompartment> &finder)
|
||||
Debugger::findCompartmentEdges(this, finder);
|
||||
}
|
||||
|
||||
static void
|
||||
FindCompartmentGroups(JSRuntime *rt)
|
||||
void
|
||||
JSCompartment::findOutgoingEdges(ComponentFinder<JS::Zone> &finder)
|
||||
{
|
||||
ComponentFinder<JSCompartment> finder(rt->mainThread.nativeStackLimit);
|
||||
/*
|
||||
* Any compartment may have a pointer to an atom in the atoms
|
||||
* compartment, and these aren't in the cross compartment map.
|
||||
*/
|
||||
if (rt->atomsCompartment->isGCMarking())
|
||||
finder.addEdgeTo(rt->atomsCompartment);
|
||||
|
||||
findOutgoingEdgesFromCompartment(finder);
|
||||
}
|
||||
|
||||
static void
|
||||
FindZoneGroups(JSRuntime *rt)
|
||||
{
|
||||
ComponentFinder<Zone> finder(rt->mainThread.nativeStackLimit);
|
||||
if (!rt->gcIsIncremental)
|
||||
finder.useOneComponent();
|
||||
|
||||
for (GCCompartmentsIter c(rt); !c.done(); c.next()) {
|
||||
JS_ASSERT(c->isGCMarking());
|
||||
finder.addNode(c);
|
||||
for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
|
||||
JS_ASSERT(zone->isGCMarking());
|
||||
finder.addNode(zone);
|
||||
}
|
||||
rt->gcZoneGroups = finder.getResultsList();
|
||||
rt->gcCurrentZoneGroup = rt->gcZoneGroups;
|
||||
@ -3237,24 +3243,27 @@ static void
|
||||
ResetGrayList(JSCompartment* comp);
|
||||
|
||||
static void
|
||||
GetNextCompartmentGroup(JSRuntime *rt)
|
||||
GetNextZoneGroup(JSRuntime *rt)
|
||||
{
|
||||
rt->gcCurrentZoneGroup = rt->gcCurrentZoneGroup->nextGroup();
|
||||
++rt->gcZoneGroupIndex;
|
||||
|
||||
if (!rt->gcIsIncremental)
|
||||
ComponentFinder<JSCompartment>::mergeCompartmentGroups(rt->gcCurrentZoneGroup);
|
||||
ComponentFinder<Zone>::mergeGroups(rt->gcCurrentZoneGroup);
|
||||
|
||||
if (rt->gcAbortSweepAfterCurrentGroup) {
|
||||
JS_ASSERT(!rt->gcIsIncremental);
|
||||
for (GCCompartmentGroupIter c(rt); !c.done(); c.next()) {
|
||||
JS_ASSERT(!c->gcNextGraphComponent);
|
||||
JS_ASSERT(c->isGCMarking());
|
||||
c->setNeedsBarrier(false, JSCompartment::UpdateIon);
|
||||
c->setGCState(JSCompartment::NoGC);
|
||||
ArrayBufferObject::resetArrayBufferList(c);
|
||||
ResetGrayList(c);
|
||||
c->gcGrayRoots.clearAndFree();
|
||||
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
JS_ASSERT(!zone->gcNextGraphComponent);
|
||||
JS_ASSERT(zone->isGCMarking());
|
||||
zone->setNeedsBarrier(false, JSCompartment::UpdateIon);
|
||||
zone->setGCState(JSCompartment::NoGC);
|
||||
}
|
||||
|
||||
for (GCCompartmentGroupIter comp(rt); !comp.done(); comp.next()) {
|
||||
ArrayBufferObject::resetArrayBufferList(comp);
|
||||
ResetGrayList(comp);
|
||||
comp->gcGrayRoots.clearAndFree();
|
||||
}
|
||||
|
||||
rt->gcAbortSweepAfterCurrentGroup = false;
|
||||
@ -3500,7 +3509,7 @@ js::NotifyGCPostSwap(RawObject a, RawObject b, unsigned removedFlags)
|
||||
}
|
||||
|
||||
static void
|
||||
EndMarkingCompartmentGroup(JSRuntime *rt)
|
||||
EndMarkingZoneGroup(JSRuntime *rt)
|
||||
{
|
||||
/*
|
||||
* Mark any incoming black pointers from previously swept compartments
|
||||
@ -3540,10 +3549,10 @@ EndMarkingCompartmentGroup(JSRuntime *rt)
|
||||
}
|
||||
|
||||
static void
|
||||
BeginSweepingCompartmentGroup(JSRuntime *rt)
|
||||
BeginSweepingZoneGroup(JSRuntime *rt)
|
||||
{
|
||||
/*
|
||||
* Begin sweeping the group of compartments in gcCurrentCompartmentGroup,
|
||||
* Begin sweeping the group of zones in gcCurrentZoneGroup,
|
||||
* performing actions that must be done before yielding to caller.
|
||||
*/
|
||||
|
||||
@ -3638,7 +3647,7 @@ BeginSweepingCompartmentGroup(JSRuntime *rt)
|
||||
}
|
||||
|
||||
static void
|
||||
EndSweepingCompartmentGroup(JSRuntime *rt)
|
||||
EndSweepingZoneGroup(JSRuntime *rt)
|
||||
{
|
||||
/* Update the GC state for compartments we have swept and unlink the list. */
|
||||
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
@ -3685,9 +3694,9 @@ BeginSweepPhase(JSRuntime *rt)
|
||||
#endif
|
||||
|
||||
DropStringWrappers(rt);
|
||||
FindCompartmentGroups(rt);
|
||||
EndMarkingCompartmentGroup(rt);
|
||||
BeginSweepingCompartmentGroup(rt);
|
||||
FindZoneGroups(rt);
|
||||
EndMarkingZoneGroup(rt);
|
||||
BeginSweepingZoneGroup(rt);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -3738,12 +3747,12 @@ SweepPhase(JSRuntime *rt, SliceBudget &sliceBudget)
|
||||
rt->gcSweepZone = rt->gcCurrentZoneGroup;
|
||||
}
|
||||
|
||||
EndSweepingCompartmentGroup(rt);
|
||||
GetNextCompartmentGroup(rt);
|
||||
EndSweepingZoneGroup(rt);
|
||||
GetNextZoneGroup(rt);
|
||||
if (!rt->gcCurrentZoneGroup)
|
||||
return true; /* We're finished. */
|
||||
EndMarkingCompartmentGroup(rt);
|
||||
BeginSweepingCompartmentGroup(rt);
|
||||
EndMarkingZoneGroup(rt);
|
||||
BeginSweepingZoneGroup(rt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3998,7 +4007,7 @@ ResetIncrementalGC(JSRuntime *rt, const char *reason)
|
||||
for (CompartmentsIter c(rt); !c.done(); c.next())
|
||||
c->scheduledForDestruction = false;
|
||||
|
||||
/* Finish sweeping the current compartment group, then abort. */
|
||||
/* Finish sweeping the current zone group, then abort. */
|
||||
rt->gcAbortSweepAfterCurrentGroup = true;
|
||||
IncrementalCollectSlice(rt, SliceBudget::Unlimited, gcreason::RESET, GC_NORMAL);
|
||||
|
||||
|
@ -1581,7 +1581,7 @@ Debugger::detachAllDebuggersFromGlobal(FreeOp *fop, GlobalObject *global,
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
Debugger::findCompartmentEdges(JSCompartment *comp, js::gc::ComponentFinder<JSCompartment> &finder)
|
||||
Debugger::findCompartmentEdges(Zone *zone, js::gc::ComponentFinder<Zone> &finder)
|
||||
{
|
||||
/*
|
||||
* For debugger cross compartment wrappers, add edges in the opposite
|
||||
@ -1589,13 +1589,13 @@ Debugger::findCompartmentEdges(JSCompartment *comp, js::gc::ComponentFinder<JSCo
|
||||
* This ensure that debuggers and their debuggees are finalized in the same
|
||||
* group.
|
||||
*/
|
||||
for (Debugger *dbg = comp->rt->debuggerList.getFirst(); dbg; dbg = dbg->getNext()) {
|
||||
JSCompartment *w = dbg->object->compartment();
|
||||
if (w == comp || !w->isGCMarking())
|
||||
for (Debugger *dbg = zone->rt->debuggerList.getFirst(); dbg; dbg = dbg->getNext()) {
|
||||
Zone *w = dbg->object->zone();
|
||||
if (w == zone || !w->isGCMarking())
|
||||
continue;
|
||||
if (dbg->scripts.hasKeyInCompartment(comp) ||
|
||||
dbg->objects.hasKeyInCompartment(comp) ||
|
||||
dbg->environments.hasKeyInCompartment(comp))
|
||||
if (dbg->scripts.hasKeyInZone(zone) ||
|
||||
dbg->objects.hasKeyInZone(zone) ||
|
||||
dbg->environments.hasKeyInZone(zone))
|
||||
{
|
||||
finder.addEdgeTo(w);
|
||||
}
|
||||
|
@ -46,17 +46,17 @@ template <class Key, class Value>
|
||||
class DebuggerWeakMap : private WeakMap<Key, Value, DefaultHasher<Key> >
|
||||
{
|
||||
private:
|
||||
typedef HashMap<JSCompartment *,
|
||||
typedef HashMap<JS::Zone *,
|
||||
uintptr_t,
|
||||
DefaultHasher<JSCompartment *>,
|
||||
DefaultHasher<JS::Zone *>,
|
||||
RuntimeAllocPolicy> CountMap;
|
||||
|
||||
CountMap compartmentCounts;
|
||||
CountMap zoneCounts;
|
||||
|
||||
public:
|
||||
typedef WeakMap<Key, Value, DefaultHasher<Key> > Base;
|
||||
explicit DebuggerWeakMap(JSContext *cx)
|
||||
: Base(cx), compartmentCounts(cx) { }
|
||||
: Base(cx), zoneCounts(cx) { }
|
||||
|
||||
public:
|
||||
/* Expose those parts of HashMap public interface that are used by Debugger methods. */
|
||||
@ -68,7 +68,7 @@ class DebuggerWeakMap : private WeakMap<Key, Value, DefaultHasher<Key> >
|
||||
typedef typename Base::Lookup Lookup;
|
||||
|
||||
bool init(uint32_t len = 16) {
|
||||
return Base::init(len) && compartmentCounts.init();
|
||||
return Base::init(len) && zoneCounts.init();
|
||||
}
|
||||
|
||||
AddPtr lookupForAdd(const Lookup &l) const {
|
||||
@ -78,11 +78,11 @@ class DebuggerWeakMap : private WeakMap<Key, Value, DefaultHasher<Key> >
|
||||
template<typename KeyInput, typename ValueInput>
|
||||
bool relookupOrAdd(AddPtr &p, const KeyInput &k, const ValueInput &v) {
|
||||
JS_ASSERT(v->compartment() == Base::compartment);
|
||||
if (!incCompartmentCount(k->compartment()))
|
||||
if (!incZoneCount(k->zone()))
|
||||
return false;
|
||||
bool ok = Base::relookupOrAdd(p, k, v);
|
||||
if (!ok)
|
||||
decCompartmentCount(k->compartment());
|
||||
decZoneCount(k->zone());
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ class DebuggerWeakMap : private WeakMap<Key, Value, DefaultHasher<Key> >
|
||||
|
||||
void remove(const Lookup &l) {
|
||||
Base::remove(l);
|
||||
decCompartmentCount(l->compartment());
|
||||
decZoneCount(l->zone());
|
||||
}
|
||||
|
||||
public:
|
||||
@ -110,8 +110,8 @@ class DebuggerWeakMap : private WeakMap<Key, Value, DefaultHasher<Key> >
|
||||
}
|
||||
}
|
||||
|
||||
bool hasKeyInCompartment(JSCompartment *c) {
|
||||
CountMap::Ptr p = compartmentCounts.lookup(c);
|
||||
bool hasKeyInZone(JS::Zone *zone) {
|
||||
CountMap::Ptr p = zoneCounts.lookup(zone);
|
||||
JS_ASSERT_IF(p, p->value > 0);
|
||||
return p;
|
||||
}
|
||||
@ -124,27 +124,27 @@ class DebuggerWeakMap : private WeakMap<Key, Value, DefaultHasher<Key> >
|
||||
Value v(e.front().value);
|
||||
if (gc::IsAboutToBeFinalized(&k)) {
|
||||
e.removeFront();
|
||||
decCompartmentCount(k->compartment());
|
||||
decZoneCount(k->zone());
|
||||
}
|
||||
}
|
||||
Base::assertEntriesNotAboutToBeFinalized();
|
||||
}
|
||||
|
||||
bool incCompartmentCount(JSCompartment *c) {
|
||||
CountMap::Ptr p = compartmentCounts.lookupWithDefault(c, 0);
|
||||
bool incZoneCount(JS::Zone *zone) {
|
||||
CountMap::Ptr p = zoneCounts.lookupWithDefault(zone, 0);
|
||||
if (!p)
|
||||
return false;
|
||||
++p->value;
|
||||
return true;
|
||||
}
|
||||
|
||||
void decCompartmentCount(JSCompartment *c) {
|
||||
CountMap::Ptr p = compartmentCounts.lookup(c);
|
||||
void decZoneCount(JS::Zone *zone) {
|
||||
CountMap::Ptr p = zoneCounts.lookup(zone);
|
||||
JS_ASSERT(p);
|
||||
JS_ASSERT(p->value > 0);
|
||||
--p->value;
|
||||
if (p->value == 0)
|
||||
compartmentCounts.remove(c);
|
||||
zoneCounts.remove(zone);
|
||||
}
|
||||
};
|
||||
|
||||
@ -385,7 +385,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
|
||||
GlobalObjectSet::Enum *compartmentEnum);
|
||||
static unsigned gcGrayLinkSlot();
|
||||
static bool isDebugWrapper(RawObject o);
|
||||
static void findCompartmentEdges(JSCompartment *v, gc::ComponentFinder<JSCompartment> &finder);
|
||||
static void findCompartmentEdges(JS::Zone *v, gc::ComponentFinder<JS::Zone> &finder);
|
||||
|
||||
static inline JSTrapStatus onEnterFrame(JSContext *cx, Value *vp);
|
||||
static inline bool onLeaveFrame(JSContext *cx, bool ok);
|
||||
|
Loading…
Reference in New Issue
Block a user