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

Unified Diff: src/parsing/preparser.cc

Issue 2481163002: Assign unique IDs to FunctionLiterals (Closed)
Patch Set: updates Created 4 years, 1 month 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/preparser.cc
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc
index c7b2e1b5d25d6e9537e62989e4a610d6ee47ee68..306fb264d1c17116d189d87aefedbcc65a6a8dbf 100644
--- a/src/parsing/preparser.cc
+++ b/src/parsing/preparser.cc
@@ -92,6 +92,11 @@ PreParser::PreParseResult PreParser::PreParseFunction(
DCHECK(!track_unresolved_variables_);
track_unresolved_variables_ = is_inner_function;
+ // In the preparser, we use the function literal ids to count how many
+ // FunctionLiterals were encountered. The PreParser doesn't actually persist
+ // FunctionLiterals, so there IDs don't matter.
+ ResetFunctionLiteralId();
+
// The caller passes the function_scope which is not yet inserted into the
// scope_state_. All scopes above the function_scope are ignored by the
// PreParser.
@@ -195,6 +200,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
FunctionState function_state(&function_state_, &scope_state_, function_scope);
DuplicateFinder duplicate_finder(scanner()->unicode_cache());
ExpressionClassifier formals_classifier(this, &duplicate_finder);
+ GetNextFunctionLiteralId();
Expect(Token::LPAREN, CHECK_OK);
int start_position = scanner()->location().beg_pos;
@@ -251,10 +257,10 @@ PreParser::LazyParsingResult PreParser::ParseStatementListAndLogFunction(
DCHECK_EQ(Token::RBRACE, scanner()->peek());
int body_end = scanner()->peek_location().end_pos;
DCHECK(this->scope()->is_function_scope());
- log_.LogFunction(body_end, formals->num_parameters(),
- formals->function_length, has_duplicate_parameters,
- function_state_->materialized_literal_count(),
- function_state_->expected_property_count());
+ log_.LogFunction(
+ body_end, formals->num_parameters(), formals->function_length,
+ has_duplicate_parameters, function_state_->materialized_literal_count(),
+ function_state_->expected_property_count(), GetLastFunctionLiteralId());
return kLazyParsingComplete;
}

Powered by Google App Engine
This is Rietveld 408576698