From 6b962ddf01f404a51deed683b3a88ea19276107c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 9 Oct 2019 11:18:25 +0200 Subject: [PATCH] deps: patch V8 to 7.8.279.15 Refs: https://github.com/v8/v8/compare/7.8.279.14...7.8.279.15 PR-URL: https://github.com/nodejs/node/pull/29899 Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Gus Caplan Reviewed-By: Jiawen Geng --- deps/v8/include/v8-version.h | 2 +- deps/v8/src/ast/scopes.cc | 1 + deps/v8/src/parsing/expression-scope.h | 8 ++-- deps/v8/src/parsing/parser-base.h | 45 +++++++++++++------ deps/v8/src/parsing/parser.cc | 19 +++----- deps/v8/src/parsing/parser.h | 3 +- deps/v8/src/parsing/preparser.h | 10 ++--- .../mjsunit/regress/regress-crbug-1009728.js | 15 +++++++ .../regress/regress-crbug-1011596-module.mjs | 8 ++++ .../mjsunit/regress/regress-crbug-1011596.mjs | 5 +++ 10 files changed, 75 insertions(+), 41 deletions(-) create mode 100644 deps/v8/test/mjsunit/regress/regress-crbug-1009728.js create mode 100644 deps/v8/test/mjsunit/regress/regress-crbug-1011596-module.mjs create mode 100644 deps/v8/test/mjsunit/regress/regress-crbug-1011596.mjs diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 09afd6248c377f..000be3a739a616 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 7 #define V8_MINOR_VERSION 8 #define V8_BUILD_NUMBER 279 -#define V8_PATCH_LEVEL 14 +#define V8_PATCH_LEVEL 15 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/ast/scopes.cc b/deps/v8/src/ast/scopes.cc index c4d09999785ba7..c8002dd088c9c7 100644 --- a/deps/v8/src/ast/scopes.cc +++ b/deps/v8/src/ast/scopes.cc @@ -1396,6 +1396,7 @@ void Scope::AnalyzePartially(DeclarationScope* max_outer_scope, for (VariableProxy* proxy = scope->unresolved_list_.first(); proxy != nullptr; proxy = proxy->next_unresolved()) { + if (proxy->is_removed_from_unresolved()) continue; DCHECK(!proxy->is_resolved()); Variable* var = Lookup(proxy, scope, max_outer_scope->outer_scope()); diff --git a/deps/v8/src/parsing/expression-scope.h b/deps/v8/src/parsing/expression-scope.h index 43bf754150fc92..ba931d36dab2e2 100644 --- a/deps/v8/src/parsing/expression-scope.h +++ b/deps/v8/src/parsing/expression-scope.h @@ -538,6 +538,10 @@ class ExpressionParsingScope : public ExpressionScope { return end; } + ScopedList>* variable_list() { + return &variable_list_; + } + protected: bool is_verified() const { #ifdef DEBUG @@ -549,10 +553,6 @@ class ExpressionParsingScope : public ExpressionScope { void ValidatePattern() { Validate(kPatternIndex); } - ScopedList>* variable_list() { - return &variable_list_; - } - private: friend class AccumulationScope; diff --git a/deps/v8/src/parsing/parser-base.h b/deps/v8/src/parsing/parser-base.h index f43496b429cd5f..1b3bd64cddf25a 100644 --- a/deps/v8/src/parsing/parser-base.h +++ b/deps/v8/src/parsing/parser-base.h @@ -5062,20 +5062,37 @@ ParserBase::ParseExpressionOrLabelledStatement( } bool starts_with_identifier = peek_any_identifier(); - ExpressionT expr = ParseExpression(); - if (peek() == Token::COLON && starts_with_identifier && - impl()->IsIdentifier(expr)) { - // The whole expression was a single identifier, and not, e.g., - // something starting with an identifier or a parenthesized identifier. - impl()->DeclareLabel(&labels, &own_labels, - impl()->AsIdentifierExpression(expr)); - Consume(Token::COLON); - // ES#sec-labelled-function-declarations Labelled Function Declarations - if (peek() == Token::FUNCTION && is_sloppy(language_mode()) && - allow_function == kAllowLabelledFunctionStatement) { - return ParseFunctionDeclaration(); - } - return ParseStatement(labels, own_labels, allow_function); + + ExpressionT expr; + { + // Effectively inlines ParseExpression, so potential labels can be extracted + // from expression_scope. + ExpressionParsingScope expression_scope(impl()); + AcceptINScope scope(this, true); + expr = ParseExpressionCoverGrammar(); + expression_scope.ValidateExpression(); + + if (peek() == Token::COLON && starts_with_identifier && + impl()->IsIdentifier(expr)) { + // The whole expression was a single identifier, and not, e.g., + // something starting with an identifier or a parenthesized identifier. + DCHECK_EQ(expression_scope.variable_list()->length(), 1); + VariableProxy* label = expression_scope.variable_list()->at(0).first; + impl()->DeclareLabel(&labels, &own_labels, label->raw_name()); + + // Remove the "ghost" variable that turned out to be a label from the top + // scope. This way, we don't try to resolve it during the scope + // processing. + this->scope()->DeleteUnresolved(label); + + Consume(Token::COLON); + // ES#sec-labelled-function-declarations Labelled Function Declarations + if (peek() == Token::FUNCTION && is_sloppy(language_mode()) && + allow_function == kAllowLabelledFunctionStatement) { + return ParseFunctionDeclaration(); + } + return ParseStatement(labels, own_labels, allow_function); + } } // If we have an extension, we allow a native function declaration. diff --git a/deps/v8/src/parsing/parser.cc b/deps/v8/src/parsing/parser.cc index e1bebc71f04bad..3a61253db5a193 100644 --- a/deps/v8/src/parsing/parser.cc +++ b/deps/v8/src/parsing/parser.cc @@ -1489,15 +1489,11 @@ Statement* Parser::DeclareNative(const AstRawString* name, int pos) { void Parser::DeclareLabel(ZonePtrList** labels, ZonePtrList** own_labels, - VariableProxy* var) { - DCHECK(IsIdentifier(var)); - const AstRawString* label = var->raw_name(); - - // TODO(1240780): We don't check for redeclaration of labels - // during preparsing since keeping track of the set of active - // labels requires nontrivial changes to the way scopes are - // structured. However, these are probably changes we want to - // make later anyway so we should go back and fix this then. + const AstRawString* label) { + // TODO(1240780): We don't check for redeclaration of labels during preparsing + // since keeping track of the set of active labels requires nontrivial changes + // to the way scopes are structured. However, these are probably changes we + // want to make later anyway so we should go back and fix this then. if (ContainsLabel(*labels, label) || TargetStackContainsLabel(label)) { ReportMessage(MessageTemplate::kLabelRedeclaration, label); return; @@ -1515,11 +1511,6 @@ void Parser::DeclareLabel(ZonePtrList** labels, } (*labels)->Add(label, zone()); (*own_labels)->Add(label, zone()); - - // Remove the "ghost" variable that turned out to be a label - // from the top scope. This way, we don't try to resolve it - // during the scope processing. - scope()->DeleteUnresolved(var); } bool Parser::ContainsLabel(ZonePtrList* labels, diff --git a/deps/v8/src/parsing/parser.h b/deps/v8/src/parsing/parser.h index 8170dbb9207aa2..2bd555e88141b3 100644 --- a/deps/v8/src/parsing/parser.h +++ b/deps/v8/src/parsing/parser.h @@ -8,6 +8,7 @@ #include #include "src/ast/ast-source-ranges.h" +#include "src/ast/ast-value-factory.h" #include "src/ast/ast.h" #include "src/ast/scopes.h" #include "src/base/compiler-specific.h" @@ -273,7 +274,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase) { Statement* BuildInitializationBlock(DeclarationParsingResult* parsing_result); void DeclareLabel(ZonePtrList** labels, ZonePtrList** own_labels, - VariableProxy* expr); + const AstRawString* label); bool ContainsLabel(ZonePtrList* labels, const AstRawString* label); Expression* RewriteReturn(Expression* return_value, int pos); diff --git a/deps/v8/src/parsing/preparser.h b/deps/v8/src/parsing/preparser.h index d7c2a92dfa09e5..b4d66d726fdd44 100644 --- a/deps/v8/src/parsing/preparser.h +++ b/deps/v8/src/parsing/preparser.h @@ -5,6 +5,7 @@ #ifndef V8_PARSING_PREPARSER_H_ #define V8_PARSING_PREPARSER_H_ +#include "src/ast/ast-value-factory.h" #include "src/ast/ast.h" #include "src/ast/scopes.h" #include "src/parsing/parser-base.h" @@ -1071,9 +1072,8 @@ class PreParser : public ParserBase { V8_INLINE void DeclareLabel(ZonePtrList** labels, ZonePtrList** own_labels, - const PreParserExpression& expr) { - DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait()); - DCHECK(IsIdentifier(expr)); + const AstRawString* label) { + DCHECK(!parsing_module_ || !label->IsOneByteEqualTo("await")); } // TODO(nikolaos): The preparser currently does not keep track of labels. @@ -1323,10 +1323,6 @@ class PreParser : public ParserBase { return identifier.IsEvalOrArguments(); } - V8_INLINE bool IsAwait(const PreParserIdentifier& identifier) const { - return identifier.IsAwait(); - } - // Returns true if the expression is of type "this.foo". V8_INLINE static bool IsThisProperty(const PreParserExpression& expression) { return expression.IsThisProperty(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-1009728.js b/deps/v8/test/mjsunit/regress/regress-crbug-1009728.js new file mode 100644 index 00000000000000..2632368910cca0 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-1009728.js @@ -0,0 +1,15 @@ +// Copyright 2019 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --stress-lazy-source-positions + +function foo(x) { + (function bar() { + { + x: 1 + } + function f() {} + }); +} +foo(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-1011596-module.mjs b/deps/v8/test/mjsunit/regress/regress-crbug-1011596-module.mjs new file mode 100644 index 00000000000000..2ad389f7a07479 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-1011596-module.mjs @@ -0,0 +1,8 @@ +// Copyright 2019 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +export function foo() { + { label: 1 } + return 42; +} diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-1011596.mjs b/deps/v8/test/mjsunit/regress/regress-crbug-1011596.mjs new file mode 100644 index 00000000000000..c223a3a1b5fcf6 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-1011596.mjs @@ -0,0 +1,5 @@ +// Copyright 2019 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import "./regress-crbug-1011596-module.mjs"