Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Unified Diff: src/parsing/parser.cc

Issue 2370713003: Preparse functions in the scope that was created when parsing of the function was started (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 16c6b36ab41186307ae09cb3ccd27e0121c8f65a..b46d03171aed81b51b2ae7cf379e3905787f8d7a 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -923,9 +923,12 @@ FunctionLiteral* Parser::DoParseLazy(ParseInfo* info,
{
// Parse the function literal.
Scope* outer = original_scope_;
+ DeclarationScope* outer_function = outer->GetClosureScope();
DCHECK(outer);
- FunctionState function_state(&function_state_, &scope_state_, outer,
- info->function_kind());
+ FunctionState function_state(&function_state_, &scope_state_,
+ outer_function,
+ outer_function->function_kind());
+ BlockState block_state(&scope_state_, outer);
DCHECK(is_sloppy(outer->language_mode()) ||
is_strict(info->language_mode()));
FunctionLiteral::FunctionType function_type = ComputeFunctionType(info);
@@ -2926,7 +2929,7 @@ Parser::LazyParsingResult Parser::SkipLazyFunctionBody(
if (produce_cached_parse_data()) CHECK(log_);
int function_block_pos = position();
- DeclarationScope* scope = this->scope()->AsDeclarationScope();
+ DeclarationScope* scope = function_state_->scope();
DCHECK(scope->is_function_scope());
scope->set_is_lazily_parsed(true);
if (consume_cached_parse_data() && !cached_parse_data_->rejected()) {
@@ -2957,6 +2960,7 @@ Parser::LazyParsingResult Parser::SkipLazyFunctionBody(
SingletonLogger logger;
PreParser::PreParseResult result =
ParseLazyFunctionBodyWithPreParser(&logger, may_abort);
+
// Return immediately if pre-parser decided to abort parsing.
if (result == PreParser::kPreParseAbort) {
scope->set_is_lazily_parsed(false);
@@ -3453,9 +3457,8 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
#undef SET_ALLOW
}
PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction(
- language_mode(), function_state_->kind(),
- scope()->AsDeclarationScope()->has_simple_parameters(), parsing_module_,
- logger, may_abort, use_counts_);
+ function_state_->scope(), parsing_module_, logger, may_abort,
+ use_counts_);
if (pre_parse_timer_ != NULL) {
pre_parse_timer_->Stop();
}

Powered by Google App Engine
This is Rietveld 408576698