mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-09-09 04:54:33 +00:00
#521: async/await M1185106 part 2
This commit is contained in:
parent
d0348b2d1e
commit
f80a788a3f
@ -636,7 +636,7 @@ BytecodeCompiler::compileFunctionBody(MutableHandleFunction fun,
|
|||||||
ParseNode* fn;
|
ParseNode* fn;
|
||||||
do {
|
do {
|
||||||
Directives newDirectives = directives;
|
Directives newDirectives = directives;
|
||||||
fn = parser->standaloneFunctionBody(fun, formals, generatorKind, directives,
|
fn = parser->standaloneFunctionBody(fun, formals, generatorKind, SyncFunction, directives,
|
||||||
&newDirectives, enclosingStaticScope);
|
&newDirectives, enclosingStaticScope);
|
||||||
if (!fn && !handleParseFailure(newDirectives))
|
if (!fn && !handleParseFailure(newDirectives))
|
||||||
return false;
|
return false;
|
||||||
@ -797,7 +797,7 @@ frontend::CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const cha
|
|||||||
|
|
||||||
Rooted<JSFunction*> fun(cx, lazy->functionNonDelazifying());
|
Rooted<JSFunction*> fun(cx, lazy->functionNonDelazifying());
|
||||||
MOZ_ASSERT(!lazy->isLegacyGenerator());
|
MOZ_ASSERT(!lazy->isLegacyGenerator());
|
||||||
ParseNode* pn = parser.standaloneLazyFunction(fun, lazy->strict(), lazy->generatorKind());
|
ParseNode* pn = parser.standaloneLazyFunction(fun, lazy->strict(), lazy->generatorKind(), lazy->asyncKind());
|
||||||
if (!pn)
|
if (!pn)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1143,6 +1143,7 @@ ParseNode*
|
|||||||
Parser<FullParseHandler>::standaloneFunctionBody(HandleFunction fun,
|
Parser<FullParseHandler>::standaloneFunctionBody(HandleFunction fun,
|
||||||
Handle<PropertyNameVector> formals,
|
Handle<PropertyNameVector> formals,
|
||||||
GeneratorKind generatorKind,
|
GeneratorKind generatorKind,
|
||||||
|
FunctionAsyncKind asyncKind,
|
||||||
Directives inheritedDirectives,
|
Directives inheritedDirectives,
|
||||||
Directives* newDirectives,
|
Directives* newDirectives,
|
||||||
HandleObject enclosingStaticScope)
|
HandleObject enclosingStaticScope)
|
||||||
@ -1158,7 +1159,7 @@ Parser<FullParseHandler>::standaloneFunctionBody(HandleFunction fun,
|
|||||||
return null();
|
return null();
|
||||||
fn->pn_body = argsbody;
|
fn->pn_body = argsbody;
|
||||||
|
|
||||||
FunctionBox* funbox = newFunctionBox(fn, fun, inheritedDirectives, generatorKind, SyncFunction,
|
FunctionBox* funbox = newFunctionBox(fn, fun, inheritedDirectives, generatorKind, asyncKind,
|
||||||
enclosingStaticScope);
|
enclosingStaticScope);
|
||||||
if (!funbox)
|
if (!funbox)
|
||||||
return null();
|
return null();
|
||||||
@ -1609,7 +1610,8 @@ struct BindData
|
|||||||
template <typename ParseHandler>
|
template <typename ParseHandler>
|
||||||
JSFunction*
|
JSFunction*
|
||||||
Parser<ParseHandler>::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
|
Parser<ParseHandler>::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
|
||||||
GeneratorKind generatorKind, HandleObject proto)
|
GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
|
||||||
|
HandleObject proto)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT_IF(kind == Statement, atom != nullptr);
|
MOZ_ASSERT_IF(kind == Statement, atom != nullptr);
|
||||||
|
|
||||||
@ -2718,11 +2720,12 @@ Parser<ParseHandler>::templateLiteral(YieldHandling yieldHandling)
|
|||||||
return nodeList;
|
return nodeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ::functionDefinition */
|
||||||
template <typename ParseHandler>
|
template <typename ParseHandler>
|
||||||
typename ParseHandler::Node
|
typename ParseHandler::Node
|
||||||
Parser<ParseHandler>::functionDef(InHandling inHandling, YieldHandling yieldHandling,
|
Parser<ParseHandler>::functionDef(InHandling inHandling, YieldHandling yieldHandling,
|
||||||
HandlePropertyName funName, FunctionSyntaxKind kind,
|
HandlePropertyName funName, FunctionSyntaxKind kind,
|
||||||
GeneratorKind generatorKind, InvokedPrediction invoked,
|
GeneratorKind generatorKind, FunctionAsyncKind asyncKind, InvokedPrediction invoked,
|
||||||
Node* assignmentForAnnexBOut)
|
Node* assignmentForAnnexBOut)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT_IF(kind == Statement, funName);
|
MOZ_ASSERT_IF(kind == Statement, funName);
|
||||||
@ -2753,7 +2756,7 @@ Parser<ParseHandler>::functionDef(InHandling inHandling, YieldHandling yieldHand
|
|||||||
if (!proto)
|
if (!proto)
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
RootedFunction fun(context, newFunction(funName, kind, generatorKind, proto));
|
RootedFunction fun(context, newFunction(funName, kind, generatorKind, asyncKind, proto));
|
||||||
if (!fun)
|
if (!fun)
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
@ -2768,7 +2771,7 @@ Parser<ParseHandler>::functionDef(InHandling inHandling, YieldHandling yieldHand
|
|||||||
tokenStream.tell(&start);
|
tokenStream.tell(&start);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (functionArgsAndBody(inHandling, pn, fun, kind, generatorKind, directives,
|
if (functionArgsAndBody(inHandling, pn, fun, kind, generatorKind, asyncKind, directives,
|
||||||
&newDirectives))
|
&newDirectives))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -2852,18 +2855,19 @@ Parser<SyntaxParseHandler>::finishFunctionDefinition(Node pn, FunctionBox* funbo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ::trySyntaxParseInnerFunction */
|
||||||
template <>
|
template <>
|
||||||
bool
|
bool
|
||||||
Parser<FullParseHandler>::functionArgsAndBody(InHandling inHandling, ParseNode* pn,
|
Parser<FullParseHandler>::functionArgsAndBody(InHandling inHandling, ParseNode* pn,
|
||||||
HandleFunction fun, FunctionSyntaxKind kind,
|
HandleFunction fun, FunctionSyntaxKind kind,
|
||||||
GeneratorKind generatorKind,
|
GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
|
||||||
Directives inheritedDirectives,
|
Directives inheritedDirectives,
|
||||||
Directives* newDirectives)
|
Directives* newDirectives)
|
||||||
{
|
{
|
||||||
ParseContext<FullParseHandler>* outerpc = pc;
|
ParseContext<FullParseHandler>* outerpc = pc;
|
||||||
|
|
||||||
// Create box for fun->object early to protect against last-ditch GC.
|
// Create box for fun->object early to protect against last-ditch GC.
|
||||||
FunctionBox* funbox = newFunctionBox(pn, fun, pc, inheritedDirectives, generatorKind, SyncFunction);
|
FunctionBox* funbox = newFunctionBox(pn, fun, pc, inheritedDirectives, generatorKind, asyncKind);
|
||||||
if (!funbox)
|
if (!funbox)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -2957,13 +2961,14 @@ bool
|
|||||||
Parser<SyntaxParseHandler>::functionArgsAndBody(InHandling inHandling, Node pn, HandleFunction fun,
|
Parser<SyntaxParseHandler>::functionArgsAndBody(InHandling inHandling, Node pn, HandleFunction fun,
|
||||||
FunctionSyntaxKind kind,
|
FunctionSyntaxKind kind,
|
||||||
GeneratorKind generatorKind,
|
GeneratorKind generatorKind,
|
||||||
|
FunctionAsyncKind asyncKind,
|
||||||
Directives inheritedDirectives,
|
Directives inheritedDirectives,
|
||||||
Directives* newDirectives)
|
Directives* newDirectives)
|
||||||
{
|
{
|
||||||
ParseContext<SyntaxParseHandler>* outerpc = pc;
|
ParseContext<SyntaxParseHandler>* outerpc = pc;
|
||||||
|
|
||||||
// Create box for fun->object early to protect against last-ditch GC.
|
// Create box for fun->object early to protect against last-ditch GC.
|
||||||
FunctionBox* funbox = newFunctionBox(pn, fun, pc, inheritedDirectives, generatorKind, SyncFunction);
|
FunctionBox* funbox = newFunctionBox(pn, fun, pc, inheritedDirectives, generatorKind, asyncKind);
|
||||||
if (!funbox)
|
if (!funbox)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3007,7 +3012,8 @@ Parser<ParseHandler>::appendToCallSiteObj(Node callSiteObj)
|
|||||||
template <>
|
template <>
|
||||||
ParseNode*
|
ParseNode*
|
||||||
Parser<FullParseHandler>::standaloneLazyFunction(HandleFunction fun, bool strict,
|
Parser<FullParseHandler>::standaloneLazyFunction(HandleFunction fun, bool strict,
|
||||||
GeneratorKind generatorKind)
|
GeneratorKind generatorKind,
|
||||||
|
FunctionAsyncKind asyncKind)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(checkOptionsCalled);
|
MOZ_ASSERT(checkOptionsCalled);
|
||||||
|
|
||||||
@ -3022,7 +3028,7 @@ Parser<FullParseHandler>::standaloneLazyFunction(HandleFunction fun, bool strict
|
|||||||
|
|
||||||
RootedObject enclosing(context, fun->lazyScript()->enclosingScope());
|
RootedObject enclosing(context, fun->lazyScript()->enclosingScope());
|
||||||
Directives directives(/* strict = */ strict);
|
Directives directives(/* strict = */ strict);
|
||||||
FunctionBox* funbox = newFunctionBox(pn, fun, directives, generatorKind, SyncFunction, enclosing);
|
FunctionBox* funbox = newFunctionBox(pn, fun, directives, generatorKind, asyncKind, enclosing);
|
||||||
if (!funbox)
|
if (!funbox)
|
||||||
return null();
|
return null();
|
||||||
funbox->length = fun->nargs() - fun->hasRest();
|
funbox->length = fun->nargs() - fun->hasRest();
|
||||||
@ -3230,7 +3236,7 @@ Parser<ParseHandler>::functionStmt(YieldHandling yieldHandling, DefaultHandling
|
|||||||
|
|
||||||
Node assignmentForAnnexB;
|
Node assignmentForAnnexB;
|
||||||
Node fun = functionDef(InAllowed, yieldHandling, name, Statement, generatorKind,
|
Node fun = functionDef(InAllowed, yieldHandling, name, Statement, generatorKind,
|
||||||
PredictUninvoked, &assignmentForAnnexB);
|
SyncFunction, PredictUninvoked, &assignmentForAnnexB);
|
||||||
if (!fun)
|
if (!fun)
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
@ -3288,7 +3294,7 @@ Parser<ParseHandler>::functionExpr(InvokedPrediction invoked)
|
|||||||
}
|
}
|
||||||
|
|
||||||
YieldHandling yieldHandling = generatorKind != NotGenerator ? YieldIsKeyword : YieldIsName;
|
YieldHandling yieldHandling = generatorKind != NotGenerator ? YieldIsKeyword : YieldIsName;
|
||||||
return functionDef(InAllowed, yieldHandling, name, Expression, generatorKind, invoked);
|
return functionDef(InAllowed, yieldHandling, name, Expression, generatorKind, SyncFunction, invoked);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -7752,7 +7758,7 @@ Parser<ParseHandler>::assignExpr(InHandling inHandling, YieldHandling yieldHandl
|
|||||||
if (!tokenStream.peekToken(&ignored, TokenStream::Operand))
|
if (!tokenStream.peekToken(&ignored, TokenStream::Operand))
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
Node arrowFunc = functionDef(inHandling, yieldHandling, nullptr, Arrow, NotGenerator);
|
Node arrowFunc = functionDef(inHandling, yieldHandling, nullptr, Arrow, NotGenerator, SyncFunction);
|
||||||
if (!arrowFunc)
|
if (!arrowFunc)
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
@ -8630,7 +8636,7 @@ Parser<ParseHandler>::generatorComprehensionLambda(GeneratorKind comprehensionKi
|
|||||||
}
|
}
|
||||||
|
|
||||||
RootedFunction fun(context, newFunction(/* atom = */ nullptr, Expression,
|
RootedFunction fun(context, newFunction(/* atom = */ nullptr, Expression,
|
||||||
comprehensionKind, proto));
|
comprehensionKind, SyncFunction, proto));
|
||||||
if (!fun)
|
if (!fun)
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
@ -9876,7 +9882,7 @@ Parser<ParseHandler>::methodDefinition(YieldHandling yieldHandling, PropertyType
|
|||||||
{
|
{
|
||||||
FunctionSyntaxKind kind = FunctionSyntaxKindFromPropertyType(propType);
|
FunctionSyntaxKind kind = FunctionSyntaxKindFromPropertyType(propType);
|
||||||
GeneratorKind generatorKind = GeneratorKindFromPropertyType(propType);
|
GeneratorKind generatorKind = GeneratorKindFromPropertyType(propType);
|
||||||
return functionDef(InAllowed, yieldHandling, funName, kind, generatorKind);
|
return functionDef(InAllowed, yieldHandling, funName, kind, generatorKind, SyncFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ParseHandler>
|
template <typename ParseHandler>
|
||||||
|
@ -612,7 +612,7 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
|||||||
* a function expression).
|
* a function expression).
|
||||||
*/
|
*/
|
||||||
JSFunction* newFunction(HandleAtom atom, FunctionSyntaxKind kind, GeneratorKind generatorKind,
|
JSFunction* newFunction(HandleAtom atom, FunctionSyntaxKind kind, GeneratorKind generatorKind,
|
||||||
HandleObject proto);
|
FunctionAsyncKind asyncKind, HandleObject proto);
|
||||||
|
|
||||||
bool generateBlockId(JSObject* staticScope, uint32_t* blockIdOut) {
|
bool generateBlockId(JSObject* staticScope, uint32_t* blockIdOut) {
|
||||||
if (blockScopes.length() == StmtInfoPC::BlockIdLimit) {
|
if (blockScopes.length() == StmtInfoPC::BlockIdLimit) {
|
||||||
@ -679,12 +679,15 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
|||||||
// Generator constructors.
|
// Generator constructors.
|
||||||
Node standaloneFunctionBody(HandleFunction fun, Handle<PropertyNameVector> formals,
|
Node standaloneFunctionBody(HandleFunction fun, Handle<PropertyNameVector> formals,
|
||||||
GeneratorKind generatorKind,
|
GeneratorKind generatorKind,
|
||||||
|
FunctionAsyncKind asyncKind,
|
||||||
Directives inheritedDirectives, Directives* newDirectives,
|
Directives inheritedDirectives, Directives* newDirectives,
|
||||||
HandleObject enclosingStaticScope);
|
HandleObject enclosingStaticScope);
|
||||||
|
|
||||||
// Parse a function, given only its arguments and body. Used for lazily
|
// Parse a function, given only its arguments and body. Used for lazily
|
||||||
// parsed functions.
|
// parsed functions.
|
||||||
Node standaloneLazyFunction(HandleFunction fun, bool strict, GeneratorKind generatorKind);
|
Node standaloneLazyFunction(HandleFunction fun, bool strict,
|
||||||
|
GeneratorKind generatorKind,
|
||||||
|
FunctionAsyncKind asyncKind);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse a function body. Pass StatementListBody if the body is a list of
|
* Parse a function body. Pass StatementListBody if the body is a list of
|
||||||
@ -882,10 +885,12 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
|||||||
|
|
||||||
Node functionDef(InHandling inHandling, YieldHandling uieldHandling, HandlePropertyName name,
|
Node functionDef(InHandling inHandling, YieldHandling uieldHandling, HandlePropertyName name,
|
||||||
FunctionSyntaxKind kind, GeneratorKind generatorKind,
|
FunctionSyntaxKind kind, GeneratorKind generatorKind,
|
||||||
|
FunctionAsyncKind asyncKind,
|
||||||
InvokedPrediction invoked = PredictUninvoked,
|
InvokedPrediction invoked = PredictUninvoked,
|
||||||
Node* assignmentForAnnexBOut = nullptr);
|
Node* assignmentForAnnexBOut = nullptr);
|
||||||
bool functionArgsAndBody(InHandling inHandling, Node pn, HandleFunction fun,
|
bool functionArgsAndBody(InHandling inHandling, Node pn, HandleFunction fun,
|
||||||
FunctionSyntaxKind kind, GeneratorKind generatorKind,
|
FunctionSyntaxKind kind, GeneratorKind generatorKind,
|
||||||
|
FunctionAsyncKind asyncKind,
|
||||||
Directives inheritedDirectives, Directives* newDirectives);
|
Directives inheritedDirectives, Directives* newDirectives);
|
||||||
|
|
||||||
Node unaryOpExpr(YieldHandling yieldHandling, ParseNodeKind kind, JSOp op, uint32_t begin);
|
Node unaryOpExpr(YieldHandling yieldHandling, ParseNodeKind kind, JSOp op, uint32_t begin);
|
||||||
|
Loading…
Reference in New Issue
Block a user