| OLD | NEW |
| 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/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 197 } |
| 198 | 198 |
| 199 // Helper for putting parts of the parse results into a temporary zone when | 199 // Helper for putting parts of the parse results into a temporary zone when |
| 200 // parsing inner function bodies. | 200 // parsing inner function bodies. |
| 201 class DiscardableZoneScope { | 201 class DiscardableZoneScope { |
| 202 public: | 202 public: |
| 203 DiscardableZoneScope(Parser* parser, Zone* temp_zone, bool use_temp_zone) | 203 DiscardableZoneScope(Parser* parser, Zone* temp_zone, bool use_temp_zone) |
| 204 : ast_node_factory_scope_(parser->factory(), temp_zone, use_temp_zone), | 204 : ast_node_factory_scope_(parser->factory(), temp_zone, use_temp_zone), |
| 205 fni_(parser->ast_value_factory_, temp_zone), | 205 fni_(parser->ast_value_factory_, temp_zone), |
| 206 parser_(parser), | 206 parser_(parser), |
| 207 prev_fni_(parser->fni_) { | 207 prev_fni_(parser->fni_), |
| 208 prev_zone_(parser->zone_) { |
| 208 if (use_temp_zone) { | 209 if (use_temp_zone) { |
| 209 parser_->fni_ = &fni_; | 210 parser_->fni_ = &fni_; |
| 211 parser_->zone_ = temp_zone; |
| 210 } | 212 } |
| 211 } | 213 } |
| 212 ~DiscardableZoneScope() { parser_->fni_ = prev_fni_; } | 214 ~DiscardableZoneScope() { |
| 215 parser_->fni_ = prev_fni_; |
| 216 parser_->zone_ = prev_zone_; |
| 217 } |
| 213 | 218 |
| 214 private: | 219 private: |
| 215 AstNodeFactory::BodyScope ast_node_factory_scope_; | 220 AstNodeFactory::BodyScope ast_node_factory_scope_; |
| 216 FuncNameInferrer fni_; | 221 FuncNameInferrer fni_; |
| 217 Parser* parser_; | 222 Parser* parser_; |
| 218 FuncNameInferrer* prev_fni_; | 223 FuncNameInferrer* prev_fni_; |
| 224 Zone* prev_zone_; |
| 225 |
| 226 DISALLOW_COPY_AND_ASSIGN(DiscardableZoneScope); |
| 219 }; | 227 }; |
| 220 | 228 |
| 221 void Parser::SetCachedData(ParseInfo* info) { | 229 void Parser::SetCachedData(ParseInfo* info) { |
| 222 if (compile_options_ == ScriptCompiler::kNoCompileOptions) { | 230 if (compile_options_ == ScriptCompiler::kNoCompileOptions) { |
| 223 cached_parse_data_ = NULL; | 231 cached_parse_data_ = NULL; |
| 224 } else { | 232 } else { |
| 225 DCHECK(info->cached_data() != NULL); | 233 DCHECK(info->cached_data() != NULL); |
| 226 if (compile_options_ == ScriptCompiler::kConsumeParserCache) { | 234 if (compile_options_ == ScriptCompiler::kConsumeParserCache) { |
| 227 cached_parse_data_ = ParseData::FromCachedData(*info->cached_data()); | 235 cached_parse_data_ = ParseData::FromCachedData(*info->cached_data()); |
| 228 } | 236 } |
| (...skipping 4077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4306 // Anonymous functions were passed either the empty symbol or a null | 4314 // Anonymous functions were passed either the empty symbol or a null |
| 4307 // handle as the function name. Remember if we were passed a non-empty | 4315 // handle as the function name. Remember if we were passed a non-empty |
| 4308 // handle to decide whether to invoke function name inference. | 4316 // handle to decide whether to invoke function name inference. |
| 4309 bool should_infer_name = function_name == NULL; | 4317 bool should_infer_name = function_name == NULL; |
| 4310 | 4318 |
| 4311 // We want a non-null handle as the function name. | 4319 // We want a non-null handle as the function name. |
| 4312 if (should_infer_name) { | 4320 if (should_infer_name) { |
| 4313 function_name = ast_value_factory()->empty_string(); | 4321 function_name = ast_value_factory()->empty_string(); |
| 4314 } | 4322 } |
| 4315 | 4323 |
| 4316 Scope* scope = NewFunctionScope(kind); | 4324 FunctionLiteral::EagerCompileHint eager_compile_hint = |
| 4317 SetLanguageMode(scope, language_mode); | 4325 function_state_->next_function_is_parenthesized() |
| 4318 ZoneList<Statement*>* body = NULL; | 4326 ? FunctionLiteral::kShouldEagerCompile |
| 4327 : FunctionLiteral::kShouldLazyCompile; |
| 4328 |
| 4329 // Determine if the function can be parsed lazily. Lazy parsing is |
| 4330 // different from lazy compilation; we need to parse more eagerly than we |
| 4331 // compile. |
| 4332 |
| 4333 // We can only parse lazily if we also compile lazily. The heuristics for lazy |
| 4334 // compilation are: |
| 4335 // - It must not have been prohibited by the caller to Parse (some callers |
| 4336 // need a full AST). |
| 4337 // - The outer scope must allow lazy compilation of inner functions. |
| 4338 // - The function mustn't be a function expression with an open parenthesis |
| 4339 // before; we consider that a hint that the function will be called |
| 4340 // immediately, and it would be a waste of time to make it lazily |
| 4341 // compiled. |
| 4342 // These are all things we can know at this point, without looking at the |
| 4343 // function itself. |
| 4344 |
| 4345 // In addition, we need to distinguish between these cases: |
| 4346 // (function foo() { |
| 4347 // bar = function() { return 1; } |
| 4348 // })(); |
| 4349 // and |
| 4350 // (function foo() { |
| 4351 // var a = 1; |
| 4352 // bar = function() { return a; } |
| 4353 // })(); |
| 4354 |
| 4355 // Now foo will be parsed eagerly and compiled eagerly (optimization: assume |
| 4356 // parenthesis before the function means that it will be called |
| 4357 // immediately). The inner function *must* be parsed eagerly to resolve the |
| 4358 // possible reference to the variable in foo's scope. However, it's possible |
| 4359 // that it will be compiled lazily. |
| 4360 |
| 4361 // To make this additional case work, both Parser and PreParser implement a |
| 4362 // logic where only top-level functions will be parsed lazily. |
| 4363 bool is_lazily_parsed = mode() == PARSE_LAZILY && |
| 4364 this->scope()->AllowsLazyParsing() && |
| 4365 !function_state_->next_function_is_parenthesized(); |
| 4366 |
| 4367 // Determine whether the function body can be discarded after parsing. |
| 4368 // The preconditions are: |
| 4369 // - Lazy compilation has to be enabled. |
| 4370 // - Neither V8 natives nor native function declarations can be allowed, |
| 4371 // since parsing one would retroactively force the function to be |
| 4372 // eagerly compiled. |
| 4373 // - The invoker of this parser can't depend on the AST being eagerly |
| 4374 // built (either because the function is about to be compiled, or |
| 4375 // because the AST is going to be inspected for some reason). |
| 4376 // - Because of the above, we can't be attempting to parse a |
| 4377 // FunctionExpression; even without enclosing parentheses it might be |
| 4378 // immediately invoked. |
| 4379 // - The function literal shouldn't be hinted to eagerly compile. |
| 4380 // - For asm.js functions the body needs to be available when module |
| 4381 // validation is active, because we examine the entire module at once. |
| 4382 bool use_temp_zone = |
| 4383 !is_lazily_parsed && FLAG_lazy && !allow_natives() && |
| 4384 extension_ == NULL && allow_lazy() && |
| 4385 function_type == FunctionLiteral::kDeclaration && |
| 4386 eager_compile_hint != FunctionLiteral::kShouldEagerCompile && |
| 4387 !(FLAG_validate_asm && scope()->asm_module()); |
| 4388 |
| 4389 Scope* main_scope = nullptr; |
| 4390 if (use_temp_zone) { |
| 4391 // This Scope lives in the main Zone; we'll migrate data into it later. |
| 4392 main_scope = NewFunctionScope(kind); |
| 4393 } |
| 4394 |
| 4395 ZoneList<Statement*>* body = nullptr; |
| 4319 int arity = -1; | 4396 int arity = -1; |
| 4320 int materialized_literal_count = -1; | 4397 int materialized_literal_count = -1; |
| 4321 int expected_property_count = -1; | 4398 int expected_property_count = -1; |
| 4322 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 4399 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
| 4323 bool should_be_used_once_hint = false; | 4400 bool should_be_used_once_hint = false; |
| 4324 bool has_duplicate_parameters; | 4401 bool has_duplicate_parameters; |
| 4325 FunctionLiteral::EagerCompileHint eager_compile_hint; | |
| 4326 | 4402 |
| 4327 // Parse function. | |
| 4328 { | 4403 { |
| 4404 // Temporary zones can nest. When we migrate free variables (see below), we |
| 4405 // need to recreate them in the previous Zone. |
| 4406 AstNodeFactory previous_zone_ast_node_factory(ast_value_factory()); |
| 4407 previous_zone_ast_node_factory.set_zone(zone()); |
| 4408 |
| 4409 // Open a new zone scope, which sets our AstNodeFactory to allocate in the |
| 4410 // new temporary zone if the preconditions are satisfied, and ensures that |
| 4411 // the previous zone is always restored after parsing the body. To be able |
| 4412 // to do scope analysis correctly after full parsing, we migrate needed |
| 4413 // information from scope into main_scope when the function has been parsed. |
| 4414 Zone temp_zone(zone()->allocator()); |
| 4415 DiscardableZoneScope zone_scope(this, &temp_zone, use_temp_zone); |
| 4416 |
| 4417 Scope* scope = NewFunctionScope(kind); |
| 4418 SetLanguageMode(scope, language_mode); |
| 4419 if (!use_temp_zone) { |
| 4420 main_scope = scope; |
| 4421 } else { |
| 4422 DCHECK(main_scope->zone() != scope->zone()); |
| 4423 } |
| 4424 |
| 4329 FunctionState function_state(&function_state_, &scope_state_, scope, kind); | 4425 FunctionState function_state(&function_state_, &scope_state_, scope, kind); |
| 4330 #ifdef DEBUG | 4426 #ifdef DEBUG |
| 4331 this->scope()->SetScopeName(function_name); | 4427 this->scope()->SetScopeName(function_name); |
| 4332 #endif | 4428 #endif |
| 4333 ExpressionClassifier formals_classifier(this, &duplicate_finder); | 4429 ExpressionClassifier formals_classifier(this, &duplicate_finder); |
| 4334 | 4430 |
| 4335 eager_compile_hint = function_state_->this_function_is_parenthesized() | |
| 4336 ? FunctionLiteral::kShouldEagerCompile | |
| 4337 : FunctionLiteral::kShouldLazyCompile; | |
| 4338 | |
| 4339 if (is_generator) { | 4431 if (is_generator) { |
| 4340 // For generators, allocating variables in contexts is currently a win | 4432 // For generators, allocating variables in contexts is currently a win |
| 4341 // because it minimizes the work needed to suspend and resume an | 4433 // because it minimizes the work needed to suspend and resume an |
| 4342 // activation. The machine code produced for generators (by full-codegen) | 4434 // activation. The machine code produced for generators (by full-codegen) |
| 4343 // relies on this forced context allocation, but not in an essential way. | 4435 // relies on this forced context allocation, but not in an essential way. |
| 4344 this->scope()->ForceContextAllocation(); | 4436 this->scope()->ForceContextAllocation(); |
| 4345 | 4437 |
| 4346 // Calling a generator returns a generator object. That object is stored | 4438 // Calling a generator returns a generator object. That object is stored |
| 4347 // in a temporary variable, a definition that is used by "yield" | 4439 // in a temporary variable, a definition that is used by "yield" |
| 4348 // expressions. This also marks the FunctionState as a generator. | 4440 // expressions. This also marks the FunctionState as a generator. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4361 int formals_end_position = scanner()->location().end_pos; | 4453 int formals_end_position = scanner()->location().end_pos; |
| 4362 | 4454 |
| 4363 CheckArityRestrictions(arity, kind, formals.has_rest, start_position, | 4455 CheckArityRestrictions(arity, kind, formals.has_rest, start_position, |
| 4364 formals_end_position, CHECK_OK); | 4456 formals_end_position, CHECK_OK); |
| 4365 Expect(Token::LBRACE, CHECK_OK); | 4457 Expect(Token::LBRACE, CHECK_OK); |
| 4366 // Don't include the rest parameter into the function's formal parameter | 4458 // Don't include the rest parameter into the function's formal parameter |
| 4367 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count, | 4459 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count, |
| 4368 // which says whether we need to create an arguments adaptor frame). | 4460 // which says whether we need to create an arguments adaptor frame). |
| 4369 if (formals.has_rest) arity--; | 4461 if (formals.has_rest) arity--; |
| 4370 | 4462 |
| 4371 // Determine if the function can be parsed lazily. Lazy parsing is different | |
| 4372 // from lazy compilation; we need to parse more eagerly than we compile. | |
| 4373 | |
| 4374 // We can only parse lazily if we also compile lazily. The heuristics for | |
| 4375 // lazy compilation are: | |
| 4376 // - It must not have been prohibited by the caller to Parse (some callers | |
| 4377 // need a full AST). | |
| 4378 // - The outer scope must allow lazy compilation of inner functions. | |
| 4379 // - The function mustn't be a function expression with an open parenthesis | |
| 4380 // before; we consider that a hint that the function will be called | |
| 4381 // immediately, and it would be a waste of time to make it lazily | |
| 4382 // compiled. | |
| 4383 // These are all things we can know at this point, without looking at the | |
| 4384 // function itself. | |
| 4385 | |
| 4386 // In addition, we need to distinguish between these cases: | |
| 4387 // (function foo() { | |
| 4388 // bar = function() { return 1; } | |
| 4389 // })(); | |
| 4390 // and | |
| 4391 // (function foo() { | |
| 4392 // var a = 1; | |
| 4393 // bar = function() { return a; } | |
| 4394 // })(); | |
| 4395 | |
| 4396 // Now foo will be parsed eagerly and compiled eagerly (optimization: assume | |
| 4397 // parenthesis before the function means that it will be called | |
| 4398 // immediately). The inner function *must* be parsed eagerly to resolve the | |
| 4399 // possible reference to the variable in foo's scope. However, it's possible | |
| 4400 // that it will be compiled lazily. | |
| 4401 | |
| 4402 // To make this additional case work, both Parser and PreParser implement a | |
| 4403 // logic where only top-level functions will be parsed lazily. | |
| 4404 bool is_lazily_parsed = mode() == PARSE_LAZILY && | |
| 4405 this->scope()->AllowsLazyParsing() && | |
| 4406 !function_state_->this_function_is_parenthesized(); | |
| 4407 | |
| 4408 // Eager or lazy parse? | 4463 // Eager or lazy parse? |
| 4409 // If is_lazily_parsed, we'll parse lazy. If we can set a bookmark, we'll | 4464 // If is_lazily_parsed, we'll parse lazy. If we can set a bookmark, we'll |
| 4410 // pass it to SkipLazyFunctionBody, which may use it to abort lazy | 4465 // pass it to SkipLazyFunctionBody, which may use it to abort lazy |
| 4411 // parsing if it suspect that wasn't a good idea. If so, or if we didn't | 4466 // parsing if it suspect that wasn't a good idea. If so, or if we didn't |
| 4412 // try to lazy parse in the first place, we'll have to parse eagerly. | 4467 // try to lazy parse in the first place, we'll have to parse eagerly. |
| 4413 Scanner::BookmarkScope bookmark(scanner()); | 4468 Scanner::BookmarkScope bookmark(scanner()); |
| 4414 if (is_lazily_parsed) { | 4469 if (is_lazily_parsed) { |
| 4415 Scanner::BookmarkScope* maybe_bookmark = | 4470 Scanner::BookmarkScope* maybe_bookmark = |
| 4416 bookmark.Set() ? &bookmark : nullptr; | 4471 bookmark.Set() ? &bookmark : nullptr; |
| 4417 SkipLazyFunctionBody(&materialized_literal_count, | 4472 SkipLazyFunctionBody(&materialized_literal_count, |
| 4418 &expected_property_count, /*CHECK_OK*/ ok, | 4473 &expected_property_count, /*CHECK_OK*/ ok, |
| 4419 maybe_bookmark); | 4474 maybe_bookmark); |
| 4420 | 4475 |
| 4421 materialized_literal_count += formals.materialized_literals_count + | 4476 materialized_literal_count += formals.materialized_literals_count + |
| 4422 function_state.materialized_literal_count(); | 4477 function_state.materialized_literal_count(); |
| 4423 | 4478 |
| 4424 if (bookmark.HasBeenReset()) { | 4479 if (bookmark.HasBeenReset()) { |
| 4425 // Trigger eager (re-)parsing, just below this block. | 4480 // Trigger eager (re-)parsing, just below this block. |
| 4426 is_lazily_parsed = false; | 4481 is_lazily_parsed = false; |
| 4427 | 4482 |
| 4428 // This is probably an initialization function. Inform the compiler it | 4483 // This is probably an initialization function. Inform the compiler it |
| 4429 // should also eager-compile this function, and that we expect it to be | 4484 // should also eager-compile this function, and that we expect it to be |
| 4430 // used once. | 4485 // used once. |
| 4431 eager_compile_hint = FunctionLiteral::kShouldEagerCompile; | 4486 eager_compile_hint = FunctionLiteral::kShouldEagerCompile; |
| 4432 should_be_used_once_hint = true; | 4487 should_be_used_once_hint = true; |
| 4433 } | 4488 } |
| 4434 } | 4489 } |
| 4435 if (!is_lazily_parsed) { | 4490 if (!is_lazily_parsed) { |
| 4436 // Determine whether the function body can be discarded after parsing. | 4491 body = ParseEagerFunctionBody(function_name, pos, formals, kind, |
| 4437 // The preconditions are: | 4492 function_type, CHECK_OK); |
| 4438 // - Lazy compilation has to be enabled. | 4493 |
| 4439 // - Neither V8 natives nor native function declarations can be allowed, | |
| 4440 // since parsing one would retroactively force the function to be | |
| 4441 // eagerly compiled. | |
| 4442 // - The invoker of this parser can't depend on the AST being eagerly | |
| 4443 // built (either because the function is about to be compiled, or | |
| 4444 // because the AST is going to be inspected for some reason). | |
| 4445 // - Because of the above, we can't be attempting to parse a | |
| 4446 // FunctionExpression; even without enclosing parentheses it might be | |
| 4447 // immediately invoked. | |
| 4448 // - The function literal shouldn't be hinted to eagerly compile. | |
| 4449 // - For asm.js functions the body needs to be available when module | |
| 4450 // validation is active, because we examine the entire module at once. | |
| 4451 bool use_temp_zone = | |
| 4452 FLAG_lazy && !allow_natives() && extension_ == NULL && allow_lazy() && | |
| 4453 function_type == FunctionLiteral::kDeclaration && | |
| 4454 eager_compile_hint != FunctionLiteral::kShouldEagerCompile && | |
| 4455 !(FLAG_validate_asm && scope->asm_function()); | |
| 4456 // Open a new zone scope, which sets our AstNodeFactory to allocate in the | |
| 4457 // new temporary zone if the preconditions are satisfied, and ensures that | |
| 4458 // the previous zone is always restored after parsing the body. | |
| 4459 // For the purpose of scope analysis, some ZoneObjects allocated by the | |
| 4460 // factory must persist after the function body is thrown away and | |
| 4461 // temp_zone is deallocated. These objects are instead allocated in a | |
| 4462 // parser-persistent zone (see parser_zone_ in AstNodeFactory). | |
| 4463 { | |
| 4464 Zone temp_zone(zone()->allocator()); | |
| 4465 DiscardableZoneScope zone_scope(this, &temp_zone, use_temp_zone); | |
| 4466 body = ParseEagerFunctionBody(function_name, pos, formals, kind, | |
| 4467 function_type, CHECK_OK); | |
| 4468 } | |
| 4469 materialized_literal_count = function_state.materialized_literal_count(); | 4494 materialized_literal_count = function_state.materialized_literal_count(); |
| 4470 expected_property_count = function_state.expected_property_count(); | 4495 expected_property_count = function_state.expected_property_count(); |
| 4471 if (use_temp_zone) { | 4496 if (use_temp_zone) { |
| 4472 // If the preconditions are correct the function body should never be | 4497 // If the preconditions are correct the function body should never be |
| 4473 // accessed, but do this anyway for better behaviour if they're wrong. | 4498 // accessed, but do this anyway for better behaviour if they're wrong. |
| 4474 body = NULL; | 4499 body = nullptr; |
| 4475 } | 4500 } |
| 4476 } | 4501 } |
| 4477 | 4502 |
| 4478 // Parsing the body may change the language mode in our scope. | 4503 // Parsing the body may change the language mode in our scope. |
| 4479 language_mode = scope->language_mode(); | 4504 language_mode = scope->language_mode(); |
| 4480 | 4505 |
| 4481 // Validate name and parameter names. We can do this only after parsing the | 4506 // Validate name and parameter names. We can do this only after parsing the |
| 4482 // function, since the function can declare itself strict. | 4507 // function, since the function can declare itself strict. |
| 4483 CheckFunctionName(language_mode, function_name, function_name_validity, | 4508 CheckFunctionName(language_mode, function_name, function_name_validity, |
| 4484 function_name_location, CHECK_OK); | 4509 function_name_location, CHECK_OK); |
| 4485 const bool allow_duplicate_parameters = | 4510 const bool allow_duplicate_parameters = |
| 4486 is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind); | 4511 is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind); |
| 4487 ValidateFormalParameters(&formals_classifier, language_mode, | 4512 ValidateFormalParameters(&formals_classifier, language_mode, |
| 4488 allow_duplicate_parameters, CHECK_OK); | 4513 allow_duplicate_parameters, CHECK_OK); |
| 4489 | 4514 |
| 4490 if (is_strict(language_mode)) { | 4515 if (is_strict(language_mode)) { |
| 4491 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), | 4516 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), |
| 4492 CHECK_OK); | 4517 CHECK_OK); |
| 4493 CheckDecimalLiteralWithLeadingZero(use_counts_, scope->start_position(), | 4518 CheckDecimalLiteralWithLeadingZero(use_counts_, scope->start_position(), |
| 4494 scope->end_position()); | 4519 scope->end_position()); |
| 4495 } | 4520 } |
| 4496 CheckConflictingVarDeclarations(scope, CHECK_OK); | 4521 CheckConflictingVarDeclarations(scope, CHECK_OK); |
| 4497 | 4522 |
| 4498 if (body) { | 4523 if (body) { |
| 4499 // If body can be inspected, rewrite queued destructuring assignments | 4524 // If body can be inspected, rewrite queued destructuring assignments |
| 4500 ParserTraits::RewriteDestructuringAssignments(); | 4525 ParserTraits::RewriteDestructuringAssignments(); |
| 4501 } | 4526 } |
| 4502 has_duplicate_parameters = | 4527 has_duplicate_parameters = |
| 4503 !formals_classifier.is_valid_formal_parameter_list_without_duplicates(); | 4528 !formals_classifier.is_valid_formal_parameter_list_without_duplicates(); |
| 4504 } | 4529 |
| 4530 if (use_temp_zone) { |
| 4531 DCHECK(main_scope != scope); |
| 4532 scope->AnalyzePartially(main_scope, &previous_zone_ast_node_factory); |
| 4533 } |
| 4534 } // DiscardableZoneScope goes out of scope. |
| 4505 | 4535 |
| 4506 FunctionLiteral::ParameterFlag duplicate_parameters = | 4536 FunctionLiteral::ParameterFlag duplicate_parameters = |
| 4507 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters | 4537 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters |
| 4508 : FunctionLiteral::kNoDuplicateParameters; | 4538 : FunctionLiteral::kNoDuplicateParameters; |
| 4509 | 4539 |
| 4540 // Note that the FunctionLiteral needs to be created in the main Zone again. |
| 4510 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( | 4541 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( |
| 4511 function_name, scope, body, materialized_literal_count, | 4542 function_name, main_scope, body, materialized_literal_count, |
| 4512 expected_property_count, arity, duplicate_parameters, function_type, | 4543 expected_property_count, arity, duplicate_parameters, function_type, |
| 4513 eager_compile_hint, kind, pos); | 4544 eager_compile_hint, kind, pos); |
| 4514 function_literal->set_function_token_position(function_token_pos); | 4545 function_literal->set_function_token_position(function_token_pos); |
| 4515 if (should_be_used_once_hint) | 4546 if (should_be_used_once_hint) |
| 4516 function_literal->set_should_be_used_once_hint(); | 4547 function_literal->set_should_be_used_once_hint(); |
| 4517 | 4548 |
| 4518 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); | 4549 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); |
| 4519 return function_literal; | 4550 return function_literal; |
| 4520 } | 4551 } |
| 4521 | 4552 |
| (...skipping 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7121 node->Print(Isolate::Current()); | 7152 node->Print(Isolate::Current()); |
| 7122 } | 7153 } |
| 7123 #endif // DEBUG | 7154 #endif // DEBUG |
| 7124 | 7155 |
| 7125 #undef CHECK_OK | 7156 #undef CHECK_OK |
| 7126 #undef CHECK_OK_VOID | 7157 #undef CHECK_OK_VOID |
| 7127 #undef CHECK_FAILED | 7158 #undef CHECK_FAILED |
| 7128 | 7159 |
| 7129 } // namespace internal | 7160 } // namespace internal |
| 7130 } // namespace v8 | 7161 } // namespace v8 |
| OLD | NEW |