mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1649968 - Part 6: Use CompilationStencil in ScopeCreationData::create. r=tcampbell
Depends on D88209 Differential Revision: https://phabricator.services.mozilla.com/D88210
This commit is contained in:
parent
8af2640026
commit
59c98f2c1f
@ -514,8 +514,8 @@ bool EmitterScope::enterLexical(BytecodeEmitter* bce, ScopeKind kind,
|
||||
auto createScope = [kind, bindings, firstFrameSlot, bce](
|
||||
JSContext* cx, mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index) {
|
||||
return ScopeStencil::createForLexicalScope(cx, bce->compilationInfo, kind,
|
||||
bindings, firstFrameSlot,
|
||||
return ScopeStencil::createForLexicalScope(cx, bce->compilationInfo.stencil,
|
||||
kind, bindings, firstFrameSlot,
|
||||
enclosing, index);
|
||||
};
|
||||
if (!internScopeCreationData(bce, createScope)) {
|
||||
@ -575,8 +575,8 @@ bool EmitterScope::enterNamedLambda(BytecodeEmitter* bce, FunctionBox* funbox) {
|
||||
JSContext* cx, mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index) {
|
||||
return ScopeStencil::createForLexicalScope(
|
||||
cx, bce->compilationInfo, scopeKind, funbox->namedLambdaBindings(),
|
||||
LOCALNO_LIMIT, enclosing, index);
|
||||
cx, bce->compilationInfo.stencil, scopeKind,
|
||||
funbox->namedLambdaBindings(), LOCALNO_LIMIT, enclosing, index);
|
||||
};
|
||||
if (!internScopeCreationData(bce, createScope)) {
|
||||
return false;
|
||||
@ -665,7 +665,7 @@ bool EmitterScope::enterFunction(BytecodeEmitter* bce, FunctionBox* funbox) {
|
||||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index) {
|
||||
return ScopeStencil::createForFunctionScope(
|
||||
cx, bce->compilationInfo, funbox->functionScopeBindings(),
|
||||
cx, bce->compilationInfo.stencil, funbox->functionScopeBindings(),
|
||||
funbox->hasParameterExprs,
|
||||
funbox->needsCallObjectRegardlessOfBindings(), funbox->index(),
|
||||
funbox->isArrow(), enclosing, index);
|
||||
@ -725,7 +725,7 @@ bool EmitterScope::enterFunctionExtraBodyVar(BytecodeEmitter* bce,
|
||||
JSContext* cx, mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index) {
|
||||
return ScopeStencil::createForVarScope(
|
||||
cx, bce->compilationInfo, ScopeKind::FunctionBodyVar,
|
||||
cx, bce->compilationInfo.stencil, ScopeKind::FunctionBodyVar,
|
||||
funbox->extraVarScopeBindings(), firstFrameSlot,
|
||||
funbox->needsExtraBodyVarEnvironmentRegardlessOfBindings(), enclosing,
|
||||
index);
|
||||
@ -804,7 +804,7 @@ bool EmitterScope::enterGlobal(BytecodeEmitter* bce,
|
||||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index) {
|
||||
MOZ_ASSERT(enclosing.isNothing());
|
||||
return ScopeStencil::createForGlobalScope(cx, bce->compilationInfo,
|
||||
return ScopeStencil::createForGlobalScope(cx, bce->compilationInfo.stencil,
|
||||
globalsc->scopeKind(),
|
||||
globalsc->bindings, index);
|
||||
};
|
||||
@ -873,8 +873,9 @@ bool EmitterScope::enterEval(BytecodeEmitter* bce, EvalSharedContext* evalsc) {
|
||||
ScopeIndex* index) {
|
||||
ScopeKind scopeKind =
|
||||
evalsc->strict() ? ScopeKind::StrictEval : ScopeKind::Eval;
|
||||
return ScopeStencil::createForEvalScope(cx, bce->compilationInfo, scopeKind,
|
||||
evalsc->bindings, enclosing, index);
|
||||
return ScopeStencil::createForEvalScope(cx, bce->compilationInfo.stencil,
|
||||
scopeKind, evalsc->bindings,
|
||||
enclosing, index);
|
||||
};
|
||||
if (!internBodyScopeCreationData(bce, createScope)) {
|
||||
return false;
|
||||
@ -980,7 +981,7 @@ bool EmitterScope::enterModule(BytecodeEmitter* bce,
|
||||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index) {
|
||||
return ScopeStencil::createForModuleScope(
|
||||
cx, bce->compilationInfo, modulesc->bindings, enclosing, index);
|
||||
cx, bce->compilationInfo.stencil, modulesc->bindings, enclosing, index);
|
||||
};
|
||||
if (!internBodyScopeCreationData(bce, createScope)) {
|
||||
return false;
|
||||
@ -1001,8 +1002,8 @@ bool EmitterScope::enterWith(BytecodeEmitter* bce) {
|
||||
|
||||
auto createScope = [bce](JSContext* cx, mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index) {
|
||||
return ScopeStencil::createForWithScope(cx, bce->compilationInfo, enclosing,
|
||||
index);
|
||||
return ScopeStencil::createForWithScope(cx, bce->compilationInfo.stencil,
|
||||
enclosing, index);
|
||||
};
|
||||
if (!internScopeCreationData(bce, createScope)) {
|
||||
return false;
|
||||
|
@ -141,7 +141,7 @@ bool ConvertScopeStencil(JSContext* cx, const SmooshResult& result,
|
||||
data->length = numBindings;
|
||||
|
||||
if (!ScopeStencil::createForGlobalScope(
|
||||
cx, compilationInfo, ScopeKind::Global, data, &index)) {
|
||||
cx, compilationInfo.stencil, ScopeKind::Global, data, &index)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -167,7 +167,7 @@ bool ConvertScopeStencil(JSContext* cx, const SmooshResult& result,
|
||||
uint32_t firstFrameSlot = var.first_frame_slot;
|
||||
ScopeIndex enclosingIndex(var.enclosing);
|
||||
if (!ScopeStencil::createForVarScope(
|
||||
cx, compilationInfo, ScopeKind::FunctionBodyVar, data,
|
||||
cx, compilationInfo.stencil, ScopeKind::FunctionBodyVar, data,
|
||||
firstFrameSlot, var.function_has_extensible_scope,
|
||||
mozilla::Some(enclosingIndex), &index)) {
|
||||
return false;
|
||||
@ -196,8 +196,8 @@ bool ConvertScopeStencil(JSContext* cx, const SmooshResult& result,
|
||||
uint32_t firstFrameSlot = lexical.first_frame_slot;
|
||||
ScopeIndex enclosingIndex(lexical.enclosing);
|
||||
if (!ScopeStencil::createForLexicalScope(
|
||||
cx, compilationInfo, ScopeKind::Lexical, data, firstFrameSlot,
|
||||
mozilla::Some(enclosingIndex), &index)) {
|
||||
cx, compilationInfo.stencil, ScopeKind::Lexical, data,
|
||||
firstFrameSlot, mozilla::Some(enclosingIndex), &index)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -231,9 +231,9 @@ bool ConvertScopeStencil(JSContext* cx, const SmooshResult& result,
|
||||
|
||||
ScopeIndex enclosingIndex(function.enclosing);
|
||||
if (!ScopeStencil::createForFunctionScope(
|
||||
cx, compilationInfo, data, hasParameterExprs, needsEnvironment,
|
||||
functionIndex, isArrow, mozilla::Some(enclosingIndex),
|
||||
&index)) {
|
||||
cx, compilationInfo.stencil, data, hasParameterExprs,
|
||||
needsEnvironment, functionIndex, isArrow,
|
||||
mozilla::Some(enclosingIndex), &index)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -41,6 +41,7 @@ class JSONPrinter;
|
||||
namespace frontend {
|
||||
|
||||
struct CompilationInfo;
|
||||
struct CompilationStencil;
|
||||
struct CompilationGCOutput;
|
||||
class ScriptStencil;
|
||||
class RegExpStencil;
|
||||
@ -190,44 +191,44 @@ class ScopeStencil {
|
||||
isArrow_(isArrow),
|
||||
data_(data) {}
|
||||
|
||||
static bool createForFunctionScope(
|
||||
JSContext* cx, CompilationInfo& compilationInfo,
|
||||
ParserFunctionScopeData* dataArg, bool hasParameterExprs,
|
||||
bool needsEnvironment, FunctionIndex functionIndex, bool isArrow,
|
||||
mozilla::Maybe<ScopeIndex> enclosing, ScopeIndex* index);
|
||||
static bool createForFunctionScope(JSContext* cx, CompilationStencil& stencil,
|
||||
ParserFunctionScopeData* dataArg,
|
||||
bool hasParameterExprs,
|
||||
bool needsEnvironment,
|
||||
FunctionIndex functionIndex, bool isArrow,
|
||||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index);
|
||||
|
||||
static bool createForLexicalScope(
|
||||
JSContext* cx, CompilationInfo& compilationInfo, ScopeKind kind,
|
||||
ParserLexicalScopeData* dataArg, uint32_t firstFrameSlot,
|
||||
mozilla::Maybe<ScopeIndex> enclosing, ScopeIndex* index);
|
||||
static bool createForLexicalScope(JSContext* cx, CompilationStencil& stencil,
|
||||
ScopeKind kind,
|
||||
ParserLexicalScopeData* dataArg,
|
||||
uint32_t firstFrameSlot,
|
||||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index);
|
||||
|
||||
static bool createForVarScope(JSContext* cx,
|
||||
frontend::CompilationInfo& compilationInfo,
|
||||
frontend::CompilationStencil& stencil,
|
||||
ScopeKind kind, ParserVarScopeData* dataArg,
|
||||
uint32_t firstFrameSlot, bool needsEnvironment,
|
||||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index);
|
||||
|
||||
static bool createForGlobalScope(JSContext* cx,
|
||||
CompilationInfo& compilationInfo,
|
||||
static bool createForGlobalScope(JSContext* cx, CompilationStencil& stencil,
|
||||
ScopeKind kind,
|
||||
ParserGlobalScopeData* dataArg,
|
||||
ScopeIndex* index);
|
||||
|
||||
static bool createForEvalScope(JSContext* cx,
|
||||
CompilationInfo& compilationInfo,
|
||||
static bool createForEvalScope(JSContext* cx, CompilationStencil& stencil,
|
||||
ScopeKind kind, ParserEvalScopeData* dataArg,
|
||||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index);
|
||||
|
||||
static bool createForModuleScope(JSContext* cx,
|
||||
CompilationInfo& compilationInfo,
|
||||
static bool createForModuleScope(JSContext* cx, CompilationStencil& stencil,
|
||||
ParserModuleScopeData* dataArg,
|
||||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index);
|
||||
|
||||
static bool createForWithScope(JSContext* cx,
|
||||
CompilationInfo& compilationInfo,
|
||||
static bool createForWithScope(JSContext* cx, CompilationStencil& stencil,
|
||||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index);
|
||||
|
||||
|
@ -1917,7 +1917,7 @@ JS::ubi::Node::Size JS::ubi::Concrete<Scope>::size(
|
||||
|
||||
/* static */
|
||||
bool ScopeStencil::createForFunctionScope(
|
||||
JSContext* cx, frontend::CompilationInfo& compilationInfo,
|
||||
JSContext* cx, frontend::CompilationStencil& stencil,
|
||||
ParserFunctionScopeData* data, bool hasParameterExprs,
|
||||
bool needsEnvironment, FunctionIndex functionIndex, bool isArrow,
|
||||
mozilla::Maybe<ScopeIndex> enclosing, ScopeIndex* index) {
|
||||
@ -1950,15 +1950,15 @@ bool ScopeStencil::createForFunctionScope(
|
||||
}
|
||||
}
|
||||
|
||||
*index = compilationInfo.stencil.scopeData.length();
|
||||
return compilationInfo.stencil.scopeData.emplaceBack(
|
||||
*index = stencil.scopeData.length();
|
||||
return stencil.scopeData.emplaceBack(
|
||||
ScopeKind::Function, enclosing, firstFrameSlot, envShape,
|
||||
ownedData.release(), mozilla::Some(functionIndex), isArrow);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool ScopeStencil::createForLexicalScope(
|
||||
JSContext* cx, frontend::CompilationInfo& compilationInfo, ScopeKind kind,
|
||||
JSContext* cx, frontend::CompilationStencil& stencil, ScopeKind kind,
|
||||
ParserLexicalScopeData* data, uint32_t firstFrameSlot,
|
||||
mozilla::Maybe<ScopeIndex> enclosing, ScopeIndex* index) {
|
||||
// If incoming data is null, initialize an empty scope data.
|
||||
@ -1984,13 +1984,13 @@ bool ScopeStencil::createForLexicalScope(
|
||||
}
|
||||
}
|
||||
|
||||
*index = compilationInfo.stencil.scopeData.length();
|
||||
return compilationInfo.stencil.scopeData.emplaceBack(
|
||||
kind, enclosing, firstFrameSlot, envShape, ownedData.release());
|
||||
*index = stencil.scopeData.length();
|
||||
return stencil.scopeData.emplaceBack(kind, enclosing, firstFrameSlot,
|
||||
envShape, ownedData.release());
|
||||
}
|
||||
|
||||
bool ScopeStencil::createForVarScope(
|
||||
JSContext* cx, frontend::CompilationInfo& compilationInfo, ScopeKind kind,
|
||||
JSContext* cx, frontend::CompilationStencil& stencil, ScopeKind kind,
|
||||
ParserVarScopeData* data, uint32_t firstFrameSlot, bool needsEnvironment,
|
||||
mozilla::Maybe<ScopeIndex> enclosing, ScopeIndex* index) {
|
||||
// If incoming data is null, initialize an empty scope data.
|
||||
@ -2016,15 +2016,17 @@ bool ScopeStencil::createForVarScope(
|
||||
}
|
||||
}
|
||||
|
||||
*index = compilationInfo.stencil.scopeData.length();
|
||||
return compilationInfo.stencil.scopeData.emplaceBack(
|
||||
kind, enclosing, firstFrameSlot, envShape, ownedData.release());
|
||||
*index = stencil.scopeData.length();
|
||||
return stencil.scopeData.emplaceBack(kind, enclosing, firstFrameSlot,
|
||||
envShape, ownedData.release());
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool ScopeStencil::createForGlobalScope(
|
||||
JSContext* cx, frontend::CompilationInfo& compilationInfo, ScopeKind kind,
|
||||
ParserGlobalScopeData* data, ScopeIndex* index) {
|
||||
bool ScopeStencil::createForGlobalScope(JSContext* cx,
|
||||
frontend::CompilationStencil& stencil,
|
||||
ScopeKind kind,
|
||||
ParserGlobalScopeData* data,
|
||||
ScopeIndex* index) {
|
||||
// If incoming data is null, initialize an empty scope data.
|
||||
UniquePtr<ParserGlobalScopeData> ownedData;
|
||||
if (!data) {
|
||||
@ -2051,16 +2053,17 @@ bool ScopeStencil::createForGlobalScope(
|
||||
}
|
||||
}
|
||||
|
||||
*index = compilationInfo.stencil.scopeData.length();
|
||||
return compilationInfo.stencil.scopeData.emplaceBack(
|
||||
kind, enclosing, firstFrameSlot, envShape, ownedData.release());
|
||||
*index = stencil.scopeData.length();
|
||||
return stencil.scopeData.emplaceBack(kind, enclosing, firstFrameSlot,
|
||||
envShape, ownedData.release());
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool ScopeStencil::createForEvalScope(
|
||||
JSContext* cx, frontend::CompilationInfo& compilationInfo, ScopeKind kind,
|
||||
ParserEvalScopeData* data, mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index) {
|
||||
bool ScopeStencil::createForEvalScope(JSContext* cx,
|
||||
frontend::CompilationStencil& stencil,
|
||||
ScopeKind kind, ParserEvalScopeData* data,
|
||||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index) {
|
||||
// If incoming data is null, initialize an empty scope data.
|
||||
UniquePtr<ParserEvalScopeData> ownedData;
|
||||
if (!data) {
|
||||
@ -2085,16 +2088,17 @@ bool ScopeStencil::createForEvalScope(
|
||||
}
|
||||
}
|
||||
|
||||
*index = compilationInfo.stencil.scopeData.length();
|
||||
return compilationInfo.stencil.scopeData.emplaceBack(
|
||||
kind, enclosing, firstFrameSlot, envShape, ownedData.release());
|
||||
*index = stencil.scopeData.length();
|
||||
return stencil.scopeData.emplaceBack(kind, enclosing, firstFrameSlot,
|
||||
envShape, ownedData.release());
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool ScopeStencil::createForModuleScope(
|
||||
JSContext* cx, frontend::CompilationInfo& compilationInfo,
|
||||
ParserModuleScopeData* data, mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index) {
|
||||
bool ScopeStencil::createForModuleScope(JSContext* cx,
|
||||
frontend::CompilationStencil& stencil,
|
||||
ParserModuleScopeData* data,
|
||||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index) {
|
||||
// If incoming data is null, initialize an empty scope data.
|
||||
UniquePtr<ParserModuleScopeData> ownedData;
|
||||
if (!data) {
|
||||
@ -2127,10 +2131,10 @@ bool ScopeStencil::createForModuleScope(
|
||||
}
|
||||
}
|
||||
|
||||
*index = compilationInfo.stencil.scopeData.length();
|
||||
return compilationInfo.stencil.scopeData.emplaceBack(
|
||||
ScopeKind::Module, enclosing, firstFrameSlot, envShape,
|
||||
ownedData.release());
|
||||
*index = stencil.scopeData.length();
|
||||
return stencil.scopeData.emplaceBack(ScopeKind::Module, enclosing,
|
||||
firstFrameSlot, envShape,
|
||||
ownedData.release());
|
||||
}
|
||||
|
||||
template <typename SpecificEnvironmentT>
|
||||
@ -2156,15 +2160,16 @@ bool ScopeStencil::createSpecificShape(JSContext* cx, ScopeKind kind,
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool ScopeStencil::createForWithScope(
|
||||
JSContext* cx, frontend::CompilationInfo& compilationInfo,
|
||||
mozilla::Maybe<ScopeIndex> enclosing, ScopeIndex* index) {
|
||||
bool ScopeStencil::createForWithScope(JSContext* cx,
|
||||
CompilationStencil& stencil,
|
||||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index) {
|
||||
uint32_t firstFrameSlot = 0;
|
||||
mozilla::Maybe<uint32_t> envShape;
|
||||
|
||||
*index = compilationInfo.stencil.scopeData.length();
|
||||
return compilationInfo.stencil.scopeData.emplaceBack(
|
||||
ScopeKind::With, enclosing, firstFrameSlot, envShape);
|
||||
*index = stencil.scopeData.length();
|
||||
return stencil.scopeData.emplaceBack(ScopeKind::With, enclosing,
|
||||
firstFrameSlot, envShape);
|
||||
}
|
||||
|
||||
template <typename SpecificScopeT>
|
||||
|
Loading…
Reference in New Issue
Block a user