зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1609504 - Add parseInfo to sharedContext. r=mgaudet
Differential Revision: https://phabricator.services.mozilla.com/D60334 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c6b8eb2709
Коммит
c4fb2ca61c
|
@ -3725,8 +3725,8 @@ static bool reflect_parse(JSContext* cx, uint32_t argc, Value* vp) {
|
|||
|
||||
ModuleBuilder builder(cx, module, &parser);
|
||||
|
||||
ModuleSharedContext modulesc(cx, module, &cx->global()->emptyGlobalScope(),
|
||||
builder);
|
||||
ModuleSharedContext modulesc(cx, module, parseInfo,
|
||||
&cx->global()->emptyGlobalScope(), builder);
|
||||
pn = parser.moduleBody(&modulesc);
|
||||
if (!pn) {
|
||||
return false;
|
||||
|
|
|
@ -278,7 +278,8 @@ JS::Result<FunctionBox*> BinASTParserPerTokenizer<Tok>::buildFunctionBox(
|
|||
}
|
||||
|
||||
auto* funbox = alloc_.new_<FunctionBox>(
|
||||
cx_, traceListHead_, fun, /* toStringStart = */ 0, *directives,
|
||||
cx_, traceListHead_, fun, /* toStringStart = */ 0, getParseInfo(),
|
||||
*directives,
|
||||
/* extraWarning = */ false, generatorKind, functionAsyncKind);
|
||||
if (MOZ_UNLIKELY(!funbox)) {
|
||||
return raiseOOM();
|
||||
|
|
|
@ -117,7 +117,8 @@ class MOZ_STACK_CLASS GlobalScriptInfo final : public BytecodeCompiler {
|
|||
const JS::ReadOnlyCompileOptions& options,
|
||||
ScopeKind scopeKind)
|
||||
: BytecodeCompiler(cx, parseInfo, options),
|
||||
globalsc_(cx, scopeKind, directives, options.extraWarningsOption) {
|
||||
globalsc_(cx, scopeKind, parseInfo, directives,
|
||||
options.extraWarningsOption) {
|
||||
MOZ_ASSERT(scopeKind == ScopeKind::Global ||
|
||||
scopeKind == ScopeKind::NonSyntactic);
|
||||
}
|
||||
|
@ -142,7 +143,7 @@ class MOZ_STACK_CLASS EvalScriptInfo final : public BytecodeCompiler {
|
|||
JS::Handle<Scope*> enclosingScope)
|
||||
: BytecodeCompiler(cx, parseInfo, options),
|
||||
environment_(environment),
|
||||
evalsc_(cx, environment_, enclosingScope, directives,
|
||||
evalsc_(cx, environment_, parseInfo, enclosingScope, directives,
|
||||
options.extraWarningsOption) {}
|
||||
|
||||
HandleObject environment() { return environment_; }
|
||||
|
|
|
@ -580,7 +580,8 @@ ModuleObject* frontend::ModuleCompiler<Unit>::compile(
|
|||
ModuleBuilder builder(cx, module, parser.ptr());
|
||||
|
||||
RootedScope enclosingScope(cx, &cx->global()->emptyGlobalScope());
|
||||
ModuleSharedContext modulesc(cx, module, enclosingScope, builder);
|
||||
ModuleSharedContext modulesc(cx, module, info.parseInfo, enclosingScope,
|
||||
builder);
|
||||
ParseNode* pn = parser->moduleBody(&modulesc);
|
||||
if (!pn) {
|
||||
return nullptr;
|
||||
|
@ -748,7 +749,7 @@ static JSScript* CompileGlobalBinASTScriptImpl(
|
|||
}
|
||||
|
||||
Directives directives(options.forceStrictMode());
|
||||
GlobalSharedContext globalsc(cx, ScopeKind::Global, directives,
|
||||
GlobalSharedContext globalsc(cx, ScopeKind::Global, parseInfo, directives,
|
||||
options.extraWarningsOption);
|
||||
|
||||
frontend::BinASTParser<ParserT> parser(cx, parseInfo, options,
|
||||
|
|
|
@ -29,7 +29,7 @@ class MOZ_STACK_CLASS ModuleSharedContext : public SharedContext {
|
|||
JS::Rooted<ModuleScope::Data*> bindings;
|
||||
ModuleBuilder& builder;
|
||||
|
||||
ModuleSharedContext(JSContext* cx, ModuleObject* module,
|
||||
ModuleSharedContext(JSContext* cx, ModuleObject* module, ParseInfo& parseInfo,
|
||||
Scope* enclosingScope, ModuleBuilder& builder);
|
||||
|
||||
JS::Handle<ModuleObject*> module() const { return module_; }
|
||||
|
|
|
@ -324,8 +324,9 @@ FunctionBox* PerHandlerParser<ParseHandler>::newFunctionBox(
|
|||
* function.
|
||||
*/
|
||||
FunctionBox* funbox = alloc_.new_<FunctionBox>(
|
||||
cx_, traceListHead_, fun, toStringStart, inheritedDirectives,
|
||||
options().extraWarningsOption, generatorKind, asyncKind);
|
||||
cx_, traceListHead_, fun, toStringStart, this->getParseInfo(),
|
||||
inheritedDirectives, options().extraWarningsOption, generatorKind,
|
||||
asyncKind);
|
||||
if (!funbox) {
|
||||
ReportOutOfMemory(cx_);
|
||||
return nullptr;
|
||||
|
@ -353,8 +354,9 @@ FunctionBox* PerHandlerParser<ParseHandler>::newFunctionBox(
|
|||
*/
|
||||
|
||||
FunctionBox* funbox = alloc_.new_<FunctionBox>(
|
||||
cx_, traceListHead_, fcd, toStringStart, inheritedDirectives,
|
||||
options().extraWarningsOption, generatorKind, asyncKind);
|
||||
cx_, traceListHead_, fcd, toStringStart, this->getParseInfo(),
|
||||
inheritedDirectives, options().extraWarningsOption, generatorKind,
|
||||
asyncKind);
|
||||
|
||||
if (!funbox) {
|
||||
ReportOutOfMemory(cx_);
|
||||
|
@ -426,8 +428,8 @@ typename ParseHandler::ListNodeType GeneralParser<ParseHandler, Unit>::parse() {
|
|||
MOZ_ASSERT(checkOptionsCalled_);
|
||||
|
||||
Directives directives(options().forceStrictMode());
|
||||
GlobalSharedContext globalsc(cx_, ScopeKind::Global, directives,
|
||||
options().extraWarningsOption);
|
||||
GlobalSharedContext globalsc(cx_, ScopeKind::Global, this->getParseInfo(),
|
||||
directives, options().extraWarningsOption);
|
||||
SourceParseContext globalpc(this, &globalsc, /* newDirectives = */ nullptr);
|
||||
if (!globalpc.init()) {
|
||||
return null();
|
||||
|
|
|
@ -74,9 +74,10 @@ void SharedContext::computeInWith(Scope* scope) {
|
|||
}
|
||||
|
||||
EvalSharedContext::EvalSharedContext(JSContext* cx, JSObject* enclosingEnv,
|
||||
ParseInfo& parseInfo,
|
||||
Scope* enclosingScope,
|
||||
Directives directives, bool extraWarnings)
|
||||
: SharedContext(cx, Kind::Eval, directives, extraWarnings),
|
||||
: SharedContext(cx, Kind::Eval, parseInfo, directives, extraWarnings),
|
||||
enclosingScope_(cx, enclosingScope),
|
||||
bindings(cx) {
|
||||
computeAllowSyntax(enclosingScope);
|
||||
|
@ -116,12 +117,14 @@ bool FunctionBox::atomsAreKept() { return cx_->zone()->hasKeptAtoms(); }
|
|||
#endif
|
||||
|
||||
FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
|
||||
uint32_t toStringStart, Directives directives,
|
||||
bool extraWarnings, GeneratorKind generatorKind,
|
||||
uint32_t toStringStart, ParseInfo& parseInfo,
|
||||
Directives directives, bool extraWarnings,
|
||||
GeneratorKind generatorKind,
|
||||
FunctionAsyncKind asyncKind, JSAtom* explicitName,
|
||||
FunctionFlags flags)
|
||||
: ObjectBox(nullptr, traceListHead, TraceListNode::NodeType::Function),
|
||||
SharedContext(cx, Kind::FunctionBox, directives, extraWarnings),
|
||||
SharedContext(cx, Kind::FunctionBox, parseInfo, directives,
|
||||
extraWarnings),
|
||||
enclosingScope_(),
|
||||
namedLambdaBindings_(nullptr),
|
||||
functionScopeBindings_(nullptr),
|
||||
|
@ -163,11 +166,12 @@ FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
|
|||
|
||||
FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
|
||||
JSFunction* fun, uint32_t toStringStart,
|
||||
Directives directives, bool extraWarnings,
|
||||
GeneratorKind generatorKind,
|
||||
ParseInfo& parseInfo, Directives directives,
|
||||
bool extraWarnings, GeneratorKind generatorKind,
|
||||
FunctionAsyncKind asyncKind)
|
||||
: FunctionBox(cx, traceListHead, toStringStart, directives, extraWarnings,
|
||||
generatorKind, asyncKind, fun->explicitName(), fun->flags()) {
|
||||
: FunctionBox(cx, traceListHead, toStringStart, parseInfo, directives,
|
||||
extraWarnings, generatorKind, asyncKind, fun->explicitName(),
|
||||
fun->flags()) {
|
||||
gcThing = fun;
|
||||
// Functions created at parse time may be set singleton after parsing and
|
||||
// baked into JIT code, so they must be allocated tenured. They are held by
|
||||
|
@ -177,11 +181,13 @@ FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
|
|||
|
||||
FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
|
||||
Handle<FunctionCreationData> data,
|
||||
uint32_t toStringStart, Directives directives,
|
||||
bool extraWarnings, GeneratorKind generatorKind,
|
||||
uint32_t toStringStart, ParseInfo& parseInfo,
|
||||
Directives directives, bool extraWarnings,
|
||||
GeneratorKind generatorKind,
|
||||
FunctionAsyncKind asyncKind)
|
||||
: FunctionBox(cx, traceListHead, toStringStart, directives, extraWarnings,
|
||||
generatorKind, asyncKind, data.get().atom, data.get().flags) {
|
||||
: FunctionBox(cx, traceListHead, toStringStart, parseInfo, directives,
|
||||
extraWarnings, generatorKind, asyncKind, data.get().atom,
|
||||
data.get().flags) {
|
||||
functionCreationData_.emplace(data);
|
||||
}
|
||||
|
||||
|
@ -327,9 +333,10 @@ void FunctionBox::finish() {
|
|||
}
|
||||
|
||||
ModuleSharedContext::ModuleSharedContext(JSContext* cx, ModuleObject* module,
|
||||
ParseInfo& parseInfo,
|
||||
Scope* enclosingScope,
|
||||
ModuleBuilder& builder)
|
||||
: SharedContext(cx, Kind::Module, Directives(true), false),
|
||||
: SharedContext(cx, Kind::Module, parseInfo, Directives(true), false),
|
||||
module_(cx, module),
|
||||
enclosingScope_(cx, enclosingScope),
|
||||
bindings(cx),
|
||||
|
|
|
@ -108,6 +108,8 @@ class SharedContext {
|
|||
|
||||
Kind kind_;
|
||||
|
||||
ParseInfo& parseInfo_;
|
||||
|
||||
ThisBinding thisBinding_;
|
||||
|
||||
public:
|
||||
|
@ -159,10 +161,11 @@ class SharedContext {
|
|||
void computeThisBinding(Scope* scope);
|
||||
|
||||
public:
|
||||
SharedContext(JSContext* cx, Kind kind, Directives directives,
|
||||
bool extraWarnings)
|
||||
SharedContext(JSContext* cx, Kind kind, ParseInfo& parseInfo,
|
||||
Directives directives, bool extraWarnings)
|
||||
: cx_(cx),
|
||||
kind_(kind),
|
||||
parseInfo_(parseInfo),
|
||||
thisBinding_(ThisBinding::Global),
|
||||
strictScript(directives.strict()),
|
||||
localStrict(false),
|
||||
|
@ -205,6 +208,8 @@ class SharedContext {
|
|||
return false;
|
||||
}
|
||||
|
||||
ParseInfo& parseInfo() const { return parseInfo_; }
|
||||
|
||||
ThisBinding thisBinding() const { return thisBinding_; }
|
||||
|
||||
bool hasModuleGoal() const { return hasModuleGoal_; }
|
||||
|
@ -247,9 +252,9 @@ class MOZ_STACK_CLASS GlobalSharedContext : public SharedContext {
|
|||
public:
|
||||
Rooted<GlobalScope::Data*> bindings;
|
||||
|
||||
GlobalSharedContext(JSContext* cx, ScopeKind scopeKind, Directives directives,
|
||||
bool extraWarnings)
|
||||
: SharedContext(cx, Kind::Global, directives, extraWarnings),
|
||||
GlobalSharedContext(JSContext* cx, ScopeKind scopeKind, ParseInfo& parseInfo,
|
||||
Directives directives, bool extraWarnings)
|
||||
: SharedContext(cx, Kind::Global, parseInfo, directives, extraWarnings),
|
||||
scopeKind_(scopeKind),
|
||||
bindings(cx) {
|
||||
MOZ_ASSERT(scopeKind == ScopeKind::Global ||
|
||||
|
@ -273,7 +278,7 @@ class MOZ_STACK_CLASS EvalSharedContext : public SharedContext {
|
|||
public:
|
||||
Rooted<EvalScope::Data*> bindings;
|
||||
|
||||
EvalSharedContext(JSContext* cx, JSObject* enclosingEnv,
|
||||
EvalSharedContext(JSContext* cx, JSObject* enclosingEnv, ParseInfo& parseInfo,
|
||||
Scope* enclosingScope, Directives directives,
|
||||
bool extraWarnings);
|
||||
|
||||
|
@ -314,7 +319,8 @@ class FunctionBox : public ObjectBox, public SharedContext {
|
|||
VarScope::Data* extraVarScopeBindings_;
|
||||
|
||||
FunctionBox(JSContext* cx, TraceListNode* traceListHead,
|
||||
uint32_t toStringStart, Directives directives, bool extraWarnings,
|
||||
uint32_t toStringStart, ParseInfo& parseInfo,
|
||||
Directives directives, bool extraWarnings,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
|
||||
JSAtom* explicitName, FunctionFlags flags);
|
||||
|
||||
|
@ -434,12 +440,13 @@ class FunctionBox : public ObjectBox, public SharedContext {
|
|||
}
|
||||
|
||||
FunctionBox(JSContext* cx, TraceListNode* traceListHead, JSFunction* fun,
|
||||
uint32_t toStringStart, Directives directives, bool extraWarnings,
|
||||
uint32_t toStringStart, ParseInfo& parseInfo,
|
||||
Directives directives, bool extraWarnings,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind);
|
||||
|
||||
FunctionBox(JSContext* cx, TraceListNode* traceListHead,
|
||||
Handle<FunctionCreationData> data, uint32_t toStringStart,
|
||||
Directives directives, bool extraWarnings,
|
||||
ParseInfo& parseInfo, Directives directives, bool extraWarnings,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -56,7 +56,8 @@ static int testBinASTReaderFuzz(const uint8_t* buf, size_t size) {
|
|||
}
|
||||
|
||||
Directives directives(false);
|
||||
GlobalSharedContext globalsc(gCx, ScopeKind::Global, directives, false);
|
||||
GlobalSharedContext globalsc(gCx, ScopeKind::Global, binParseInfo, directives,
|
||||
false);
|
||||
|
||||
BinASTParser<js::frontend::BinASTTokenReaderMultipart> reader(
|
||||
gCx, binParseInfo, options, binParseInfo.sourceObject);
|
||||
|
|
|
@ -330,8 +330,8 @@ void runTestFromPath(JSContext* cx, const char* path) {
|
|||
}
|
||||
|
||||
frontend::Directives directives(false);
|
||||
frontend::GlobalSharedContext globalsc(cx, ScopeKind::Global, directives,
|
||||
false);
|
||||
frontend::GlobalSharedContext globalsc(cx, ScopeKind::Global, binParseInfo,
|
||||
directives, false);
|
||||
|
||||
frontend::BinASTParser<Tok> binParser(cx, binParseInfo, binOptions,
|
||||
binParseInfo.sourceObject);
|
||||
|
|
|
@ -5246,7 +5246,8 @@ static bool BinParse(JSContext* cx, unsigned argc, Value* vp) {
|
|||
}
|
||||
|
||||
Directives directives(false);
|
||||
GlobalSharedContext globalsc(cx, ScopeKind::Global, directives, false);
|
||||
GlobalSharedContext globalsc(cx, ScopeKind::Global, parseInfo, directives,
|
||||
false);
|
||||
|
||||
auto parseFunc = mode == Multipart
|
||||
? ParseBinASTData<frontend::BinASTTokenReaderMultipart>
|
||||
|
@ -5351,7 +5352,7 @@ static bool Parse(JSContext* cx, unsigned argc, Value* vp) {
|
|||
|
||||
ModuleBuilder builder(cx, module, &parser);
|
||||
|
||||
ModuleSharedContext modulesc(cx, module, nullptr, builder);
|
||||
ModuleSharedContext modulesc(cx, module, parseInfo, nullptr, builder);
|
||||
pn = parser.moduleBody(&modulesc);
|
||||
}
|
||||
if (!pn) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче