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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 AstNodeFactory::BodyScope ast_node_factory_scope_; | 143 AstNodeFactory::BodyScope ast_node_factory_scope_; |
144 FuncNameInferrer fni_; | 144 FuncNameInferrer fni_; |
145 Parser* parser_; | 145 Parser* parser_; |
146 FuncNameInferrer* prev_fni_; | 146 FuncNameInferrer* prev_fni_; |
147 Zone* prev_zone_; | 147 Zone* prev_zone_; |
148 | 148 |
149 DISALLOW_COPY_AND_ASSIGN(DiscardableZoneScope); | 149 DISALLOW_COPY_AND_ASSIGN(DiscardableZoneScope); |
150 }; | 150 }; |
151 | 151 |
152 void Parser::SetCachedData(ParseInfo* info) { | 152 void Parser::SetCachedData(ParseInfo* info) { |
153 if (compile_options_ == ScriptCompiler::kNoCompileOptions) { | 153 DCHECK_NULL(cached_parse_data_); |
154 cached_parse_data_ = NULL; | 154 if (consume_cached_parse_data()) { |
155 } else { | 155 cached_parse_data_ = ParseData::FromCachedData(*info->cached_data()); |
156 DCHECK(info->cached_data() != NULL); | 156 if (cached_parse_data_ == nullptr) { |
157 if (compile_options_ == ScriptCompiler::kConsumeParserCache) { | 157 compile_options_ = ScriptCompiler::kNoCompileOptions; |
158 cached_parse_data_ = ParseData::FromCachedData(*info->cached_data()); | |
159 } | 158 } |
160 } | 159 } |
161 } | 160 } |
162 | 161 |
163 Expression* Parser::CallClassFieldInitializer(Scope* scope, | 162 Expression* Parser::CallClassFieldInitializer(Scope* scope, |
164 Expression* this_expr) { | 163 Expression* this_expr) { |
165 // This produces the expression | 164 // This produces the expression |
166 // `.class_field_intializer(this_expr)`, where '.class_field_intializer' is | 165 // `.class_field_intializer(this_expr)`, where '.class_field_intializer' is |
167 // the name | 166 // the name |
168 // of a synthetic variable. | 167 // of a synthetic variable. |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 } | 630 } |
632 | 631 |
633 Parser::Parser(ParseInfo* info) | 632 Parser::Parser(ParseInfo* info) |
634 : ParserBase<Parser>(info->zone(), &scanner_, info->stack_limit(), | 633 : ParserBase<Parser>(info->zone(), &scanner_, info->stack_limit(), |
635 info->extension(), info->ast_value_factory(), NULL), | 634 info->extension(), info->ast_value_factory(), NULL), |
636 scanner_(info->unicode_cache()), | 635 scanner_(info->unicode_cache()), |
637 reusable_preparser_(NULL), | 636 reusable_preparser_(NULL), |
638 original_scope_(NULL), | 637 original_scope_(NULL), |
639 target_stack_(NULL), | 638 target_stack_(NULL), |
640 compile_options_(info->compile_options()), | 639 compile_options_(info->compile_options()), |
641 cached_parse_data_(NULL), | 640 cached_parse_data_(nullptr), |
642 total_preparse_skipped_(0), | 641 total_preparse_skipped_(0), |
643 pre_parse_timer_(NULL), | 642 pre_parse_timer_(NULL), |
644 parsing_on_main_thread_(true) { | 643 parsing_on_main_thread_(true) { |
645 // Even though we were passed ParseInfo, we should not store it in | 644 // Even though we were passed ParseInfo, we should not store it in |
646 // Parser - this makes sure that Isolate is not accidentally accessed via | 645 // Parser - this makes sure that Isolate is not accidentally accessed via |
647 // ParseInfo during background parsing. | 646 // ParseInfo during background parsing. |
648 DCHECK(!info->script().is_null() || info->source_stream() != nullptr || | 647 DCHECK(!info->script().is_null() || info->source_stream() != nullptr || |
649 info->character_stream() != nullptr); | 648 info->character_stream() != nullptr); |
650 // Determine if functions can be lazily compiled. This is necessary to | 649 // Determine if functions can be lazily compiled. This is necessary to |
651 // allow some of our builtin JS files to be lazily compiled. These | 650 // allow some of our builtin JS files to be lazily compiled. These |
(...skipping 10 matching lines...) Expand all Loading... |
662 can_compile_lazily &= !(FLAG_serialize_eager && info->will_serialize()); | 661 can_compile_lazily &= !(FLAG_serialize_eager && info->will_serialize()); |
663 | 662 |
664 // Consider compiling eagerly when compiling bytecode for Ignition. | 663 // Consider compiling eagerly when compiling bytecode for Ignition. |
665 can_compile_lazily &= !(FLAG_ignition && FLAG_ignition_eager && | 664 can_compile_lazily &= !(FLAG_ignition && FLAG_ignition_eager && |
666 info->isolate()->serializer_enabled()); | 665 info->isolate()->serializer_enabled()); |
667 | 666 |
668 set_default_eager_compile_hint(can_compile_lazily | 667 set_default_eager_compile_hint(can_compile_lazily |
669 ? FunctionLiteral::kShouldLazyCompile | 668 ? FunctionLiteral::kShouldLazyCompile |
670 : FunctionLiteral::kShouldEagerCompile); | 669 : FunctionLiteral::kShouldEagerCompile); |
671 set_allow_lazy(FLAG_lazy && info->allow_lazy_parsing() && | 670 set_allow_lazy(FLAG_lazy && info->allow_lazy_parsing() && |
672 !info->is_native() && info->extension() == nullptr); | 671 !info->is_native() && info->extension() == nullptr && |
| 672 can_compile_lazily); |
673 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); | 673 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); |
674 set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && | 674 set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && |
675 info->isolate()->is_tail_call_elimination_enabled()); | 675 info->isolate()->is_tail_call_elimination_enabled()); |
676 set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); | 676 set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); |
677 set_allow_harmony_function_sent(FLAG_harmony_function_sent); | 677 set_allow_harmony_function_sent(FLAG_harmony_function_sent); |
678 set_allow_harmony_restrictive_declarations( | 678 set_allow_harmony_restrictive_declarations( |
679 FLAG_harmony_restrictive_declarations); | 679 FLAG_harmony_restrictive_declarations); |
680 set_allow_harmony_async_await(FLAG_harmony_async_await); | 680 set_allow_harmony_async_await(FLAG_harmony_async_await); |
681 set_allow_harmony_restrictive_generators(FLAG_harmony_restrictive_generators); | 681 set_allow_harmony_restrictive_generators(FLAG_harmony_restrictive_generators); |
682 set_allow_harmony_trailing_commas(FLAG_harmony_trailing_commas); | 682 set_allow_harmony_trailing_commas(FLAG_harmony_trailing_commas); |
(...skipping 4759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5442 | 5442 |
5443 return final_loop; | 5443 return final_loop; |
5444 } | 5444 } |
5445 | 5445 |
5446 #undef CHECK_OK | 5446 #undef CHECK_OK |
5447 #undef CHECK_OK_VOID | 5447 #undef CHECK_OK_VOID |
5448 #undef CHECK_FAILED | 5448 #undef CHECK_FAILED |
5449 | 5449 |
5450 } // namespace internal | 5450 } // namespace internal |
5451 } // namespace v8 | 5451 } // namespace v8 |
OLD | NEW |