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