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-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 &RuntimeCallStats::ParseFunction); | 848 &RuntimeCallStats::ParseFunction); |
849 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.ParseFunction"); | 849 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.ParseFunction"); |
850 Handle<String> source(String::cast(info->script()->source())); | 850 Handle<String> source(String::cast(info->script()->source())); |
851 isolate->counters()->total_parse_size()->Increment(source->length()); | 851 isolate->counters()->total_parse_size()->Increment(source->length()); |
852 base::ElapsedTimer timer; | 852 base::ElapsedTimer timer; |
853 if (FLAG_trace_parse) { | 853 if (FLAG_trace_parse) { |
854 timer.Start(); | 854 timer.Start(); |
855 } | 855 } |
856 Handle<SharedFunctionInfo> shared_info = info->shared_info(); | 856 Handle<SharedFunctionInfo> shared_info = info->shared_info(); |
857 DeserializeScopeChain(info, info->maybe_outer_scope_info()); | 857 DeserializeScopeChain(info, info->maybe_outer_scope_info()); |
858 if (info->asm_function_scope()) { | |
titzer
2016/11/28 10:40:11
Also fishy. I am not sure why we have to manually
bradn
2016/11/29 06:30:35
Agreed.
I had tried instead to set the outer funct
| |
859 original_scope_ = info->asm_function_scope(); | |
860 } | |
858 | 861 |
859 // Initialize parser state. | 862 // Initialize parser state. |
860 source = String::Flatten(source); | 863 source = String::Flatten(source); |
861 FunctionLiteral* result; | 864 FunctionLiteral* result; |
862 { | 865 { |
863 std::unique_ptr<Utf16CharacterStream> stream(ScannerStream::For( | 866 std::unique_ptr<Utf16CharacterStream> stream(ScannerStream::For( |
864 source, shared_info->start_position(), shared_info->end_position())); | 867 source, shared_info->start_position(), shared_info->end_position())); |
865 Handle<String> name(String::cast(shared_info->name())); | 868 Handle<String> name(String::cast(shared_info->name())); |
866 result = DoParseFunction(info, ast_value_factory()->GetString(name), | 869 result = DoParseFunction(info, ast_value_factory()->GetString(name), |
867 stream.get()); | 870 stream.get()); |
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2603 // - Neither V8 natives nor native function declarations can be allowed, | 2606 // - Neither V8 natives nor native function declarations can be allowed, |
2604 // since parsing one would retroactively force the function to be | 2607 // since parsing one would retroactively force the function to be |
2605 // eagerly compiled. | 2608 // eagerly compiled. |
2606 // - The invoker of this parser can't depend on the AST being eagerly | 2609 // - The invoker of this parser can't depend on the AST being eagerly |
2607 // built (either because the function is about to be compiled, or | 2610 // built (either because the function is about to be compiled, or |
2608 // because the AST is going to be inspected for some reason). | 2611 // because the AST is going to be inspected for some reason). |
2609 // - Because of the above, we can't be attempting to parse a | 2612 // - Because of the above, we can't be attempting to parse a |
2610 // FunctionExpression; even without enclosing parentheses it might be | 2613 // FunctionExpression; even without enclosing parentheses it might be |
2611 // immediately invoked. | 2614 // immediately invoked. |
2612 // - The function literal shouldn't be hinted to eagerly compile. | 2615 // - The function literal shouldn't be hinted to eagerly compile. |
2613 // - For asm.js functions the body needs to be available when module | |
2614 // validation is active, because we examine the entire module at once. | |
2615 | 2616 |
2616 // Inner functions will be parsed using a temporary Zone. After parsing, we | 2617 // Inner functions will be parsed using a temporary Zone. After parsing, we |
2617 // will migrate unresolved variable into a Scope in the main Zone. | 2618 // will migrate unresolved variable into a Scope in the main Zone. |
2618 // TODO(marja): Refactor parsing modes: simplify this. | 2619 // TODO(marja): Refactor parsing modes: simplify this. |
2619 bool use_temp_zone = | 2620 bool use_temp_zone = |
2620 (FLAG_lazy_inner_functions | 2621 (FLAG_lazy_inner_functions |
2621 ? can_preparse | 2622 ? can_preparse |
2622 : (is_lazy_top_level_function || | 2623 : (is_lazy_top_level_function || |
2623 (allow_lazy_ && function_type == FunctionLiteral::kDeclaration && | 2624 (allow_lazy_ && function_type == FunctionLiteral::kDeclaration && |
2624 eager_compile_hint == FunctionLiteral::kShouldLazyCompile))) && | 2625 eager_compile_hint == FunctionLiteral::kShouldLazyCompile))); |
2625 !(FLAG_validate_asm && scope()->IsAsmModule()); | |
2626 bool is_lazy_inner_function = | 2626 bool is_lazy_inner_function = |
2627 use_temp_zone && FLAG_lazy_inner_functions && !is_lazy_top_level_function; | 2627 use_temp_zone && FLAG_lazy_inner_functions && !is_lazy_top_level_function; |
2628 | 2628 |
2629 ZoneList<Statement*>* body = nullptr; | 2629 ZoneList<Statement*>* body = nullptr; |
2630 int materialized_literal_count = -1; | 2630 int materialized_literal_count = -1; |
2631 int expected_property_count = -1; | 2631 int expected_property_count = -1; |
2632 bool should_be_used_once_hint = false; | 2632 bool should_be_used_once_hint = false; |
2633 int num_parameters = -1; | 2633 int num_parameters = -1; |
2634 int function_length = -1; | 2634 int function_length = -1; |
2635 bool has_duplicate_parameters = false; | 2635 bool has_duplicate_parameters = false; |
(...skipping 2836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5472 | 5472 |
5473 return final_loop; | 5473 return final_loop; |
5474 } | 5474 } |
5475 | 5475 |
5476 #undef CHECK_OK | 5476 #undef CHECK_OK |
5477 #undef CHECK_OK_VOID | 5477 #undef CHECK_OK_VOID |
5478 #undef CHECK_FAILED | 5478 #undef CHECK_FAILED |
5479 | 5479 |
5480 } // namespace internal | 5480 } // namespace internal |
5481 } // namespace v8 | 5481 } // namespace v8 |
OLD | NEW |