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

Side by Side Diff: src/parser.cc

Issue 1354523003: Fix temp_zone scoping when parsing inner function literals (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « src/ast.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/parser.h" 5 #include "src/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/ast-literal-reindexer.h" 9 #include "src/ast-literal-reindexer.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 4206 matching lines...) Expand 10 before | Expand all | Expand 10 after
4217 // - Neither V8 natives nor native function declarations can be allowed, 4217 // - Neither V8 natives nor native function declarations can be allowed,
4218 // since parsing one would retroactively force the function to be 4218 // since parsing one would retroactively force the function to be
4219 // eagerly compiled. 4219 // eagerly compiled.
4220 // - The invoker of this parser can't depend on the AST being eagerly 4220 // - The invoker of this parser can't depend on the AST being eagerly
4221 // built (either because the function is about to be compiled, or 4221 // built (either because the function is about to be compiled, or
4222 // because the AST is going to be inspected for some reason). 4222 // because the AST is going to be inspected for some reason).
4223 // - Because of the above, we can't be attempting to parse a 4223 // - Because of the above, we can't be attempting to parse a
4224 // FunctionExpression; even without enclosing parentheses it might be 4224 // FunctionExpression; even without enclosing parentheses it might be
4225 // immediately invoked. 4225 // immediately invoked.
4226 // - The function literal shouldn't be hinted to eagerly compile. 4226 // - The function literal shouldn't be hinted to eagerly compile.
4227 bool can_use_temp_zone = 4227 bool use_temp_zone =
4228 FLAG_lazy && !allow_natives() && extension_ == NULL && allow_lazy() && 4228 FLAG_lazy && !allow_natives() && extension_ == NULL && allow_lazy() &&
4229 function_type == FunctionLiteral::DECLARATION && 4229 function_type == FunctionLiteral::DECLARATION &&
4230 eager_compile_hint != FunctionLiteral::kShouldEagerCompile; 4230 eager_compile_hint != FunctionLiteral::kShouldEagerCompile;
4231 // Open a new BodyScope, which sets our AstNodeFactory to allocate in the 4231 // Open a new BodyScope, which sets our AstNodeFactory to allocate in the
4232 // new temporary zone if the preconditions are satisfied, and ensures that 4232 // new temporary zone if the preconditions are satisfied, and ensures that
4233 // the previous zone is always restored after parsing the body. 4233 // the previous zone is always restored after parsing the body.
4234 // For the purpose of scope analysis, some ZoneObjects allocated by the 4234 // For the purpose of scope analysis, some ZoneObjects allocated by the
4235 // factory must persist after the function body is thrown away and 4235 // factory must persist after the function body is thrown away and
4236 // temp_zone is deallocated. These objects are instead allocated in a 4236 // temp_zone is deallocated. These objects are instead allocated in a
4237 // parser-persistent zone (see parser_zone_ in AstNodeFactory). 4237 // parser-persistent zone (see parser_zone_ in AstNodeFactory).
4238 { 4238 {
4239 Zone temp_zone; 4239 Zone temp_zone;
4240 AstNodeFactory::BodyScope(factory(), &temp_zone, can_use_temp_zone); 4240 AstNodeFactory::BodyScope inner(factory(), &temp_zone, use_temp_zone);
4241 4241
4242 body = ParseEagerFunctionBody(function_name, pos, formals, kind, 4242 body = ParseEagerFunctionBody(function_name, pos, formals, kind,
4243 function_type, CHECK_OK); 4243 function_type, CHECK_OK);
4244 } 4244 }
4245 materialized_literal_count = function_state.materialized_literal_count(); 4245 materialized_literal_count = function_state.materialized_literal_count();
4246 expected_property_count = function_state.expected_property_count(); 4246 expected_property_count = function_state.expected_property_count();
4247 if (can_use_temp_zone) { 4247 if (use_temp_zone) {
4248 // If the preconditions are correct the function body should never be 4248 // If the preconditions are correct the function body should never be
4249 // accessed, but do this anyway for better behaviour if they're wrong. 4249 // accessed, but do this anyway for better behaviour if they're wrong.
4250 body = NULL; 4250 body = NULL;
4251 } 4251 }
4252 } 4252 }
4253 4253
4254 // Parsing the body may change the language mode in our scope. 4254 // Parsing the body may change the language mode in our scope.
4255 language_mode = scope->language_mode(); 4255 language_mode = scope->language_mode();
4256 4256
4257 if (is_strong(language_mode) && IsSubclassConstructor(kind)) { 4257 if (is_strong(language_mode) && IsSubclassConstructor(kind)) {
(...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after
6243 6243
6244 Expression* Parser::SpreadCallNew(Expression* function, 6244 Expression* Parser::SpreadCallNew(Expression* function,
6245 ZoneList<v8::internal::Expression*>* args, 6245 ZoneList<v8::internal::Expression*>* args,
6246 int pos) { 6246 int pos) {
6247 args->InsertAt(0, function, zone()); 6247 args->InsertAt(0, function, zone());
6248 6248
6249 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); 6249 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos);
6250 } 6250 }
6251 } // namespace internal 6251 } // namespace internal
6252 } // namespace v8 6252 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698