Merge V8 5.2.361.47 DO NOT MERGE
https://chromium.googlesource.com/v8/v8/+/5.2.361.47
FPIIM-449
Change-Id: Ibec421b85a9b88cb3a432ada642e469fe7e78346
(cherry picked from commit bcf72ee8e3b26f1d0726869c7ddb3921c68b09a8)
diff --git a/src/parsing/parser.h b/src/parsing/parser.h
index c82682e..174b983 100644
--- a/src/parsing/parser.h
+++ b/src/parsing/parser.h
@@ -125,7 +125,6 @@
// TODO(titzer): these should not be part of ParseInfo.
//--------------------------------------------------------------------------
Isolate* isolate() { return isolate_; }
- Handle<JSFunction> closure() { return closure_; }
Handle<SharedFunctionInfo> shared_info() { return shared_; }
Handle<Script> script() { return script_; }
Handle<Context> context() { return context_; }
@@ -145,7 +144,6 @@
}
void ReopenHandlesInNewHandleScope() {
- closure_ = Handle<JSFunction>(*closure_);
shared_ = Handle<SharedFunctionInfo>(*shared_);
script_ = Handle<Script>(*script_);
context_ = Handle<Context>(*context_);
@@ -186,7 +184,6 @@
// TODO(titzer): Move handles and isolate out of ParseInfo.
Isolate* isolate_;
- Handle<JSFunction> closure_;
Handle<SharedFunctionInfo> shared_;
Handle<Script> script_;
Handle<Context> context_;
@@ -202,8 +199,6 @@
void SetFlag(Flag f) { flags_ |= f; }
void SetFlag(Flag f, bool v) { flags_ = v ? flags_ | f : flags_ & ~f; }
bool GetFlag(Flag f) const { return (flags_ & f) != 0; }
-
- void set_closure(Handle<JSFunction> closure) { closure_ = closure; }
};
class FunctionEntry BASE_EMBEDDED {
@@ -360,6 +355,7 @@
bool IsArguments(const AstRawString* identifier) const;
bool IsEvalOrArguments(const AstRawString* identifier) const;
bool IsUndefined(const AstRawString* identifier) const;
+ bool IsAwait(const AstRawString* identifier) const;
V8_INLINE bool IsFutureStrictReserved(const AstRawString* identifier) const;
// Returns true if the expression is of type "this.foo".
@@ -376,6 +372,12 @@
return expression->AsVariableProxy()->raw_name();
}
+ bool IsDirectEvalCall(Expression* expression) {
+ if (!expression->IsCall()) return false;
+ expression = expression->AsCall()->expression();
+ return IsIdentifier(expression) && IsEval(AsIdentifier(expression));
+ }
+
static bool IsBoilerplateProperty(ObjectLiteral::Property* property) {
return ObjectLiteral::IsBoilerplateProperty(property);
}
@@ -533,7 +535,11 @@
V8_INLINE void AddParameterInitializationBlock(
const ParserFormalParameters& parameters,
- ZoneList<v8::internal::Statement*>* body, bool* ok);
+ ZoneList<v8::internal::Statement*>* body, bool is_async, bool* ok);
+
+ void ParseAsyncArrowSingleExpressionBody(
+ ZoneList<Statement*>* body, bool accept_IN,
+ Type::ExpressionClassifier* classifier, int pos, bool* ok);
V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type,
FunctionKind kind = kNormalFunction);
@@ -546,14 +552,15 @@
Scope* scope, const ParserFormalParameters::Parameter& parameter,
Type::ExpressionClassifier* classifier);
void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters,
- Expression* params,
- const Scanner::Location& params_loc,
+ Expression* params, int end_pos,
bool* ok);
void ParseArrowFunctionFormalParameterList(
ParserFormalParameters* parameters, Expression* params,
const Scanner::Location& params_loc,
Scanner::Location* duplicate_loc, bool* ok);
+ V8_INLINE Expression* ParseAsyncFunctionExpression(bool* ok);
+
V8_INLINE DoExpression* ParseDoExpression(bool* ok);
void ReindexLiterals(const ParserFormalParameters& parameters);
@@ -579,6 +586,7 @@
bool name_is_strict_reserved, int pos,
bool* ok);
+ V8_INLINE void MarkCollectedTailCallExpressions();
V8_INLINE void MarkTailPosition(Expression* expression);
V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope,
@@ -636,6 +644,8 @@
ZoneList<v8::internal::Expression*>* args,
int pos);
+ Expression* ExpressionListToExpression(ZoneList<Expression*>* args);
+
// Rewrite all DestructuringAssignments in the current FunctionState.
V8_INLINE void RewriteDestructuringAssignments();
@@ -644,6 +654,8 @@
V8_INLINE Expression* RewriteAssignExponentiation(Expression* left,
Expression* right, int pos);
+ V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos);
+
V8_INLINE void QueueDestructuringAssignmentForRewriting(
Expression* assignment);
V8_INLINE void QueueNonPatternForRewriting(Expression* expr);
@@ -665,16 +677,14 @@
Expression* RewriteYieldStar(
Expression* generator, Expression* expression, int pos);
- Expression* RewriteInstanceof(Expression* lhs, Expression* rhs, int pos);
-
private:
Parser* parser_;
void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator,
- Maybe<Variable*> input, Variable* output);
- void BuildIteratorCloseForCompletion(
- ZoneList<Statement*>* statements, Variable* iterator,
- Variable* body_threw);
+ Variable* input, Variable* output);
+ void BuildIteratorCloseForCompletion(ZoneList<Statement*>* statements,
+ Variable* iterator,
+ Expression* completion);
Statement* CheckCallable(Variable* var, Expression* error, int pos);
};
@@ -768,8 +778,15 @@
bool* ok);
Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels,
bool* ok);
- Statement* ParseFunctionDeclaration(ZoneList<const AstRawString*>* names,
+ Statement* ParseFunctionDeclaration(bool* ok);
+ Statement* ParseHoistableDeclaration(ZoneList<const AstRawString*>* names,
bool* ok);
+ Statement* ParseHoistableDeclaration(int pos, ParseFunctionFlags flags,
+ ZoneList<const AstRawString*>* names,
+ bool* ok);
+ Statement* ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names,
+ bool* ok);
+ Expression* ParseAsyncFunctionExpression(bool* ok);
Statement* ParseFunctionDeclaration(int pos, bool is_generator,
ZoneList<const AstRawString*>* names,
bool* ok);
@@ -838,8 +855,6 @@
Assignment* assignment,
Scope* scope);
- void set_initializer_position(int pos) { initializer_position_ = pos; }
-
private:
PatternRewriter() {}
@@ -880,6 +895,8 @@
PatternContext SetAssignmentContextIfNeeded(Expression* node);
PatternContext SetInitializerContextIfNeeded(Expression* node);
+ void RewriteParameterScopes(Expression* expr);
+
Variable* CreateTempVar(Expression* value = nullptr);
AstNodeFactory* factory() const { return parser_->factory(); }
@@ -927,8 +944,6 @@
Statement* ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok);
Statement* ParseThrowStatement(bool* ok);
Expression* MakeCatchContext(Handle<String> id, VariableProxy* value);
- class DontCollectExpressionsInTailPositionScope;
- class CollectExpressionsInTailPositionToListScope;
TryStatement* ParseTryStatement(bool* ok);
DebuggerStatement* ParseDebuggerStatement(bool* ok);
// Parse a SubStatement in strict mode, or with an extra block scope in
@@ -948,15 +963,22 @@
// Initialize the components of a for-in / for-of statement.
void InitializeForEachStatement(ForEachStatement* stmt, Expression* each,
- Expression* subject, Statement* body);
+ Expression* subject, Statement* body,
+ int each_keyword_pos);
void InitializeForOfStatement(ForOfStatement* stmt, Expression* each,
Expression* iterable, Statement* body,
- int iterable_pos);
+ int next_result_pos = RelocInfo::kNoPosition);
Statement* DesugarLexicalBindingsInForStatement(
Scope* inner_scope, VariableMode mode,
ZoneList<const AstRawString*>* names, ForStatement* loop, Statement* init,
Expression* cond, Statement* next, Statement* body, bool* ok);
+ void DesugarAsyncFunctionBody(const AstRawString* function_name, Scope* scope,
+ ZoneList<Statement*>* body,
+ Type::ExpressionClassifier* classifier,
+ FunctionKind kind, FunctionBody type,
+ bool accept_IN, int pos, bool* ok);
+
void RewriteDoExpression(Expression* expr, bool* ok);
FunctionLiteral* ParseFunctionLiteral(
@@ -1027,6 +1049,7 @@
Block* BuildParameterInitializationBlock(
const ParserFormalParameters& parameters, bool* ok);
+ Block* BuildRejectPromiseOnException(Block* block);
// Consumes the ending }.
ZoneList<Statement*>* ParseEagerFunctionBody(
@@ -1054,6 +1077,8 @@
void SetLanguageMode(Scope* scope, LanguageMode mode);
void RaiseLanguageMode(LanguageMode mode);
+ V8_INLINE void MarkCollectedTailCallExpressions();
+
V8_INLINE void RewriteDestructuringAssignments();
V8_INLINE Expression* RewriteExponentiation(Expression* left,
@@ -1069,6 +1094,10 @@
friend class InitializerRewriter;
void RewriteParameterInitializer(Expression* expr, Scope* scope);
+ Expression* BuildCreateJSGeneratorObject(int pos, FunctionKind kind);
+ Expression* BuildPromiseResolve(Expression* value, int pos);
+ Expression* BuildPromiseReject(Expression* value, int pos);
+
Scanner scanner_;
PreParser* reusable_preparser_;
Scope* original_scope_; // for ES5 function declarations in sloppy eval
@@ -1238,20 +1267,27 @@
}
}
-
void ParserTraits::AddParameterInitializationBlock(
const ParserFormalParameters& parameters,
- ZoneList<v8::internal::Statement*>* body, bool* ok) {
+ ZoneList<v8::internal::Statement*>* body, bool is_async, bool* ok) {
if (!parameters.is_simple) {
auto* init_block =
parser_->BuildParameterInitializationBlock(parameters, ok);
if (!*ok) return;
+
+ if (is_async) {
+ init_block = parser_->BuildRejectPromiseOnException(init_block);
+ }
+
if (init_block != nullptr) {
body->Add(init_block, parser_->zone());
}
}
}
+Expression* ParserTraits::ParseAsyncFunctionExpression(bool* ok) {
+ return parser_->ParseAsyncFunctionExpression(ok);
+}
DoExpression* ParserTraits::ParseDoExpression(bool* ok) {
return parser_->ParseDoExpression(ok);