Backed out changeset 47ce8dbb036e (bug 1356189) for no tests result for own test await-restricted-nested.js on Windows 7 VM opt. r=backout

This commit is contained in:
Sebastian Hengst 2017-06-07 20:27:53 +02:00
parent 4ab8b6f8bc
commit 481ca2cea0
5 changed files with 20 additions and 43 deletions

View File

@ -801,7 +801,7 @@ ParserBase::ParserBase(JSContext* cx, LifoAlloc& alloc,
#endif
abortedSyntaxParse(false),
isUnexpectedEOF_(false),
awaitHandling_(AwaitIsName)
awaitIsKeyword_(false)
{
cx->frontendCollectionPool().addActiveCompilation();
tempPoolMark = alloc.mark();
@ -859,18 +859,18 @@ Parser<ParseHandler, CharT>::~Parser()
template <>
void
Parser<SyntaxParseHandler, char16_t>::setAwaitHandling(AwaitHandling awaitHandling)
Parser<SyntaxParseHandler, char16_t>::setAwaitIsKeyword(bool isKeyword)
{
awaitHandling_ = awaitHandling;
awaitIsKeyword_ = isKeyword;
}
template <>
void
Parser<FullParseHandler, char16_t>::setAwaitHandling(AwaitHandling awaitHandling)
Parser<FullParseHandler, char16_t>::setAwaitIsKeyword(bool isKeyword)
{
awaitHandling_ = awaitHandling;
awaitIsKeyword_ = isKeyword;
if (Parser<SyntaxParseHandler, char16_t>* parser = handler.getSyntaxParser())
parser->setAwaitHandling(awaitHandling);
parser->setAwaitIsKeyword(isKeyword);
}
ObjectBox*
@ -2238,7 +2238,7 @@ Parser<FullParseHandler, char16_t>::moduleBody(ModuleSharedContext* modulesc)
if (!mn)
return null();
AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, AwaitIsModuleKeyword);
AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, true);
ParseNode* pn = statementList(YieldIsKeyword);
if (!pn)
return null();
@ -2506,14 +2506,6 @@ GetYieldHandling(GeneratorKind generatorKind)
return YieldIsKeyword;
}
static AwaitHandling
GetAwaitHandling(FunctionAsyncKind asyncKind)
{
if (asyncKind == SyncFunction)
return AwaitIsName;
return AwaitIsKeyword;
}
template <>
ParseNode*
Parser<FullParseHandler, char16_t>::standaloneFunction(HandleFunction fun,
@ -2574,8 +2566,7 @@ Parser<FullParseHandler, char16_t>::standaloneFunction(HandleFunction fun,
funpc.setIsStandaloneFunctionBody();
YieldHandling yieldHandling = GetYieldHandling(generatorKind);
AwaitHandling awaitHandling = GetAwaitHandling(asyncKind);
AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, awaitHandling);
AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, asyncKind == AsyncFunction);
if (!functionFormalParametersAndBody(InAllowed, yieldHandling, fn, Statement,
parameterListEnd, /* isStandaloneFunction = */ true))
{
@ -3685,10 +3676,8 @@ Parser<ParseHandler, CharT>::functionFormalParametersAndBody(InHandling inHandli
// See below for an explanation why arrow function parameters and arrow
// function bodies are parsed with different yield/await settings.
{
AwaitHandling awaitHandling = funbox->isAsync() || (kind == Arrow && awaitIsKeyword())
? AwaitIsKeyword
: AwaitIsName;
AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, awaitHandling);
bool asyncOrArrowInAsync = funbox->isAsync() || (kind == Arrow && awaitIsKeyword());
AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, asyncOrArrowInAsync);
if (!functionArguments(yieldHandling, kind, pn))
return false;
}
@ -3759,11 +3748,10 @@ Parser<ParseHandler, CharT>::functionFormalParametersAndBody(InHandling inHandli
// Whereas the |yield| in the function body is always parsed as a name.
// The same goes when parsing |await| in arrow functions.
YieldHandling bodyYieldHandling = GetYieldHandling(pc->generatorKind());
AwaitHandling bodyAwaitHandling = GetAwaitHandling(pc->asyncKind());
bool inheritedStrict = pc->sc()->strict();
Node body;
{
AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, bodyAwaitHandling);
AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, funbox->isAsync());
body = functionBody(inHandling, bodyYieldHandling, kind, bodyType);
if (!body)
return false;
@ -3926,7 +3914,7 @@ Parser<ParseHandler, CharT>::functionExpr(uint32_t toStringStart, InvokedPredict
{
MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_FUNCTION));
AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, GetAwaitHandling(asyncKind));
AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, asyncKind == AsyncFunction);
GeneratorKind generatorKind = NotGenerator;
TokenKind tt;
if (!tokenStream.getToken(&tt))

View File

@ -609,7 +609,6 @@ enum class PropertyType {
// we're in a function box -- easier and simpler than passing an extra
// parameter everywhere.
enum YieldHandling { YieldIsName, YieldIsKeyword };
enum AwaitHandling { AwaitIsName, AwaitIsKeyword, AwaitIsModuleKeyword };
enum InHandling { InAllowed, InProhibited };
enum DefaultHandling { NameRequired, AllowDefaultName };
enum TripledotHandling { TripledotAllowed, TripledotProhibited };
@ -816,11 +815,11 @@ class ParserBase : public StrictModeGetter
/* Unexpected end of input, i.e. TOK_EOF not at top-level. */
bool isUnexpectedEOF_:1;
AwaitHandling awaitHandling_:2;
bool awaitIsKeyword_:1;
public:
bool awaitIsKeyword() const {
return awaitHandling_ != AwaitIsName;
return awaitIsKeyword_;
}
ParserBase(JSContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options,
@ -1136,7 +1135,7 @@ class Parser final : public ParserBase, private JS::AutoGCRooter
~Parser();
friend class AutoAwaitIsKeyword<Parser>;
void setAwaitHandling(AwaitHandling awaitHandling);
void setAwaitIsKeyword(bool isKeyword);
bool checkOptions();
@ -1577,21 +1576,17 @@ class MOZ_STACK_CLASS AutoAwaitIsKeyword
{
private:
Parser* parser_;
AwaitHandling oldAwaitHandling_;
bool oldAwaitIsKeyword_;
public:
AutoAwaitIsKeyword(Parser* parser, AwaitHandling awaitHandling) {
AutoAwaitIsKeyword(Parser* parser, bool awaitIsKeyword) {
parser_ = parser;
oldAwaitHandling_ = parser_->awaitHandling_;
// 'await' is always a keyword in module contexts, so we don't modify
// the state when the original handling is AwaitIsModuleKeyword.
if (oldAwaitHandling_ != AwaitIsModuleKeyword)
parser_->setAwaitHandling(awaitHandling);
oldAwaitIsKeyword_ = parser_->awaitIsKeyword_;
parser_->setAwaitIsKeyword(awaitIsKeyword);
}
~AutoAwaitIsKeyword() {
parser_->setAwaitHandling(oldAwaitHandling_);
parser_->setAwaitIsKeyword(oldAwaitIsKeyword_);
}
};

View File

@ -1,6 +0,0 @@
// |reftest| error:SyntaxError module
// 'await' is always a keyword when parsing modules.
function f() {
await;
}