Commit 0405d6ef authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

Revert "[parser] Remove RETURN_IF* part 16"

This reverts commit fd22cfc8.

Reason for revert: Breaking MSAN build, see
https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Linux%20-%20arm64%20-%20sim%20-%20MSAN/23602

Original change's description:
> [parser] Remove RETURN_IF* part 16
> 
> Bug: v8:8363, v8:7926
> Change-Id: I9f0b9e25cf6b47c8ff32451880e348b92ab3cfaa
> Reviewed-on: https://chromium-review.googlesource.com/c/1309760
> Commit-Queue: Toon Verwaest <verwaest@chromium.org>
> Reviewed-by: Igor Sheludko <ishell@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#57172}

TBR=ishell@chromium.org,verwaest@chromium.org

Change-Id: Ic03a669c1a9598c7bd5ca186d783987e91dca5b5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:8363, v8:7926
Reviewed-on: https://chromium-review.googlesource.com/c/1309828Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57175}
parent 162d4e6d
...@@ -449,7 +449,9 @@ class FunctionDeclaration final : public Declaration { ...@@ -449,7 +449,9 @@ class FunctionDeclaration final : public Declaration {
friend class AstNodeFactory; friend class AstNodeFactory;
FunctionDeclaration(VariableProxy* proxy, FunctionLiteral* fun, int pos) FunctionDeclaration(VariableProxy* proxy, FunctionLiteral* fun, int pos)
: Declaration(proxy, pos, kFunctionDeclaration), fun_(fun) {} : Declaration(proxy, pos, kFunctionDeclaration), fun_(fun) {
DCHECK_NOT_NULL(fun);
}
FunctionLiteral* fun_; FunctionLiteral* fun_;
}; };
......
...@@ -1547,7 +1547,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() { ...@@ -1547,7 +1547,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() {
if (impl()->IsEvalOrArguments(name)) { if (impl()->IsEvalOrArguments(name)) {
if (impl()->IsArguments(name) && scope()->ShouldBanArguments()) { if (impl()->IsArguments(name) && scope()->ShouldBanArguments()) {
ReportMessage(MessageTemplate::kArgumentsDisallowedInInitializer); ReportMessage(MessageTemplate::kArgumentsDisallowedInInitializer);
return impl()->EmptyIdentifierString(); return impl()->NullIdentifier();
} }
classifier()->RecordStrictModeFormalParameterError( classifier()->RecordStrictModeFormalParameterError(
...@@ -1575,7 +1575,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() { ...@@ -1575,7 +1575,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() {
return impl()->GetSymbol(); return impl()->GetSymbol();
} else { } else {
ReportUnexpectedToken(next); ReportUnexpectedToken(next);
return impl()->EmptyIdentifierString(); return impl()->NullIdentifier();
} }
} }
...@@ -1594,7 +1594,7 @@ ParserBase<Impl>::ParseIdentifierOrStrictReservedWord( ...@@ -1594,7 +1594,7 @@ ParserBase<Impl>::ParseIdentifierOrStrictReservedWord(
*is_strict_reserved = true; *is_strict_reserved = true;
} else { } else {
ReportUnexpectedToken(next); ReportUnexpectedToken(next);
return impl()->EmptyIdentifierString(); return impl()->NullIdentifier();
} }
return impl()->GetSymbol(); return impl()->GetSymbol();
...@@ -1606,7 +1606,7 @@ typename ParserBase<Impl>::IdentifierT ParserBase<Impl>::ParseIdentifierName() { ...@@ -1606,7 +1606,7 @@ typename ParserBase<Impl>::IdentifierT ParserBase<Impl>::ParseIdentifierName() {
if (!Token::IsAnyIdentifier(next) && next != Token::ESCAPED_KEYWORD && if (!Token::IsAnyIdentifier(next) && next != Token::ESCAPED_KEYWORD &&
!Token::IsKeyword(next)) { !Token::IsKeyword(next)) {
ReportUnexpectedToken(next); ReportUnexpectedToken(next);
return impl()->EmptyIdentifierString(); return impl()->NullIdentifier();
} }
return impl()->GetSymbol(); return impl()->GetSymbol();
...@@ -1628,6 +1628,7 @@ ParserBase<Impl>::ParseIdentifierNameOrPrivateName() { ...@@ -1628,6 +1628,7 @@ ParserBase<Impl>::ParseIdentifierNameOrPrivateName() {
name = ParseIdentifierName(); name = ParseIdentifierName();
key = factory()->NewStringLiteral(name, pos); key = factory()->NewStringLiteral(name, pos);
} }
RETURN_IF_PARSE_ERROR;
impl()->PushLiteralName(name); impl()->PushLiteralName(name);
return key; return key;
} }
...@@ -2130,6 +2131,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName( ...@@ -2130,6 +2131,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName(
if (*kind == ParsePropertyKind::kNotSet) { if (*kind == ParsePropertyKind::kNotSet) {
ParsePropertyKindFromToken(peek(), kind); ParsePropertyKindFromToken(peek(), kind);
} }
RETURN_IF_PARSE_ERROR;
impl()->PushLiteralName(*name); impl()->PushLiteralName(*name);
return is_array_index ? factory()->NewNumberLiteral(index, pos) return is_array_index ? factory()->NewNumberLiteral(index, pos)
: factory()->NewStringLiteral(*name, pos); : factory()->NewStringLiteral(*name, pos);
...@@ -2703,6 +2705,8 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN) { ...@@ -2703,6 +2705,8 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN) {
} }
scope->set_start_position(lhs_beg_pos); scope->set_start_position(lhs_beg_pos);
// TODO(verwaest): Disable DCHECKs in failure mode?
RETURN_IF_PARSE_ERROR;
impl()->DeclareArrowFunctionFormalParameters(&parameters, expression, loc); impl()->DeclareArrowFunctionFormalParameters(&parameters, expression, loc);
expression = expression =
...@@ -3833,6 +3837,8 @@ ParserBase<Impl>::ParseHoistableDeclaration( ...@@ -3833,6 +3837,8 @@ ParserBase<Impl>::ParseHoistableDeclaration(
} }
FuncNameInferrerState fni_state(&fni_); FuncNameInferrerState fni_state(&fni_);
// TODO(verwaest): Remove once we have FailureIdentifier.
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
impl()->PushEnclosingName(name); impl()->PushEnclosingName(name);
FunctionKind kind = FunctionKindFor(flags); FunctionKind kind = FunctionKindFor(flags);
...@@ -3856,6 +3862,7 @@ ParserBase<Impl>::ParseHoistableDeclaration( ...@@ -3856,6 +3862,7 @@ ParserBase<Impl>::ParseHoistableDeclaration(
!scope()->is_declaration_scope() && !scope()->is_declaration_scope() &&
flags == ParseFunctionFlag::kIsNormal; flags == ParseFunctionFlag::kIsNormal;
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
return impl()->DeclareFunction(variable_name, function, mode, pos, return impl()->DeclareFunction(variable_name, function, mode, pos,
is_sloppy_block_function, names); is_sloppy_block_function, names);
} }
...@@ -3897,6 +3904,7 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseClassDeclaration( ...@@ -3897,6 +3904,7 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseClassDeclaration(
ExpressionT value = ParseClassLiteral(name, scanner()->location(), ExpressionT value = ParseClassLiteral(name, scanner()->location(),
is_strict_reserved, class_token_pos); is_strict_reserved, class_token_pos);
int end_pos = position(); int end_pos = position();
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
return impl()->DeclareClass(variable_name, value, names, class_token_pos, return impl()->DeclareClass(variable_name, value, names, class_token_pos,
end_pos); end_pos);
} }
...@@ -4130,7 +4138,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( ...@@ -4130,7 +4138,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
base::ElapsedTimer timer; base::ElapsedTimer timer;
if (V8_UNLIKELY(FLAG_log_function_events)) timer.Start(); if (V8_UNLIKELY(FLAG_log_function_events)) timer.Start();
DCHECK_IMPLIES(!has_error(), peek() == Token::ARROW); DCHECK_EQ(Token::ARROW, peek());
if (scanner_->HasLineTerminatorBeforeNext()) { if (scanner_->HasLineTerminatorBeforeNext()) {
// ASI inserts `;` after arrow parameters if a line terminator is found. // ASI inserts `;` after arrow parameters if a line terminator is found.
// `=> ...` is never a valid expression, so report as syntax error. // `=> ...` is never a valid expression, so report as syntax error.
......
...@@ -2436,7 +2436,7 @@ void Parser::AddArrowFunctionFormalParameters( ...@@ -2436,7 +2436,7 @@ void Parser::AddArrowFunctionFormalParameters(
void Parser::DeclareArrowFunctionFormalParameters( void Parser::DeclareArrowFunctionFormalParameters(
ParserFormalParameters* parameters, Expression* expr, ParserFormalParameters* parameters, Expression* expr,
const Scanner::Location& params_loc) { const Scanner::Location& params_loc) {
if (expr->IsEmptyParentheses() || has_error()) return; if (expr->IsEmptyParentheses()) return;
AddArrowFunctionFormalParameters(parameters, expr, params_loc.end_pos); AddArrowFunctionFormalParameters(parameters, expr, params_loc.end_pos);
...@@ -2446,8 +2446,7 @@ void Parser::DeclareArrowFunctionFormalParameters( ...@@ -2446,8 +2446,7 @@ void Parser::DeclareArrowFunctionFormalParameters(
} }
DeclareFormalParameters(parameters); DeclareFormalParameters(parameters);
DCHECK_IMPLIES(parameters->is_simple, DCHECK_EQ(parameters->is_simple, parameters->scope->has_simple_parameters());
parameters->scope->has_simple_parameters());
} }
void Parser::PrepareGeneratorVariables() { void Parser::PrepareGeneratorVariables() {
......
...@@ -862,6 +862,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { ...@@ -862,6 +862,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
V8_INLINE VariableProxy* ExpressionFromIdentifier( V8_INLINE VariableProxy* ExpressionFromIdentifier(
const AstRawString* name, int start_position, const AstRawString* name, int start_position,
InferName infer = InferName::kYes) { InferName infer = InferName::kYes) {
if (has_error()) return nullptr;
if (infer == InferName::kYes) { if (infer == InferName::kYes) {
fni_.PushVariableName(name); fni_.PushVariableName(name);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment