| 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 "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
| 10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
| (...skipping 4402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4413 // FunctionExpression; even without enclosing parentheses it might be | 4413 // FunctionExpression; even without enclosing parentheses it might be |
| 4414 // immediately invoked. | 4414 // immediately invoked. |
| 4415 // - The function literal shouldn't be hinted to eagerly compile. | 4415 // - The function literal shouldn't be hinted to eagerly compile. |
| 4416 // - For asm.js functions the body needs to be available when module | 4416 // - For asm.js functions the body needs to be available when module |
| 4417 // validation is active, because we examine the entire module at once. | 4417 // validation is active, because we examine the entire module at once. |
| 4418 bool use_temp_zone = | 4418 bool use_temp_zone = |
| 4419 FLAG_lazy && !allow_natives() && extension_ == NULL && allow_lazy() && | 4419 FLAG_lazy && !allow_natives() && extension_ == NULL && allow_lazy() && |
| 4420 function_type == FunctionLiteral::kDeclaration && | 4420 function_type == FunctionLiteral::kDeclaration && |
| 4421 eager_compile_hint != FunctionLiteral::kShouldEagerCompile && | 4421 eager_compile_hint != FunctionLiteral::kShouldEagerCompile && |
| 4422 !(FLAG_validate_asm && scope->asm_function()); | 4422 !(FLAG_validate_asm && scope->asm_function()); |
| 4423 // Open a new BodyScope, which sets our AstNodeFactory to allocate in the | 4423 // Open a new zone scope, which sets our AstNodeFactory to allocate in the |
| 4424 // new temporary zone if the preconditions are satisfied, and ensures that | 4424 // new temporary zone if the preconditions are satisfied, and ensures that |
| 4425 // the previous zone is always restored after parsing the body. | 4425 // the previous zone is always restored after parsing the body. |
| 4426 // For the purpose of scope analysis, some ZoneObjects allocated by the | 4426 // For the purpose of scope analysis, some ZoneObjects allocated by the |
| 4427 // factory must persist after the function body is thrown away and | 4427 // factory must persist after the function body is thrown away and |
| 4428 // temp_zone is deallocated. These objects are instead allocated in a | 4428 // temp_zone is deallocated. These objects are instead allocated in a |
| 4429 // parser-persistent zone (see parser_zone_ in AstNodeFactory). | 4429 // parser-persistent zone (see parser_zone_ in AstNodeFactory). |
| 4430 { | 4430 { |
| 4431 Zone temp_zone(zone()->allocator()); | 4431 Zone temp_zone(zone()->allocator()); |
| 4432 AstNodeFactory::BodyScope inner(factory(), &temp_zone, use_temp_zone); | 4432 DiscardableZoneScope(this, &temp_zone, use_temp_zone); |
| 4433 | |
| 4434 body = ParseEagerFunctionBody(function_name, pos, formals, kind, | 4433 body = ParseEagerFunctionBody(function_name, pos, formals, kind, |
| 4435 function_type, CHECK_OK); | 4434 function_type, CHECK_OK); |
| 4436 } | 4435 } |
| 4437 materialized_literal_count = function_state.materialized_literal_count(); | 4436 materialized_literal_count = function_state.materialized_literal_count(); |
| 4438 expected_property_count = function_state.expected_property_count(); | 4437 expected_property_count = function_state.expected_property_count(); |
| 4439 if (use_temp_zone) { | 4438 if (use_temp_zone) { |
| 4440 // If the preconditions are correct the function body should never be | 4439 // If the preconditions are correct the function body should never be |
| 4441 // accessed, but do this anyway for better behaviour if they're wrong. | 4440 // accessed, but do this anyway for better behaviour if they're wrong. |
| 4442 body = NULL; | 4441 body = NULL; |
| 4443 } | 4442 } |
| (...skipping 2618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7062 | 7061 |
| 7063 #ifdef DEBUG | 7062 #ifdef DEBUG |
| 7064 void Parser::Print(AstNode* node) { | 7063 void Parser::Print(AstNode* node) { |
| 7065 ast_value_factory()->Internalize(Isolate::Current()); | 7064 ast_value_factory()->Internalize(Isolate::Current()); |
| 7066 node->Print(Isolate::Current()); | 7065 node->Print(Isolate::Current()); |
| 7067 } | 7066 } |
| 7068 #endif // DEBUG | 7067 #endif // DEBUG |
| 7069 | 7068 |
| 7070 } // namespace internal | 7069 } // namespace internal |
| 7071 } // namespace v8 | 7070 } // namespace v8 |
| OLD | NEW |