Bug 1615143 - Eliminate TraceKind::LazyScript. r=jonco

Now that JSScript and LazyScript share a trace method, we can use a single
TraceKind within the GC. To acheive this we also must remove eager marking of
LazyScripts.

Differential Revision: https://phabricator.services.mozilla.com/D62681

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ted Campbell 2020-02-13 14:33:33 +00:00
Родитель 432b2a7b18
Коммит 211e335615
24 изменённых файлов: 69 добавлений и 206 удалений

Просмотреть файл

@ -310,6 +310,8 @@ class JS_FRIEND_API GCCellPtr {
: ptr(checkedCast(p, JS::MapTypeToTraceKind<T>::kind)) {}
explicit GCCellPtr(JSFunction* p)
: ptr(checkedCast(p, JS::TraceKind::Object)) {}
explicit GCCellPtr(JSScript* p)
: ptr(checkedCast(p, JS::TraceKind::Script)) {}
explicit GCCellPtr(const Value& v);
JS::TraceKind kind() const {

Просмотреть файл

@ -538,7 +538,6 @@ struct UnusedGCThingSizes {
#define FOR_EACH_SIZE(MACRO) \
MACRO(Other, GCHeapUnused, object) \
MACRO(Other, GCHeapUnused, script) \
MACRO(Other, GCHeapUnused, lazyScript) \
MACRO(Other, GCHeapUnused, shape) \
MACRO(Other, GCHeapUnused, baseShape) \
MACRO(Other, GCHeapUnused, objectGroup) \
@ -578,9 +577,6 @@ struct UnusedGCThingSizes {
case JS::TraceKind::JitCode:
jitcode += n;
break;
case JS::TraceKind::LazyScript:
lazyScript += n;
break;
case JS::TraceKind::ObjectGroup:
objectGroup += n;
break;
@ -624,8 +620,6 @@ struct ZoneStats {
MACRO(Other, GCHeapUsed, bigIntsGCHeap) \
MACRO(Other, MallocHeap, bigIntsMallocHeap) \
MACRO(Other, GCHeapAdmin, gcHeapArenaAdmin) \
MACRO(Other, GCHeapUsed, lazyScriptsGCHeap) \
MACRO(Other, MallocHeap, lazyScriptsMallocHeap) \
MACRO(Other, GCHeapUsed, jitCodesGCHeap) \
MACRO(Other, GCHeapUsed, objectGroupsGCHeap) \
MACRO(Other, MallocHeap, objectGroupsMallocHeap) \

Просмотреть файл

@ -13,8 +13,8 @@
// Forward declarations of all the types a TraceKind can denote.
namespace js {
class BaseScript;
class BaseShape;
class LazyScript;
class ObjectGroup;
class RegExpShared;
class Shape;
@ -58,9 +58,8 @@ enum class TraceKind {
BaseShape = 0x0F,
JitCode = 0x1F,
Script = 0x2F,
LazyScript = 0x3F,
Scope = 0x4F,
RegExpShared = 0x5F
Scope = 0x3F,
RegExpShared = 0x4F
};
const static uintptr_t OutOfLineTraceKindMask = 0x07;
@ -70,7 +69,7 @@ const static uintptr_t OutOfLineTraceKindMask = 0x07;
"mask bits are set")
ASSERT_TRACE_KIND(JS::TraceKind::BaseShape);
ASSERT_TRACE_KIND(JS::TraceKind::JitCode);
ASSERT_TRACE_KIND(JS::TraceKind::LazyScript);
ASSERT_TRACE_KIND(JS::TraceKind::Script);
ASSERT_TRACE_KIND(JS::TraceKind::Scope);
ASSERT_TRACE_KIND(JS::TraceKind::RegExpShared);
#undef ASSERT_TRACE_KIND
@ -96,11 +95,10 @@ struct MapTypeToTraceKind {
/* name type canBeGray inCCGraph */ \
D(BaseShape, js::BaseShape, true, false) \
D(JitCode, js::jit::JitCode, true, false) \
D(LazyScript, js::LazyScript, true, true) \
D(Scope, js::Scope, true, true) \
D(Object, JSObject, true, true) \
D(ObjectGroup, js::ObjectGroup, true, false) \
D(Script, JSScript, true, true) \
D(Script, js::BaseScript, true, true) \
D(Shape, js::Shape, true, false) \
D(String, JSString, false, false) \
D(Symbol, JS::Symbol, false, false) \
@ -192,6 +190,8 @@ struct MapTypeToRootKind<jsid> {
};
template <>
struct MapTypeToRootKind<JSFunction*> : public MapTypeToRootKind<JSObject*> {};
template <>
struct MapTypeToRootKind<JSScript*> : public MapTypeToRootKind<js::BaseScript*> {};
// Fortunately, few places in the system need to deal with fully abstract
// cells. In those places that do, we generally want to move to a layout
@ -209,8 +209,8 @@ struct MapTypeToRootKind<JSFunction*> : public MapTypeToRootKind<JSObject*> {};
template <typename F, typename... Args>
auto DispatchTraceKindTyped(F f, JS::TraceKind traceKind, Args&&... args) {
switch (traceKind) {
#define JS_EXPAND_DEF(name, type, _, _1) \
case JS::TraceKind::name: \
#define JS_EXPAND_DEF(name, type, _, _1) \
case JS::TraceKind::name: \
return f.template operator()<type>(std::forward<Args>(args)...);
JS_FOR_EACH_TRACEKIND(JS_EXPAND_DEF);
#undef JS_EXPAND_DEF

Просмотреть файл

@ -162,7 +162,7 @@ class JS_PUBLIC_API CallbackTracer : public JSTracer {
virtual bool onBigIntEdge(JS::BigInt** bip) {
return onChild(JS::GCCellPtr(*bip));
}
virtual bool onScriptEdge(JSScript** scriptp) {
virtual bool onScriptEdge(js::BaseScript** scriptp) {
return onChild(JS::GCCellPtr(*scriptp));
}
virtual bool onShapeEdge(js::Shape** shapep) {
@ -177,9 +177,6 @@ class JS_PUBLIC_API CallbackTracer : public JSTracer {
virtual bool onJitCodeEdge(js::jit::JitCode** codep) {
return onChild(JS::GCCellPtr(*codep, JS::TraceKind::JitCode));
}
virtual bool onLazyScriptEdge(js::LazyScript** lazyp) {
return onChild(JS::GCCellPtr(*lazyp, JS::TraceKind::LazyScript));
}
virtual bool onScopeEdge(js::Scope** scopep) {
return onChild(JS::GCCellPtr(*scopep, JS::TraceKind::Scope));
}
@ -263,7 +260,9 @@ class JS_PUBLIC_API CallbackTracer : public JSTracer {
bool dispatchToOnEdge(JSString** strp) { return onStringEdge(strp); }
bool dispatchToOnEdge(JS::Symbol** symp) { return onSymbolEdge(symp); }
bool dispatchToOnEdge(JS::BigInt** bip) { return onBigIntEdge(bip); }
bool dispatchToOnEdge(JSScript** scriptp) { return onScriptEdge(scriptp); }
bool dispatchToOnEdge(js::BaseScript** scriptp) {
return onScriptEdge(scriptp);
}
bool dispatchToOnEdge(js::Shape** shapep) { return onShapeEdge(shapep); }
bool dispatchToOnEdge(js::ObjectGroup** groupp) {
return onObjectGroupEdge(groupp);
@ -274,9 +273,6 @@ class JS_PUBLIC_API CallbackTracer : public JSTracer {
bool dispatchToOnEdge(js::jit::JitCode** codep) {
return onJitCodeEdge(codep);
}
bool dispatchToOnEdge(js::LazyScript** lazyp) {
return onLazyScriptEdge(lazyp);
}
bool dispatchToOnEdge(js::Scope** scopep) { return onScopeEdge(scopep); }
bool dispatchToOnEdge(js::RegExpShared** sharedp) {
return onRegExpSharedEdge(sharedp);

Просмотреть файл

@ -174,6 +174,10 @@ class StackFrame;
} // namespace ubi
} // namespace JS
namespace js {
class BaseScript;
} // namespace js
namespace JS {
namespace ubi {
@ -1107,12 +1111,14 @@ class JS_PUBLIC_API Concrete<JS::BigInt> : TracerConcrete<JS::BigInt> {
};
template <>
class JS_PUBLIC_API Concrete<JSScript> : TracerConcreteWithRealm<JSScript> {
class JS_PUBLIC_API Concrete<js::BaseScript>
: TracerConcreteWithRealm<js::BaseScript> {
protected:
explicit Concrete(JSScript* ptr) : TracerConcreteWithRealm<JSScript>(ptr) {}
explicit Concrete(js::BaseScript* ptr)
: TracerConcreteWithRealm<js::BaseScript>(ptr) {}
public:
static void construct(void* storage, JSScript* ptr) {
static void construct(void* storage, js::BaseScript* ptr) {
new (storage) Concrete(ptr);
}

Просмотреть файл

@ -29,12 +29,12 @@ js::gc::Cell* js::DebuggerScript::getReferentCell() const {
js::DebuggerScriptReferent js::DebuggerScript::getReferent() const {
if (gc::Cell* cell = getReferentCell()) {
if (cell->is<JSScript>()) {
if (cell->is<BaseScript>()) {
if (cell->as<BaseScript>()->isLazyScript()) {
return mozilla::AsVariant(cell->as<LazyScript>());
}
return mozilla::AsVariant(cell->as<JSScript>());
}
if (cell->is<LazyScript>()) {
return mozilla::AsVariant(cell->as<LazyScript>());
}
MOZ_ASSERT(cell->is<JSObject>());
return mozilla::AsVariant(
&static_cast<NativeObject*>(cell)->as<WasmInstanceObject>());
@ -44,9 +44,7 @@ js::DebuggerScriptReferent js::DebuggerScript::getReferent() const {
js::BaseScript* js::DebuggerScript::getReferentScript() const {
gc::Cell* cell = getReferentCell();
MOZ_ASSERT(cell->is<JSScript>() || cell->is<LazyScript>());
return static_cast<js::BaseScript*>(cell);
return cell->as<BaseScript>();
}
#endif /* debugger_Script_inl_h */

Просмотреть файл

@ -80,16 +80,11 @@ void DebuggerScript::trace(JSTracer* trc) {
// This comes from a private pointer, so no barrier needed.
gc::Cell* cell = getReferentCell();
if (cell) {
if (cell->is<JSScript>()) {
JSScript* script = cell->as<JSScript>();
if (cell->is<BaseScript>()) {
BaseScript* script = cell->as<BaseScript>();
TraceManuallyBarrieredCrossCompartmentEdge(
trc, upcast, &script, "Debugger.Script script referent");
setPrivateUnbarriered(script);
} else if (cell->is<LazyScript>()) {
LazyScript* lazyScript = cell->as<LazyScript>();
TraceManuallyBarrieredCrossCompartmentEdge(
trc, upcast, &lazyScript, "Debugger.Script lazy script referent");
setPrivateUnbarriered(lazyScript);
} else {
JSObject* wasm = cell->as<JSObject>();
TraceManuallyBarrieredCrossCompartmentEdge(

Просмотреть файл

@ -61,7 +61,7 @@ namespace gc {
#define FOR_EACH_NONOBJECT_NONNURSERY_ALLOCKIND(D) \
/* AllocKind TraceKind TypeName SizedType BGFinal Nursery Compact */ \
D(SCRIPT, Script, JSScript, JSScript, false, false, true) \
D(LAZY_SCRIPT, LazyScript, js::LazyScript, js::LazyScript, true, false, true) \
D(LAZY_SCRIPT, Script, js::LazyScript, js::LazyScript, true, false, true) \
D(SHAPE, Shape, js::Shape, js::Shape, true, false, true) \
D(ACCESSOR_SHAPE, Shape, js::AccessorShape, js::AccessorShape, true, false, true) \
D(BASE_SHAPE, BaseShape, js::BaseShape, js::BaseShape, true, false, true) \

Просмотреть файл

@ -27,12 +27,11 @@ struct ClearEdgesTracer final : public JS::CallbackTracer {
bool onStringEdge(JSString** strp) override;
bool onSymbolEdge(JS::Symbol** symp) override;
bool onBigIntEdge(JS::BigInt** bip) override;
bool onScriptEdge(JSScript** scriptp) override;
bool onScriptEdge(js::BaseScript** scriptp) override;
bool onShapeEdge(js::Shape** shapep) override;
bool onObjectGroupEdge(js::ObjectGroup** groupp) override;
bool onBaseShapeEdge(js::BaseShape** basep) override;
bool onJitCodeEdge(js::jit::JitCode** codep) override;
bool onLazyScriptEdge(js::LazyScript** lazyp) override;
bool onScopeEdge(js::Scope** scopep) override;
bool onRegExpSharedEdge(js::RegExpShared** sharedp) override;
bool onChild(const JS::GCCellPtr& thing) override;

Просмотреть файл

@ -2085,12 +2085,9 @@ bool MovingTracer::onShapeEdge(Shape** shapep) { return updateEdge(shapep); }
bool MovingTracer::onStringEdge(JSString** stringp) {
return updateEdge(stringp);
}
bool MovingTracer::onScriptEdge(JSScript** scriptp) {
bool MovingTracer::onScriptEdge(js::BaseScript** scriptp) {
return updateEdge(scriptp);
}
bool MovingTracer::onLazyScriptEdge(LazyScript** lazyp) {
return updateEdge(lazyp);
}
bool MovingTracer::onBaseShapeEdge(BaseShape** basep) {
return updateEdge(basep);
}
@ -8649,7 +8646,7 @@ bool js::gc::ClearEdgesTracer::onSymbolEdge(JS::Symbol** symp) {
bool js::gc::ClearEdgesTracer::onBigIntEdge(JS::BigInt** bip) {
return clearEdge(bip);
}
bool js::gc::ClearEdgesTracer::onScriptEdge(JSScript** scriptp) {
bool js::gc::ClearEdgesTracer::onScriptEdge(js::BaseScript** scriptp) {
return clearEdge(scriptp);
}
bool js::gc::ClearEdgesTracer::onShapeEdge(js::Shape** shapep) {
@ -8664,9 +8661,6 @@ bool js::gc::ClearEdgesTracer::onBaseShapeEdge(js::BaseShape** basep) {
bool js::gc::ClearEdgesTracer::onJitCodeEdge(js::jit::JitCode** codep) {
return clearEdge(codep);
}
bool js::gc::ClearEdgesTracer::onLazyScriptEdge(js::LazyScript** lazyp) {
return clearEdge(lazyp);
}
bool js::gc::ClearEdgesTracer::onScopeEdge(js::Scope** scopep) {
return clearEdge(scopep);
}

Просмотреть файл

@ -26,6 +26,7 @@ namespace js {
class AccessorShape;
class FatInlineAtom;
class NormalAtom;
class LazyScript;
class Nursery;

Просмотреть файл

@ -220,8 +220,7 @@ struct MovingTracer final : public JS::CallbackTracer {
bool onObjectEdge(JSObject** objp) override;
bool onShapeEdge(Shape** shapep) override;
bool onStringEdge(JSString** stringp) override;
bool onScriptEdge(JSScript** scriptp) override;
bool onLazyScriptEdge(LazyScript** lazyp) override;
bool onScriptEdge(js::BaseScript** scriptp) override;
bool onBaseShapeEdge(BaseShape** basep) override;
bool onScopeEdge(Scope** scopep) override;
bool onRegExpSharedEdge(RegExpShared** sharedp) override;
@ -247,8 +246,7 @@ struct SweepingTracer final : public JS::CallbackTracer {
bool onObjectEdge(JSObject** objp) override;
bool onShapeEdge(Shape** shapep) override;
bool onStringEdge(JSString** stringp) override;
bool onScriptEdge(JSScript** scriptp) override;
bool onLazyScriptEdge(LazyScript** lazyp) override;
bool onScriptEdge(js::BaseScript** scriptp) override;
bool onBaseShapeEdge(BaseShape** basep) override;
bool onJitCodeEdge(jit::JitCode** jitp) override;
bool onScopeEdge(Scope** scopep) override;

Просмотреть файл

@ -382,7 +382,6 @@ class GCMarker : public JSTracer {
void eagerlyMarkChildren(JSLinearString* str);
void eagerlyMarkChildren(JSRope* rope);
void eagerlyMarkChildren(JSString* str);
void eagerlyMarkChildren(LazyScript* thing);
void eagerlyMarkChildren(Shape* shape);
void eagerlyMarkChildren(Scope* scope);
void lazilyMarkChildren(ObjectGroup* group);

Просмотреть файл

@ -67,8 +67,7 @@ struct MightBeForwarded {
std::is_base_of<BaseShape, T>::value ||
std::is_base_of<JSString, T>::value ||
std::is_base_of<JS::BigInt, T>::value ||
std::is_base_of<JSScript, T>::value ||
std::is_base_of<js::LazyScript, T>::value ||
std::is_base_of<js::BaseScript, T>::value ||
std::is_base_of<js::Scope, T>::value ||
std::is_base_of<js::RegExpShared, T>::value;
};

Просмотреть файл

@ -581,10 +581,8 @@ template void js::TraceManuallyBarrieredCrossCompartmentEdge<Value>(
JSTracer*, JSObject*, Value*, const char*);
template void js::TraceManuallyBarrieredCrossCompartmentEdge<JSObject*>(
JSTracer*, JSObject*, JSObject**, const char*);
template void js::TraceManuallyBarrieredCrossCompartmentEdge<JSScript*>(
JSTracer*, JSObject*, JSScript**, const char*);
template void js::TraceManuallyBarrieredCrossCompartmentEdge<LazyScript*>(
JSTracer*, JSObject*, LazyScript**, const char*);
template void js::TraceManuallyBarrieredCrossCompartmentEdge<BaseScript*>(
JSTracer*, JSObject*, BaseScript**, const char*);
template <typename T>
void js::TraceWeakMapKeyEdgeInternal(JSTracer* trc, Zone* weakMapZone,
@ -610,11 +608,8 @@ void js::TraceWeakMapKeyEdgeInternal(JSTracer* trc, Zone* weakMapZone,
template void js::TraceWeakMapKeyEdgeInternal<JSObject>(JSTracer*, Zone*,
JSObject**,
const char*);
template void js::TraceWeakMapKeyEdgeInternal<JSScript>(JSTracer*, Zone*,
JSScript**,
const char*);
template void js::TraceWeakMapKeyEdgeInternal<LazyScript>(JSTracer*, Zone*,
LazyScript**,
template void js::TraceWeakMapKeyEdgeInternal<BaseScript>(JSTracer*, Zone*,
BaseScript**,
const char*);
template <typename T>
@ -943,9 +938,9 @@ void GCMarker::traverse(RegExpShared* thing) {
}
} // namespace js
// Strings, LazyScripts, Shapes, and Scopes are extremely common, but have
// simple patterns of recursion. We traverse trees of these edges immediately,
// with aggressive, manual inlining, implemented by eagerlyTraceChildren.
// Strings, Shapes, and Scopes are extremely common, but have simple patterns of
// recursion. We traverse trees of these edges immediately, with aggressive,
// manual inlining, implemented by eagerlyTraceChildren.
template <typename T>
void js::GCMarker::markAndScan(T* thing) {
if (ThingIsPermanentAtomOrWellKnownSymbol(thing)) {
@ -961,10 +956,6 @@ void GCMarker::traverse(JSString* thing) {
markAndScan(thing);
}
template <>
void GCMarker::traverse(LazyScript* thing) {
markAndScan(thing);
}
template <>
void GCMarker::traverse(Shape* thing) {
markAndScan(thing);
}
@ -1000,7 +991,7 @@ void GCMarker::traverse(jit::JitCode* thing) {
markAndPush(thing);
}
template <>
void GCMarker::traverse(JSScript* thing) {
void GCMarker::traverse(BaseScript* thing) {
markAndPush(thing);
}
} // namespace js
@ -1147,33 +1138,6 @@ void BaseScript::traceChildren(JSTracer* trc) {
}
}
inline void js::GCMarker::eagerlyMarkChildren(LazyScript* thing) {
traverseEdge(thing, static_cast<JSObject*>(thing->functionOrGlobal_));
traverseEdge(thing, static_cast<JSObject*>(thing->sourceObject_));
thing->warmUpData_.trace(this);
if (thing->data_) {
// Traverse the PrivateScriptData::gcthings() array.
for (JS::GCCellPtr& elem : thing->data_->gcthings()) {
if (elem.is<JSObject>()) {
traverseEdge(thing, &elem.as<JSObject>());
} else if (elem.is<JSString>()) {
traverseEdge(thing, &elem.as<JSString>());
} else {
MOZ_ASSERT(!elem);
}
}
}
MOZ_ASSERT(thing->sharedData_ == nullptr,
"LazyScript should not have shared data.");
// script_ is weak so is not traced here.
markImplicitEdges(thing);
}
void Shape::traceChildren(JSTracer* trc) {
TraceEdge(trc, &base_, "base");
TraceEdge(trc, &propidRef(), "propid");
@ -1928,7 +1892,7 @@ inline void GCMarker::processMarkStackTop(SliceBudget& budget) {
}
case MarkStack::ScriptTag: {
auto script = stack.popPtr().as<JSScript>();
auto script = stack.popPtr().as<BaseScript>();
AutoSetTracingSource asts(this, script);
return script->traceChildren(this);
}
@ -2212,7 +2176,7 @@ struct MapTypeToMarkStackTag<jit::JitCode*> {
static const auto value = MarkStack::JitCodeTag;
};
template <>
struct MapTypeToMarkStackTag<JSScript*> {
struct MapTypeToMarkStackTag<BaseScript*> {
static const auto value = MarkStack::ScriptTag;
};
@ -3060,7 +3024,7 @@ static inline void TraceWholeCell(TenuringTracer& mover, JS::BigInt* bi) {
bi->traceChildren(&mover);
}
static inline void TraceWholeCell(TenuringTracer& mover, JSScript* script) {
static inline void TraceWholeCell(TenuringTracer& mover, BaseScript* script) {
script->traceChildren(&mover);
}
@ -3105,7 +3069,7 @@ void js::gc::StoreBuffer::WholeCellBuffer::trace(TenuringTracer& mover) {
TraceBufferedCells<JS::BigInt>(mover, arena, cells);
break;
case JS::TraceKind::Script:
TraceBufferedCells<JSScript>(mover, arena, cells);
TraceBufferedCells<BaseScript>(mover, arena, cells);
break;
case JS::TraceKind::JitCode:
TraceBufferedCells<jit::JitCode>(mover, arena, cells);
@ -3725,12 +3689,9 @@ bool SweepingTracer::onShapeEdge(Shape** shapep) { return sweepEdge(shapep); }
bool SweepingTracer::onStringEdge(JSString** stringp) {
return sweepEdge(stringp);
}
bool SweepingTracer::onScriptEdge(JSScript** scriptp) {
bool SweepingTracer::onScriptEdge(js::BaseScript** scriptp) {
return sweepEdge(scriptp);
}
bool SweepingTracer::onLazyScriptEdge(LazyScript** lazyp) {
return sweepEdge(lazyp);
}
bool SweepingTracer::onBaseShapeEdge(BaseShape** basep) {
return sweepEdge(basep);
}

Просмотреть файл

@ -513,7 +513,7 @@ class BufferGrayRootsTracer final : public JS::CallbackTracer {
bool onStringEdge(JSString** stringp) override {
return bufferRoot(*stringp);
}
bool onScriptEdge(JSScript** scriptp) override {
bool onScriptEdge(js::BaseScript** scriptp) override {
return bufferRoot(*scriptp);
}
bool onSymbolEdge(JS::Symbol** symbolp) override {

Просмотреть файл

@ -237,10 +237,6 @@ JS_PUBLIC_API void JS_GetTraceThingInfo(char* buf, size_t bufsize,
name = "jitcode";
break;
case JS::TraceKind::LazyScript:
name = "lazyscript";
break;
case JS::TraceKind::Null:
name = "null_pointer";
break;
@ -321,12 +317,6 @@ JS_PUBLIC_API void JS_GetTraceThingInfo(char* buf, size_t bufsize,
break;
}
case JS::TraceKind::LazyScript: {
LazyScript* script = static_cast<LazyScript*>(thing);
snprintf(buf, bufsize, " %s:%u", script->filename(), script->lineno());
break;
}
case JS::TraceKind::String: {
*buf++ = ' ';
bufsize--;

Просмотреть файл

@ -28,12 +28,11 @@ class GCCellPtrTypeCache(object):
kind('Object', 'JSObject')
kind('String', 'JSString')
kind('Symbol', 'JS::Symbol')
kind('Script', 'JSScript')
kind('Script', 'js::BaseScript')
kind('Shape', 'js::Shape')
kind('ObjectGroup', 'js::ObjectGroup')
kind('BaseShape', 'js::BaseShape')
kind('JitCode', 'js::jit::JitCode')
kind('LazyScript', 'js::LazyScript')
self.kind_to_type = kind_to_type
self.Null = e['JS::TraceKind::Null']

Просмотреть файл

@ -803,20 +803,14 @@ inline void JSFunction::trace(JSTracer* trc) {
// for self-hosted code.
if (isIncomplete()) {
MOZ_ASSERT(u.scripted.s.script_ == nullptr);
} else if (hasScript()) {
JSScript* script = static_cast<JSScript*>(u.scripted.s.script_);
} else if (hasBaseScript()) {
BaseScript* script = u.scripted.s.script_;
TraceManuallyBarrieredEdge(trc, &script, "script");
// Self-hosted scripts are shared with workers but are never
// relocated. Skip unnecessary writes to prevent the possible data race.
if (u.scripted.s.script_ != script) {
u.scripted.s.script_ = script;
}
} else if (hasLazyScript()) {
LazyScript* lazy = static_cast<LazyScript*>(u.scripted.s.script_);
TraceManuallyBarrieredEdge(trc, &lazy, "lazy");
if (u.scripted.s.script_ != lazy) {
u.scripted.s.script_ = lazy;
}
}
// NOTE: The u.scripted.s.selfHostedLazy_ does not point to GC things.

Просмотреть файл

@ -5722,7 +5722,7 @@ void JSScript::AutoDelazify::dropScript() {
script_ = nullptr;
}
JS::ubi::Base::Size JS::ubi::Concrete<JSScript>::size(
JS::ubi::Base::Size JS::ubi::Concrete<BaseScript>::size(
mozilla::MallocSizeOf mallocSizeOf) const {
BaseScript* base = &get();
@ -5750,22 +5750,6 @@ JS::ubi::Base::Size JS::ubi::Concrete<JSScript>::size(
return size;
}
const char* JS::ubi::Concrete<JSScript>::scriptFilename() const {
const char* JS::ubi::Concrete<BaseScript>::scriptFilename() const {
return get().filename();
}
JS::ubi::Node::Size JS::ubi::Concrete<js::LazyScript>::size(
mozilla::MallocSizeOf mallocSizeOf) const {
Size size = gc::Arena::thingSize(get().asTenured().getAllocKind());
size += get().sizeOfExcludingThis(mallocSizeOf);
return size;
}
const char* JS::ubi::Concrete<js::LazyScript>::scriptFilename() const {
auto source = get().scriptSource();
if (!source) {
return nullptr;
}
return source->filename();
}

Просмотреть файл

@ -2526,6 +2526,8 @@ setterLevel: \
friend class GCMarker;
friend void js::gc::SweepLazyScripts(GCParallelTask* task);
static const JS::TraceKind TraceKind = JS::TraceKind::Script;
void traceChildren(JSTracer* trc);
void finalize(JSFreeOp* fop);
@ -3202,8 +3204,6 @@ class JSScript : public js::BaseScript {
// invariants of debuggee compartments, scripts, and frames.
inline bool isDebuggee() const;
static const JS::TraceKind TraceKind = JS::TraceKind::Script;
// A helper class to prevent relazification of the given function's script
// while it's holding on to it. This class automatically roots the script.
class AutoDelazify;
@ -3394,8 +3394,6 @@ class LazyScript : public BaseScript {
bool enclosingScriptHasEverBeenCompiled() const {
return warmUpData_.isEnclosingScope();
}
static const JS::TraceKind TraceKind = JS::TraceKind::LazyScript;
};
/* If this fails, add/remove padding within LazyScript. */
@ -3482,24 +3480,12 @@ JSScript* CloneGlobalScript(JSContext* cx, ScopeKind scopeKind,
// with no associated compartment.
namespace JS {
namespace ubi {
template <>
class Concrete<js::LazyScript> : TracerConcrete<js::LazyScript> {
protected:
explicit Concrete(js::LazyScript* ptr)
: TracerConcrete<js::LazyScript>(ptr) {}
class Concrete<JSScript> : public Concrete<js::BaseScript> {};
template <>
class Concrete<js::LazyScript> : public Concrete<js::BaseScript> {};
public:
static void construct(void* storage, js::LazyScript* ptr) {
new (storage) Concrete(ptr);
}
CoarseType coarseType() const final { return CoarseType::Script; }
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
const char* scriptFilename() const final;
const char16_t* typeName() const override { return concreteTypeName; }
static const char16_t concreteTypeName[];
};
} // namespace ubi
} // namespace JS

Просмотреть файл

@ -460,14 +460,6 @@ static void StatsCellCallback(JSRuntime* rt, void* data, JS::GCCellPtr cellptr,
break;
}
case JS::TraceKind::LazyScript: {
LazyScript* lazy = &cellptr.as<LazyScript>();
zStats->lazyScriptsGCHeap += thingSize;
zStats->lazyScriptsMallocHeap +=
lazy->sizeOfExcludingThis(rtStats->mallocSizeOf_);
break;
}
case JS::TraceKind::Shape: {
Shape* shape = &cellptr.as<Shape>();

Просмотреть файл

@ -256,8 +256,7 @@ JS::Zone* TracerConcrete<Referent>::zone() const {
return get().zoneFromAnyThread();
}
template JS::Zone* TracerConcrete<JSScript>::zone() const;
template JS::Zone* TracerConcrete<js::LazyScript>::zone() const;
template JS::Zone* TracerConcrete<js::BaseScript>::zone() const;
template JS::Zone* TracerConcrete<js::Shape>::zone() const;
template JS::Zone* TracerConcrete<js::BaseShape>::zone() const;
template JS::Zone* TracerConcrete<js::ObjectGroup>::zone() const;
@ -287,9 +286,7 @@ UniquePtr<EdgeRange> TracerConcrete<Referent>::edges(JSContext* cx,
return UniquePtr<EdgeRange>(range.release());
}
template UniquePtr<EdgeRange> TracerConcrete<JSScript>::edges(
JSContext* cx, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<js::LazyScript>::edges(
template UniquePtr<EdgeRange> TracerConcrete<js::BaseScript>::edges(
JSContext* cx, bool wantNames) const;
template UniquePtr<EdgeRange> TracerConcrete<js::Shape>::edges(
JSContext* cx, bool wantNames) const;
@ -318,8 +315,8 @@ Realm* TracerConcreteWithRealm<Referent>::realm() const {
return TracerBase::get().realm();
}
template Realm* TracerConcreteWithRealm<JSScript>::realm() const;
template JS::Compartment* TracerConcreteWithRealm<JSScript>::compartment()
template Realm* TracerConcreteWithRealm<js::BaseScript>::realm() const;
template JS::Compartment* TracerConcreteWithRealm<js::BaseScript>::compartment()
const;
bool Concrete<JSObject>::hasAllocationStack() const {
@ -372,8 +369,7 @@ Realm* Concrete<JSObject>::realm() const {
const char16_t Concrete<JS::Symbol>::concreteTypeName[] = u"JS::Symbol";
const char16_t Concrete<BigInt>::concreteTypeName[] = u"JS::BigInt";
const char16_t Concrete<JSScript>::concreteTypeName[] = u"JSScript";
const char16_t Concrete<js::LazyScript>::concreteTypeName[] = u"js::LazyScript";
const char16_t Concrete<js::BaseScript>::concreteTypeName[] = u"js::BaseScript";
const char16_t Concrete<js::jit::JitCode>::concreteTypeName[] =
u"js::jit::JitCode";
const char16_t Concrete<js::Shape>::concreteTypeName[] = u"js::Shape";

Просмотреть файл

@ -1392,15 +1392,6 @@ static void ReportZoneStats(const JS::ZoneStats& zStats,
"Extra data attached to each compartment by XPConnect, including "
"its wrapped-js.");
ZRREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("lazy-scripts/gc-heap"),
zStats.lazyScriptsGCHeap,
"Scripts that haven't executed yet.");
ZRREPORT_BYTES(
pathPrefix + NS_LITERAL_CSTRING("lazy-scripts/malloc-heap"),
zStats.lazyScriptsMallocHeap,
"Lazy script tables containing closed-over bindings or inner functions.");
ZRREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("jit-codes-gc-heap"),
zStats.jitCodesGCHeap,
"References to executable code pools used by the JITs.");
@ -2436,12 +2427,6 @@ void JSReporter::CollectReports(WindowPaths* windowPaths,
KIND_OTHER, rtStats.zTotals.unusedGCThings.script,
"Unused script cells within non-empty arenas.");
REPORT_BYTES(
NS_LITERAL_CSTRING(
"js-main-runtime-gc-heap-committed/unused/gc-things/lazy-scripts"),
KIND_OTHER, rtStats.zTotals.unusedGCThings.lazyScript,
"Unused lazy script cells within non-empty arenas.");
REPORT_BYTES(
NS_LITERAL_CSTRING(
"js-main-runtime-gc-heap-committed/unused/gc-things/jitcode"),
@ -2509,11 +2494,6 @@ void JSReporter::CollectReports(WindowPaths* windowPaths,
KIND_OTHER, rtStats.realmTotals.scriptsGCHeap,
"Used script cells.");
MREPORT_BYTES(
NS_LITERAL_CSTRING(
"js-main-runtime-gc-heap-committed/used/gc-things/lazy-scripts"),
KIND_OTHER, rtStats.zTotals.lazyScriptsGCHeap, "Used lazy script cells.");
MREPORT_BYTES(NS_LITERAL_CSTRING(
"js-main-runtime-gc-heap-committed/used/gc-things/jitcode"),
KIND_OTHER, rtStats.zTotals.jitCodesGCHeap,