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

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

Issue 2505453003: Inline ParseFunctionWithPreParser into SkipFunction (Closed)
Patch Set: merge Created 4 years, 1 month 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 2764 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 *materialized_literal_count = entry.literal_count(); 2775 *materialized_literal_count = entry.literal_count();
2776 *expected_property_count = entry.property_count(); 2776 *expected_property_count = entry.property_count();
2777 SetLanguageMode(function_scope, entry.language_mode()); 2777 SetLanguageMode(function_scope, entry.language_mode());
2778 if (entry.uses_super_property()) 2778 if (entry.uses_super_property())
2779 function_scope->RecordSuperPropertyUsage(); 2779 function_scope->RecordSuperPropertyUsage();
2780 if (entry.calls_eval()) function_scope->RecordEvalCall(); 2780 if (entry.calls_eval()) function_scope->RecordEvalCall();
2781 return kLazyParsingComplete; 2781 return kLazyParsingComplete;
2782 } 2782 }
2783 cached_parse_data_->Reject(); 2783 cached_parse_data_->Reject();
2784 } 2784 }
2785
2785 // With no cached data, we partially parse the function, without building an 2786 // With no cached data, we partially parse the function, without building an
2786 // AST. This gathers the data needed to build a lazy function. 2787 // AST. This gathers the data needed to build a lazy function.
2787 PreParser::PreParseResult result = ParseFunctionWithPreParser( 2788 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.PreParse");
2788 kind, function_scope, is_inner_function, may_abort); 2789
2790 if (reusable_preparser_ == NULL) {
2791 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(),
2792 &pending_error_handler_,
2793 runtime_call_stats_, stack_limit_);
2794 reusable_preparser_->set_allow_lazy(true);
2795 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name());
2796 SET_ALLOW(natives);
2797 SET_ALLOW(harmony_do_expressions);
2798 SET_ALLOW(harmony_function_sent);
2799 SET_ALLOW(harmony_async_await);
2800 SET_ALLOW(harmony_trailing_commas);
2801 SET_ALLOW(harmony_class_fields);
2802 #undef SET_ALLOW
2803 }
2804 // Aborting inner function preparsing would leave scopes in an inconsistent
2805 // state; we don't parse inner functions in the abortable mode anyway.
2806 DCHECK(!is_inner_function || !may_abort);
2807
2808 PreParser::PreParseResult result = reusable_preparser_->PreParseFunction(
2809 kind, function_scope, parsing_module_, is_inner_function, may_abort,
2810 use_counts_);
2789 2811
2790 // Return immediately if pre-parser decided to abort parsing. 2812 // Return immediately if pre-parser decided to abort parsing.
2791 if (result == PreParser::kPreParseAbort) return kLazyParsingAborted; 2813 if (result == PreParser::kPreParseAbort) return kLazyParsingAborted;
2792 if (result == PreParser::kPreParseStackOverflow) { 2814 if (result == PreParser::kPreParseStackOverflow) {
2793 // Propagate stack overflow. 2815 // Propagate stack overflow.
2794 set_stack_overflow(); 2816 set_stack_overflow();
2795 *ok = false; 2817 *ok = false;
2796 return kLazyParsingComplete; 2818 return kLazyParsingComplete;
2797 } 2819 }
2798 if (pending_error_handler_.has_pending_error()) { 2820 if (pending_error_handler_.has_pending_error()) {
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
3283 } else { 3305 } else {
3284 statement = factory()->NewEmptyStatement(kNoSourcePosition); 3306 statement = factory()->NewEmptyStatement(kNoSourcePosition);
3285 } 3307 }
3286 result->Set(kFunctionNameAssignmentIndex, statement); 3308 result->Set(kFunctionNameAssignmentIndex, statement);
3287 } 3309 }
3288 3310
3289 MarkCollectedTailCallExpressions(); 3311 MarkCollectedTailCallExpressions();
3290 return result; 3312 return result;
3291 } 3313 }
3292 3314
3293 PreParser::PreParseResult Parser::ParseFunctionWithPreParser(
3294 FunctionKind kind, DeclarationScope* function_scope, bool is_inner_function,
3295 bool may_abort) {
3296 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.PreParse");
3297
3298 if (reusable_preparser_ == NULL) {
3299 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(),
3300 &pending_error_handler_,
3301 runtime_call_stats_, stack_limit_);
3302 reusable_preparser_->set_allow_lazy(true);
3303 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name());
3304 SET_ALLOW(natives);
3305 SET_ALLOW(harmony_do_expressions);
3306 SET_ALLOW(harmony_function_sent);
3307 SET_ALLOW(harmony_async_await);
3308 SET_ALLOW(harmony_trailing_commas);
3309 SET_ALLOW(harmony_class_fields);
3310 #undef SET_ALLOW
3311 }
3312 // Aborting inner function preparsing would leave scopes in an inconsistent
3313 // state; we don't parse inner functions in the abortable mode anyway.
3314 DCHECK(!is_inner_function || !may_abort);
3315
3316 PreParser::PreParseResult result = reusable_preparser_->PreParseFunction(
3317 kind, function_scope, parsing_module_, is_inner_function, may_abort,
3318 use_counts_);
3319 return result;
3320 }
3321
3322 Expression* Parser::InstallHomeObject(Expression* function_literal, 3315 Expression* Parser::InstallHomeObject(Expression* function_literal,
3323 Expression* home_object) { 3316 Expression* home_object) {
3324 Block* do_block = factory()->NewBlock(nullptr, 1, false, kNoSourcePosition); 3317 Block* do_block = factory()->NewBlock(nullptr, 1, false, kNoSourcePosition);
3325 Variable* result_var = 3318 Variable* result_var =
3326 scope()->NewTemporary(ast_value_factory()->empty_string()); 3319 scope()->NewTemporary(ast_value_factory()->empty_string());
3327 DoExpression* do_expr = 3320 DoExpression* do_expr =
3328 factory()->NewDoExpression(do_block, result_var, kNoSourcePosition); 3321 factory()->NewDoExpression(do_block, result_var, kNoSourcePosition);
3329 Assignment* init = factory()->NewAssignment( 3322 Assignment* init = factory()->NewAssignment(
3330 Token::ASSIGN, factory()->NewVariableProxy(result_var), function_literal, 3323 Token::ASSIGN, factory()->NewVariableProxy(result_var), function_literal,
3331 kNoSourcePosition); 3324 kNoSourcePosition);
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after
5443 5436
5444 return final_loop; 5437 return final_loop;
5445 } 5438 }
5446 5439
5447 #undef CHECK_OK 5440 #undef CHECK_OK
5448 #undef CHECK_OK_VOID 5441 #undef CHECK_OK_VOID
5449 #undef CHECK_FAILED 5442 #undef CHECK_FAILED
5450 5443
5451 } // namespace internal 5444 } // namespace internal
5452 } // namespace v8 5445 } // 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