Commit e91e1804 authored by Florian Sattler's avatar Florian Sattler Committed by Commit Bot

[scanner] Fix apply for bookmarks and usage of scope_data within an error context.

Bug: chromium:897815, chromium:897935, chromium:897766
Change-Id: Ie8c4105867f84054559a4c43c23be82365502c1e
Reviewed-on: https://chromium-review.googlesource.com/c/1296469Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Florian Sattler <sattlerf@google.com>
Cr-Commit-Position: refs/heads/master@{#56905}
parent 71caacc7
...@@ -2745,6 +2745,10 @@ bool Parser::SkipFunction( ...@@ -2745,6 +2745,10 @@ bool Parser::SkipFunction(
LanguageMode language_mode; LanguageMode language_mode;
int num_inner_functions; int num_inner_functions;
bool uses_super_property; bool uses_super_property;
if (stack_overflow()) {
*ok = false;
return true;
}
*produced_preparsed_scope_data = *produced_preparsed_scope_data =
consumed_preparsed_scope_data_->GetDataForSkippableFunction( consumed_preparsed_scope_data_->GetDataForSkippableFunction(
main_zone(), function_scope->start_position(), &end_position, main_zone(), function_scope->start_position(), &end_position,
......
...@@ -147,6 +147,10 @@ void Scanner::BookmarkScope::Set() { ...@@ -147,6 +147,10 @@ void Scanner::BookmarkScope::Set() {
void Scanner::BookmarkScope::Apply() { void Scanner::BookmarkScope::Apply() {
DCHECK(HasBeenSet()); // Caller hasn't called SetBookmark. DCHECK(HasBeenSet()); // Caller hasn't called SetBookmark.
if (had_parser_error_) {
scanner_->set_parser_error();
} else {
scanner_->reset_parser_error_flag();
if (bookmark_ == kBookmarkAtFirstPos) { if (bookmark_ == kBookmarkAtFirstPos) {
scanner_->SeekNext(0); scanner_->SeekNext(0);
} else { } else {
...@@ -154,6 +158,7 @@ void Scanner::BookmarkScope::Apply() { ...@@ -154,6 +158,7 @@ void Scanner::BookmarkScope::Apply() {
scanner_->Next(); scanner_->Next();
DCHECK_EQ(scanner_->location().beg_pos, static_cast<int>(bookmark_)); DCHECK_EQ(scanner_->location().beg_pos, static_cast<int>(bookmark_));
} }
}
bookmark_ = kBookmarkWasApplied; bookmark_ = kBookmarkWasApplied;
} }
......
...@@ -46,7 +46,7 @@ class Utf16CharacterStream { ...@@ -46,7 +46,7 @@ class Utf16CharacterStream {
buffer_cursor_ = buffer_end_; buffer_cursor_ = buffer_end_;
has_parser_error_ = true; has_parser_error_ = true;
} }
void reset_parser_error_flag() { has_parser_error_ = false; }
bool has_parser_error() const { return has_parser_error_; } bool has_parser_error() const { return has_parser_error_; }
inline uc32 Peek() { inline uc32 Peek() {
...@@ -212,7 +212,9 @@ class Scanner { ...@@ -212,7 +212,9 @@ class Scanner {
class BookmarkScope { class BookmarkScope {
public: public:
explicit BookmarkScope(Scanner* scanner) explicit BookmarkScope(Scanner* scanner)
: scanner_(scanner), bookmark_(kNoBookmark) { : scanner_(scanner),
bookmark_(kNoBookmark),
had_parser_error_(scanner->has_parser_error_set()) {
DCHECK_NOT_NULL(scanner_); DCHECK_NOT_NULL(scanner_);
} }
~BookmarkScope() = default; ~BookmarkScope() = default;
...@@ -229,6 +231,7 @@ class Scanner { ...@@ -229,6 +231,7 @@ class Scanner {
Scanner* scanner_; Scanner* scanner_;
size_t bookmark_; size_t bookmark_;
bool had_parser_error_;
DISALLOW_COPY_AND_ASSIGN(BookmarkScope); DISALLOW_COPY_AND_ASSIGN(BookmarkScope);
}; };
...@@ -236,6 +239,7 @@ class Scanner { ...@@ -236,6 +239,7 @@ class Scanner {
// Sets the Scanner into an error state to stop further scanning and terminate // Sets the Scanner into an error state to stop further scanning and terminate
// the parsing by only returning ILLEGAL tokens after that. // the parsing by only returning ILLEGAL tokens after that.
void set_parser_error() { source_->set_parser_error(); } void set_parser_error() { source_->set_parser_error(); }
void reset_parser_error_flag() { source_->reset_parser_error_flag(); }
bool has_parser_error_set() { return source_->has_parser_error(); } bool has_parser_error_set() { return source_->has_parser_error(); }
// Representation of an interval of source positions. // Representation of an interval of source positions.
......
// Copyright 2018 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: --allow-natives-syntax
(function __f_19350() {
function __f_19351() {
function __f_19352() {
}
}
try {
__f_19350();
} catch (e) {}
%OptimizeFunctionOnNextCall(__f_19351)
})();
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