[parser] Alternative fix to chromium:899495

If PreParser::ParseFormalParameterList detects a stack overflow, make
PreParseFunction actually return kPreParseStackOverflow.

BUG=chromium:899495

Change-Id: I1f347b56c594c6edd25401b8448ff38117e190a9
Reviewed-on: https://chromium-review.googlesource.com/c/1304536
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57103}
This commit is contained in:
Marja Hölttä 2018-10-29 15:47:36 +01:00 committed by Commit Bot
parent 9348047a87
commit 43cdd62e6c
3 changed files with 11 additions and 5 deletions

View File

@ -2835,6 +2835,7 @@ bool Parser::SkipFunction(
// Propagate stack overflow.
set_stack_overflow();
} else if (pending_error_handler()->has_error_unidentifiable_by_preparser()) {
DCHECK(!pending_error_handler()->stack_overflow());
// If we encounter an error that the preparser can not identify we reset to
// the state before preparsing. The caller may then fully parse the function
// to identify the actual error.
@ -2843,8 +2844,10 @@ bool Parser::SkipFunction(
pending_error_handler()->clear_unidentifiable_error();
return false;
} else if (pending_error_handler()->has_pending_error()) {
DCHECK(!pending_error_handler()->stack_overflow());
DCHECK(scanner()->has_parser_error());
} else {
DCHECK(!pending_error_handler()->stack_overflow());
set_allow_eval_cache(reusable_preparser()->allow_eval_cache());
PreParserLogger* logger = reusable_preparser()->logger();

View File

@ -159,10 +159,14 @@ PreParser::PreParseResult PreParser::PreParseFunction(
// We return kPreParseSuccess in failure cases too - errors are retrieved
// separately by Parser::SkipLazyFunctionBody.
ParseFormalParameterList(&formals);
RETURN_IF_PARSE_ERROR_VALUE(
pending_error_handler()->has_error_unidentifiable_by_preparser()
? kPreParseNotIdentifiableError
: kPreParseSuccess);
if (pending_error_handler()->stack_overflow()) {
return kPreParseStackOverflow;
} else if (pending_error_handler()
->has_error_unidentifiable_by_preparser()) {
return kPreParseNotIdentifiableError;
} else if (scanner()->has_parser_error()) {
return kPreParseSuccess;
}
Expect(Token::RPAREN);
RETURN_IF_PARSE_ERROR_VALUE(kPreParseSuccess);
int formals_end_position = scanner()->location().end_pos;

View File

@ -66,7 +66,6 @@ class PendingCompilationErrorHandler {
void clear_unidentifiable_error() {
has_pending_error_ = false;
unidentifiable_error_ = false;
stack_overflow_ = false;
}
bool has_error_unidentifiable_by_preparser() const {
return unidentifiable_error_;