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

Unified Diff: src/parsing/parser.cc

Issue 1895123002: Prevent un-parsed LiteralFunction reaching the compiler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test. (eager_compile_hint used function_state_ of parent function.) Created 4 years, 8 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
« no previous file with comments | « no previous file | src/parsing/parser-base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 53d18fb3e9b9304d1def1dfcd04806924f298231..f0870e5af6eb31c700d0c714b3e2090e6aa93d0b 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -3993,11 +3993,10 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
int materialized_literal_count = -1;
int expected_property_count = -1;
DuplicateFinder duplicate_finder(scanner()->unicode_cache());
- FunctionLiteral::EagerCompileHint eager_compile_hint =
- parenthesized_function_ ? FunctionLiteral::kShouldEagerCompile
- : FunctionLiteral::kShouldLazyCompile;
bool should_be_used_once_hint = false;
bool has_duplicate_parameters;
+ FunctionLiteral::EagerCompileHint eager_compile_hint;
+
// Parse function.
{
AstNodeFactory function_factory(ast_value_factory());
@@ -4006,6 +4005,10 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
scope_->SetScopeName(function_name);
ExpressionClassifier formals_classifier(this, &duplicate_finder);
+ eager_compile_hint = function_state_->this_function_is_parenthesized()
+ ? FunctionLiteral::kShouldEagerCompile
+ : FunctionLiteral::kShouldLazyCompile;
+
if (is_generator) {
// For generators, allocating variables in contexts is currently a win
// because it minimizes the work needed to suspend and resume an
@@ -4074,8 +4077,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
// logic where only top-level functions will be parsed lazily.
bool is_lazily_parsed = mode() == PARSE_LAZILY &&
scope_->AllowsLazyParsing() &&
- !parenthesized_function_;
- parenthesized_function_ = false; // The bit was set for this function only.
+ !function_state_->this_function_is_parenthesized();
// Eager or lazy parse?
// If is_lazily_parsed, we'll parse lazy. If we can set a bookmark, we'll
« no previous file with comments | « no previous file | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698