mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1105069 - Part 8: Remove implicit cast from GCCellPtr to js::gc::Cell*; r=jonco, r=mccr8
--HG-- extra : rebase_source : 0dfb2314f5d20770b7b92fa9fde23cb6c41f20d8
This commit is contained in:
parent
6eb606db7f
commit
1bb5471d19
@ -483,20 +483,20 @@ ExposeGCThingToActiveJS(JS::GCCellPtr thing)
|
||||
{
|
||||
MOZ_ASSERT(thing.kind() != JSTRACE_SHAPE);
|
||||
|
||||
JS::shadow::Runtime *rt = GetGCThingRuntime(thing);
|
||||
JS::shadow::Runtime *rt = GetGCThingRuntime(thing.asCell());
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
/*
|
||||
* GC things residing in the nursery cannot be gray: they have no mark bits.
|
||||
* All live objects in the nursery are moved to tenured at the beginning of
|
||||
* each GC slice, so the gray marker never sees nursery things.
|
||||
*/
|
||||
if (IsInsideNursery(thing))
|
||||
if (IsInsideNursery(thing.asCell()))
|
||||
return;
|
||||
#endif
|
||||
if (IsIncrementalBarrierNeededOnTenuredGCThing(rt, thing))
|
||||
JS::IncrementalReferenceBarrier(thing);
|
||||
else if (JS::GCThingIsMarkedGray(thing))
|
||||
JS::UnmarkGrayGCThingRecursively(thing, thing.kind());
|
||||
else if (JS::GCThingIsMarkedGray(thing.asCell()))
|
||||
JS::UnmarkGrayGCThingRecursively(thing.asCell(), thing.kind());
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE void
|
||||
@ -507,7 +507,7 @@ MarkGCThingAsLive(JSRuntime *aRt, JS::GCCellPtr thing)
|
||||
/*
|
||||
* Any object in the nursery will not be freed during any GC running at that time.
|
||||
*/
|
||||
if (IsInsideNursery(thing))
|
||||
if (IsInsideNursery(thing.asCell()))
|
||||
return;
|
||||
#endif
|
||||
if (IsIncrementalBarrierNeededOnTenuredGCThing(rt, thing))
|
||||
|
@ -211,6 +211,9 @@ struct Zone
|
||||
// to several kinds of GC thing.
|
||||
class JS_FRIEND_API(GCCellPtr)
|
||||
{
|
||||
typedef void (GCCellPtr::* ConvertibleToBool)();
|
||||
void nonNull() {}
|
||||
|
||||
public:
|
||||
// Construction from a void* and trace kind.
|
||||
GCCellPtr(void *gcthing, JSGCTraceKind traceKind) : ptr(checkedCast(gcthing, traceKind)) {}
|
||||
@ -233,9 +236,11 @@ class JS_FRIEND_API(GCCellPtr)
|
||||
return outOfLineKind();
|
||||
}
|
||||
|
||||
// Allow CellPtr to be used as a js::gc::Cell.
|
||||
operator js::gc::Cell *() const { return asCell(); }
|
||||
js::gc::Cell *operator->() const { return asCell(); }
|
||||
// Allow GCCellPtr to be used in a boolean context.
|
||||
operator ConvertibleToBool() const {
|
||||
MOZ_ASSERT(bool(asCell()) == (kind() != JSTRACE_NULL));
|
||||
return asCell() ? &GCCellPtr::nonNull : 0;
|
||||
}
|
||||
|
||||
// Simplify checks to the kind.
|
||||
bool isObject() const { return kind() == JSTRACE_OBJECT; }
|
||||
@ -261,6 +266,9 @@ class JS_FRIEND_API(GCCellPtr)
|
||||
MOZ_ASSERT(kind() == JSTRACE_SYMBOL);
|
||||
return reinterpret_cast<Symbol *>(asCell());
|
||||
}
|
||||
js::gc::Cell *asCell() const {
|
||||
return reinterpret_cast<js::gc::Cell *>(ptr & ~JSTRACE_OUTOFLINE);
|
||||
}
|
||||
|
||||
// The CC's trace logger needs an identity that is XPIDL serializable.
|
||||
void *unsafeGetUntypedPtr() const {
|
||||
@ -279,10 +287,6 @@ class JS_FRIEND_API(GCCellPtr)
|
||||
return uintptr_t(p) | (traceKind & JSTRACE_OUTOFLINE);
|
||||
}
|
||||
|
||||
js::gc::Cell *asCell() const {
|
||||
return reinterpret_cast<js::gc::Cell *>(ptr & ~JSTRACE_OUTOFLINE);
|
||||
}
|
||||
|
||||
JSGCTraceKind outOfLineKind() const;
|
||||
|
||||
uintptr_t ptr;
|
||||
@ -397,11 +401,11 @@ IsIncrementalBarrierNeededOnTenuredGCThing(JS::shadow::Runtime *rt, const JS::GC
|
||||
{
|
||||
MOZ_ASSERT(thing);
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
MOZ_ASSERT(!js::gc::IsInsideNursery(thing));
|
||||
MOZ_ASSERT(!js::gc::IsInsideNursery(thing.asCell()));
|
||||
#endif
|
||||
if (!rt->needsIncrementalBarrier())
|
||||
return false;
|
||||
JS::Zone *zone = JS::GetTenuredGCThingZone(thing);
|
||||
JS::Zone *zone = JS::GetTenuredGCThingZone(thing.asCell());
|
||||
return JS::shadow::Zone::asShadowZone(zone)->needsIncrementalBarrier();
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ BEGIN_TEST(testGCCellPtr)
|
||||
JS::GCCellPtr copy = objcell;
|
||||
CHECK(copy == objcell);
|
||||
|
||||
CHECK(js::gc::GetGCThingRuntime(scriptcell) == rt);
|
||||
CHECK(js::gc::GetGCThingRuntime(scriptcell.asCell()) == rt);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1189,26 +1189,25 @@ JS::IncrementalReferenceBarrier(GCCellPtr thing)
|
||||
#ifdef DEBUG
|
||||
Zone *zone = thing.isObject()
|
||||
? thing.toObject()->zone()
|
||||
: thing->asTenured().zone();
|
||||
: thing.asCell()->asTenured().zone();
|
||||
MOZ_ASSERT(!zone->runtimeFromMainThread()->isHeapMajorCollecting());
|
||||
#endif
|
||||
|
||||
gc::Cell *cell = static_cast<gc::Cell *>(thing);
|
||||
switch(thing.kind()) {
|
||||
case JSTRACE_OBJECT: return JSObject::writeBarrierPre(thing.toObject());
|
||||
case JSTRACE_STRING: return JSString::writeBarrierPre(thing.toString());
|
||||
case JSTRACE_SCRIPT: return JSScript::writeBarrierPre(thing.toScript());
|
||||
case JSTRACE_SYMBOL: return JS::Symbol::writeBarrierPre(thing.toSymbol());
|
||||
case JSTRACE_LAZY_SCRIPT:
|
||||
return LazyScript::writeBarrierPre(static_cast<LazyScript*>(cell));
|
||||
return LazyScript::writeBarrierPre(static_cast<LazyScript*>(thing.asCell()));
|
||||
case JSTRACE_JITCODE:
|
||||
return jit::JitCode::writeBarrierPre(static_cast<jit::JitCode*>(cell));
|
||||
return jit::JitCode::writeBarrierPre(static_cast<jit::JitCode*>(thing.asCell()));
|
||||
case JSTRACE_SHAPE:
|
||||
return Shape::writeBarrierPre(static_cast<Shape*>(cell));
|
||||
return Shape::writeBarrierPre(static_cast<Shape*>(thing.asCell()));
|
||||
case JSTRACE_BASE_SHAPE:
|
||||
return BaseShape::writeBarrierPre(static_cast<BaseShape*>(cell));
|
||||
return BaseShape::writeBarrierPre(static_cast<BaseShape*>(thing.asCell()));
|
||||
case JSTRACE_TYPE_OBJECT:
|
||||
return types::TypeObject::writeBarrierPre(static_cast<types::TypeObject *>(cell));
|
||||
return types::TypeObject::writeBarrierPre(static_cast<types::TypeObject *>(thing.asCell()));
|
||||
default:
|
||||
MOZ_CRASH("Invalid trace kind in IncrementalReferenceBarrier.");
|
||||
}
|
||||
|
@ -186,9 +186,9 @@ TraceWeakMapping(js::WeakMapTracer* aTrc, JSObject* aMap,
|
||||
NoteWeakMapsTracer* tracer = static_cast<NoteWeakMapsTracer*>(aTrc);
|
||||
|
||||
// If nothing that could be held alive by this entry is marked gray, return.
|
||||
if ((!aKey || !xpc_IsGrayGCThing(aKey)) &&
|
||||
if ((!aKey || !xpc_IsGrayGCThing(aKey.asCell())) &&
|
||||
MOZ_LIKELY(!tracer->mCb.WantAllTraces())) {
|
||||
if (!aValue || !xpc_IsGrayGCThing(aValue) || aValue.isString()) {
|
||||
if (!aValue || !xpc_IsGrayGCThing(aValue.asCell()) || aValue.isString()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -213,22 +213,22 @@ TraceWeakMapping(js::WeakMapTracer* aTrc, JSObject* aMap,
|
||||
}
|
||||
|
||||
if (AddToCCKind(aValue.kind())) {
|
||||
tracer->mCb.NoteWeakMapping(aMap, aKey, kdelegate, aValue);
|
||||
tracer->mCb.NoteWeakMapping(aMap, aKey.asCell(), kdelegate, aValue.asCell());
|
||||
} else {
|
||||
tracer->mChildTracer.mTracedAny = false;
|
||||
tracer->mChildTracer.mMap = aMap;
|
||||
tracer->mChildTracer.mKey = aKey;
|
||||
tracer->mChildTracer.mKey = aKey.asCell();
|
||||
tracer->mChildTracer.mKeyDelegate = kdelegate;
|
||||
|
||||
if (aValue.isString()) {
|
||||
JS_TraceChildren(&tracer->mChildTracer, aValue, aValue.kind());
|
||||
JS_TraceChildren(&tracer->mChildTracer, aValue.asCell(), aValue.kind());
|
||||
}
|
||||
|
||||
// The delegate could hold alive the key, so report something to the CC
|
||||
// if we haven't already.
|
||||
if (!tracer->mChildTracer.mTracedAny &&
|
||||
aKey && xpc_IsGrayGCThing(aKey) && kdelegate) {
|
||||
tracer->mCb.NoteWeakMapping(aMap, aKey, kdelegate, nullptr);
|
||||
aKey && xpc_IsGrayGCThing(aKey.asCell()) && kdelegate) {
|
||||
tracer->mCb.NoteWeakMapping(aMap, aKey.asCell(), kdelegate, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -260,8 +260,8 @@ private:
|
||||
static_cast<FixWeakMappingGrayBitsTracer*>(aTrc);
|
||||
|
||||
// If nothing that could be held alive by this entry is marked gray, return.
|
||||
bool delegateMightNeedMarking = aKey && xpc_IsGrayGCThing(aKey);
|
||||
bool valueMightNeedMarking = aValue && xpc_IsGrayGCThing(aValue) &&
|
||||
bool delegateMightNeedMarking = aKey && xpc_IsGrayGCThing(aKey.asCell());
|
||||
bool valueMightNeedMarking = aValue && xpc_IsGrayGCThing(aValue.asCell()) &&
|
||||
aValue.kind() != JSTRACE_STRING;
|
||||
if (!delegateMightNeedMarking && !valueMightNeedMarking) {
|
||||
return;
|
||||
@ -274,17 +274,17 @@ private:
|
||||
if (delegateMightNeedMarking && aKey.isObject()) {
|
||||
JSObject* kdelegate = js::GetWeakmapKeyDelegate(aKey.toObject());
|
||||
if (kdelegate && !xpc_IsGrayGCThing(kdelegate)) {
|
||||
if (JS::UnmarkGrayGCThingRecursively(aKey, JSTRACE_OBJECT)) {
|
||||
if (JS::UnmarkGrayGCThingRecursively(aKey.asCell(), JSTRACE_OBJECT)) {
|
||||
tracer->mAnyMarked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aValue && xpc_IsGrayGCThing(aValue) &&
|
||||
(!aKey || !xpc_IsGrayGCThing(aKey)) &&
|
||||
if (aValue && xpc_IsGrayGCThing(aValue.asCell()) &&
|
||||
(!aKey || !xpc_IsGrayGCThing(aKey.asCell())) &&
|
||||
(!aMap || !xpc_IsGrayGCThing(aMap)) &&
|
||||
aValue.kind() != JSTRACE_SHAPE) {
|
||||
if (JS::UnmarkGrayGCThingRecursively(aValue, aValue.kind())) {
|
||||
if (JS::UnmarkGrayGCThingRecursively(aValue.asCell(), aValue.kind())) {
|
||||
tracer->mAnyMarked = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user