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

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

Issue 2898163002: Make non-Module generators only context allocate parameters. (Closed)
Patch Set: Rebase Created 3 years, 7 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/debug/debug-scopes.cc ('k') | src/runtime/runtime-debug.cc » ('j') | 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 <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/api.h" 10 #include "src/api.h"
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 bool is_duplicate; 699 bool is_duplicate;
700 bool is_rest = false; 700 bool is_rest = false;
701 bool is_optional = false; 701 bool is_optional = false;
702 auto var = 702 auto var =
703 scope->DeclareParameter(name, VAR, is_optional, is_rest, 703 scope->DeclareParameter(name, VAR, is_optional, is_rest,
704 &is_duplicate, ast_value_factory(), beg_pos); 704 &is_duplicate, ast_value_factory(), beg_pos);
705 DCHECK(!is_duplicate); 705 DCHECK(!is_duplicate);
706 var->AllocateTo(VariableLocation::PARAMETER, 0); 706 var->AllocateTo(VariableLocation::PARAMETER, 0);
707 707
708 PrepareGeneratorVariables(); 708 PrepareGeneratorVariables();
709 scope->ForceContextAllocation();
709 Expression* initial_yield = 710 Expression* initial_yield =
710 BuildInitialYield(kNoSourcePosition, kGeneratorFunction); 711 BuildInitialYield(kNoSourcePosition, kGeneratorFunction);
711 body->Add( 712 body->Add(
712 factory()->NewExpressionStatement(initial_yield, kNoSourcePosition), 713 factory()->NewExpressionStatement(initial_yield, kNoSourcePosition),
713 zone()); 714 zone());
714 715
715 ParseModuleItemList(body, &ok); 716 ParseModuleItemList(body, &ok);
716 ok = ok && 717 ok = ok &&
717 module()->Validate(this->scope()->AsModuleScope(), 718 module()->Validate(this->scope()->AsModuleScope(),
718 &pending_error_handler_, zone()); 719 &pending_error_handler_, zone());
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after
2524 DeclareFormalParameters(parameters->scope, parameters->params); 2525 DeclareFormalParameters(parameters->scope, parameters->params);
2525 if (!this->classifier() 2526 if (!this->classifier()
2526 ->is_valid_formal_parameter_list_without_duplicates()) { 2527 ->is_valid_formal_parameter_list_without_duplicates()) {
2527 *duplicate_loc = 2528 *duplicate_loc =
2528 this->classifier()->duplicate_formal_parameter_error().location; 2529 this->classifier()->duplicate_formal_parameter_error().location;
2529 } 2530 }
2530 DCHECK_EQ(parameters->is_simple, parameters->scope->has_simple_parameters()); 2531 DCHECK_EQ(parameters->is_simple, parameters->scope->has_simple_parameters());
2531 } 2532 }
2532 2533
2533 void Parser::PrepareGeneratorVariables() { 2534 void Parser::PrepareGeneratorVariables() {
2534 // For generators, allocating variables in contexts is currently a win because 2535 // The code produced for generators relies on forced context allocation of
2535 // it minimizes the work needed to suspend and resume an activation. The 2536 // parameters (it does not restore the frame's parameters upon resume).
2536 // code produced for generators relies on this forced context allocation (it 2537 function_state_->scope()->ForceContextAllocationForParameters();
2537 // does not restore the frame's parameters upon resume).
2538 function_state_->scope()->ForceContextAllocation();
2539 2538
2540 // Calling a generator returns a generator object. That object is stored 2539 // Calling a generator returns a generator object. That object is stored
2541 // in a temporary variable, a definition that is used by "yield" 2540 // in a temporary variable, a definition that is used by "yield"
2542 // expressions. 2541 // expressions.
2543 function_state_->scope()->DeclareGeneratorObjectVar( 2542 function_state_->scope()->DeclareGeneratorObjectVar(
2544 ast_value_factory()->dot_generator_object_string()); 2543 ast_value_factory()->dot_generator_object_string());
2545 } 2544 }
2546 2545
2547 FunctionLiteral* Parser::ParseFunctionLiteral( 2546 FunctionLiteral* Parser::ParseFunctionLiteral(
2548 const AstRawString* function_name, Scanner::Location function_name_location, 2547 const AstRawString* function_name, Scanner::Location function_name_location,
(...skipping 2594 matching lines...) Expand 10 before | Expand all | Expand 10 after
5143 literal->SetShouldEagerCompile(); 5142 literal->SetShouldEagerCompile();
5144 } 5143 }
5145 } 5144 }
5146 5145
5147 #undef CHECK_OK 5146 #undef CHECK_OK
5148 #undef CHECK_OK_VOID 5147 #undef CHECK_OK_VOID
5149 #undef CHECK_FAILED 5148 #undef CHECK_FAILED
5150 5149
5151 } // namespace internal 5150 } // namespace internal
5152 } // namespace v8 5151 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug-scopes.cc ('k') | src/runtime/runtime-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698