Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: src/parsing/parser.cc

Issue 2738153003: [parser] Make reusable_preparser really reusable (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/parser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2765 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 SkipFunctionLiterals(entry.num_inner_functions()); 2776 SkipFunctionLiterals(entry.num_inner_functions());
2777 return kLazyParsingComplete; 2777 return kLazyParsingComplete;
2778 } 2778 }
2779 cached_parse_data_->Reject(); 2779 cached_parse_data_->Reject();
2780 } 2780 }
2781 2781
2782 // With no cached data, we partially parse the function, without building an 2782 // With no cached data, we partially parse the function, without building an
2783 // AST. This gathers the data needed to build a lazy function. 2783 // AST. This gathers the data needed to build a lazy function.
2784 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.PreParse"); 2784 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.PreParse");
2785 2785
2786 if (reusable_preparser_ == NULL) {
2787 reusable_preparser_ = new PreParser(
2788 zone(), &scanner_, stack_limit_, ast_value_factory(),
2789 &pending_error_handler_, runtime_call_stats_, parsing_on_main_thread_);
2790 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name());
2791 SET_ALLOW(natives);
2792 SET_ALLOW(harmony_do_expressions);
2793 SET_ALLOW(harmony_function_sent);
2794 SET_ALLOW(harmony_trailing_commas);
2795 SET_ALLOW(harmony_class_fields);
2796 SET_ALLOW(harmony_object_rest_spread);
2797 SET_ALLOW(harmony_dynamic_import);
2798 SET_ALLOW(harmony_async_iteration);
2799 #undef SET_ALLOW
2800 }
2801 // Aborting inner function preparsing would leave scopes in an inconsistent 2786 // Aborting inner function preparsing would leave scopes in an inconsistent
2802 // state; we don't parse inner functions in the abortable mode anyway. 2787 // state; we don't parse inner functions in the abortable mode anyway.
2803 DCHECK(!is_inner_function || !may_abort); 2788 DCHECK(!is_inner_function || !may_abort);
2804 2789
2805 PreParser::PreParseResult result = reusable_preparser_->PreParseFunction( 2790 PreParser::PreParseResult result = reusable_preparser()->PreParseFunction(
2806 kind, function_scope, parsing_module_, is_inner_function, may_abort, 2791 kind, function_scope, parsing_module_, is_inner_function, may_abort,
2807 use_counts_); 2792 use_counts_);
2808 2793
2809 // Return immediately if pre-parser decided to abort parsing. 2794 // Return immediately if pre-parser decided to abort parsing.
2810 if (result == PreParser::kPreParseAbort) return kLazyParsingAborted; 2795 if (result == PreParser::kPreParseAbort) return kLazyParsingAborted;
2811 if (result == PreParser::kPreParseStackOverflow) { 2796 if (result == PreParser::kPreParseStackOverflow) {
2812 // Propagate stack overflow. 2797 // Propagate stack overflow.
2813 set_stack_overflow(); 2798 set_stack_overflow();
2814 *ok = false; 2799 *ok = false;
2815 return kLazyParsingComplete; 2800 return kLazyParsingComplete;
2816 } 2801 }
2817 if (pending_error_handler_.has_pending_error()) { 2802 if (pending_error_handler_.has_pending_error()) {
2818 *ok = false; 2803 *ok = false;
2819 return kLazyParsingComplete; 2804 return kLazyParsingComplete;
2820 } 2805 }
2821 PreParserLogger* logger = reusable_preparser_->logger(); 2806 PreParserLogger* logger = reusable_preparser()->logger();
2822 function_scope->set_end_position(logger->end()); 2807 function_scope->set_end_position(logger->end());
2823 Expect(Token::RBRACE, CHECK_OK_VALUE(kLazyParsingComplete)); 2808 Expect(Token::RBRACE, CHECK_OK_VALUE(kLazyParsingComplete));
2824 total_preparse_skipped_ += 2809 total_preparse_skipped_ +=
2825 function_scope->end_position() - function_scope->start_position(); 2810 function_scope->end_position() - function_scope->start_position();
2826 *num_parameters = logger->num_parameters(); 2811 *num_parameters = logger->num_parameters();
2827 *function_length = logger->function_length(); 2812 *function_length = logger->function_length();
2828 *has_duplicate_parameters = logger->has_duplicate_parameters(); 2813 *has_duplicate_parameters = logger->has_duplicate_parameters();
2829 *expected_property_count = logger->properties(); 2814 *expected_property_count = logger->properties();
2830 SkipFunctionLiterals(logger->num_inner_functions()); 2815 SkipFunctionLiterals(logger->num_inner_functions());
2831 if (!is_inner_function && produce_cached_parse_data()) { 2816 if (!is_inner_function && produce_cached_parse_data()) {
(...skipping 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after
5048 5033
5049 return final_loop; 5034 return final_loop;
5050 } 5035 }
5051 5036
5052 #undef CHECK_OK 5037 #undef CHECK_OK
5053 #undef CHECK_OK_VOID 5038 #undef CHECK_OK_VOID
5054 #undef CHECK_FAILED 5039 #undef CHECK_FAILED
5055 5040
5056 } // namespace internal 5041 } // namespace internal
5057 } // namespace v8 5042 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698