Bug 1591598 - Move 'warmUpData_' field to js::BaseScript. r=jandem

Unify the JSScript::warmUpData_ and LazyScript::enclosingLazyScriptOrScope_
fields into BaseScript. As a script progresses from lazy up to being JIT-ed
it the type stored in this field will change. If a script is in a compiled
state, the enclosingLazyScriptOrScope_ value can always be reconstructed
during relazification.

Depends on D55034

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ted Campbell 2019-12-02 19:38:26 +00:00
Родитель 271e720c33
Коммит 67a59d854f
3 изменённых файлов: 23 добавлений и 39 удалений

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

@ -965,6 +965,8 @@ bool js::GCMarker::mark(T* thing) {
void BaseScript::traceChildren(JSTracer* trc) {
TraceEdge(trc, &functionOrGlobal_, "function");
TraceNullableEdge(trc, &sourceObject_, "sourceObject");
warmUpData_.trace(trc);
}
void LazyScript::traceChildren(JSTracer* trc) {
@ -975,14 +977,6 @@ void LazyScript::traceChildren(JSTracer* trc) {
TraceNullableEdge(trc, &script_, "script");
}
if (enclosingLazyScriptOrScope_) {
TraceGenericPointerRoot(
trc,
reinterpret_cast<Cell**>(
enclosingLazyScriptOrScope_.unsafeUnbarrieredForTracing()),
"enclosingScope or enclosingLazyScript");
}
// We rely on the fact that atoms are always tenured.
for (GCPtrAtom& closedOverBinding : closedOverBindings()) {
if (closedOverBinding) {
@ -1007,15 +1001,9 @@ inline void js::GCMarker::eagerlyMarkChildren(LazyScript* thing) {
traverseEdge(thing, static_cast<JSObject*>(thing->sourceObject_));
}
// script_ is weak so is not traced here.
thing->warmUpData_.trace(this);
if (thing->enclosingLazyScriptOrScope_) {
TraceManuallyBarrieredGenericPointerEdge(
this,
reinterpret_cast<Cell**>(
thing->enclosingLazyScriptOrScope_.unsafeUnbarrieredForTracing()),
"enclosingScope or enclosingLazyScript");
}
// script_ is weak so is not traced here.
// We rely on the fact that atoms are always tenured.
for (GCPtrAtom& closedOverBinding : thing->closedOverBindings()) {

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

@ -5318,8 +5318,6 @@ void JSScript::traceChildren(JSTracer* trc) {
scriptData()->traceChildren(trc);
}
warmUpData_.trace(trc);
if (maybeLazyScript()) {
TraceManuallyBarrieredEdge(trc, &lazyScript, "lazyScript");
}
@ -5680,14 +5678,19 @@ void LazyScript::setEnclosingLazyScript(LazyScript* enclosingLazyScript) {
// Enclosing scopes never transition back to enclosing lazy scripts.
MOZ_ASSERT(!hasEnclosingScope());
enclosingLazyScriptOrScope_ = enclosingLazyScript;
warmUpData_.initEnclosingScript(enclosingLazyScript);
}
void LazyScript::setEnclosingScope(Scope* enclosingScope) {
MOZ_ASSERT(enclosingScope);
MOZ_ASSERT(!hasEnclosingScope());
enclosingLazyScriptOrScope_ = enclosingScope;
if (warmUpData_.isEnclosingScript()) {
warmUpData_.clearEnclosingScript();
}
MOZ_ASSERT(warmUpData_.isWarmUpCount());
warmUpData_.initEnclosingScope(enclosingScope);
}
/* static */

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

@ -1568,6 +1568,8 @@ class BaseScript : public gc::TenuredCell {
uint32_t immutableFlags_ = 0;
uint32_t mutableFlags_ = 0;
ScriptWarmUpData warmUpData_ = {};
BaseScript(uint8_t* stubEntry, JSObject* functionOrGlobal,
ScriptSourceObject* sourceObject, uint32_t sourceStart,
uint32_t sourceEnd, uint32_t toStringStart, uint32_t toStringEnd)
@ -1991,6 +1993,9 @@ setterLevel: \
static constexpr size_t offsetOfMutableFlags() {
return offsetof(BaseScript, mutableFlags_);
}
static constexpr size_t offsetOfWarmUpData() {
return offsetof(BaseScript, warmUpData_);
}
};
struct FieldInitializers {
@ -2511,8 +2516,6 @@ class JSScript : public js::BaseScript {
js::PrivateScriptData* data_ = nullptr;
private:
js::ScriptWarmUpData warmUpData_ = {};
/* Information used to re-lazify a lazily-parsed interpreted function. */
js::LazyScript* lazyScript = nullptr;
@ -2801,9 +2804,6 @@ class JSScript : public js::BaseScript {
static constexpr size_t offsetOfPrivateScriptData() {
return offsetof(JSScript, data_);
}
static constexpr size_t offsetOfWarmUpData() {
return offsetof(JSScript, warmUpData_);
}
void updateJitCodeRaw(JSRuntime* rt);
@ -3274,7 +3274,7 @@ class LazyScript : public BaseScript {
WeakHeapPtrScript script_;
friend void js::gc::SweepLazyScripts(GCParallelTask* task);
// This field holds one of:
// The BaseScript::warmUpData_ field is used as follows:
// * LazyScript in which the script is nested. This case happens if the
// enclosing script is lazily parsed and have never been compiled.
//
@ -3301,6 +3301,8 @@ class LazyScript : public BaseScript {
// enclosing script has ever been compiled.
//
// * nullptr for incomplete (initial or failure) state
// NOTE: We currently represent this as WarmUpCount(0) inside the
// ScriptWarmUpData tagged pointer.
//
// This field should be accessed via accessors:
// * enclosingScope
@ -3349,7 +3351,6 @@ class LazyScript : public BaseScript {
// +-----------------+ |
// | enclosing Scope |<-------------+
// +-----------------+
GCPtr<TenuredCell*> enclosingLazyScriptOrScope_;
// Heap allocated table with any free variables, inner functions, or class
// fields. This will be nullptr if none exist.
@ -3423,25 +3424,17 @@ class LazyScript : public BaseScript {
}
bool hasScript() const { return bool(script_); }
bool hasEnclosingScope() const {
return enclosingLazyScriptOrScope_ &&
enclosingLazyScriptOrScope_->is<Scope>();
}
bool hasEnclosingScope() const { return warmUpData_.isEnclosingScope(); }
bool hasEnclosingLazyScript() const {
return enclosingLazyScriptOrScope_ &&
enclosingLazyScriptOrScope_->is<LazyScript>();
return warmUpData_.isEnclosingScript();
}
LazyScript* enclosingLazyScript() const {
MOZ_ASSERT(hasEnclosingLazyScript());
return enclosingLazyScriptOrScope_->as<LazyScript>();
return warmUpData_.toEnclosingScript();
}
void setEnclosingLazyScript(LazyScript* enclosingLazyScript);
Scope* enclosingScope() const {
MOZ_ASSERT(hasEnclosingScope());
return enclosingLazyScriptOrScope_->as<Scope>();
}
Scope* enclosingScope() const { return warmUpData_.toEnclosingScope(); }
void setEnclosingScope(Scope* enclosingScope);
bool hasNonSyntacticScope() const {