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

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

Issue 2898163002: Make non-Module generators only context allocate parameters. (Closed)
Patch Set: Fix comment 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
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();
neis 2017/05/24 10:39:37 Do we still need this? If not, do we still want it
adamk 2017/05/24 13:04:00 Do you mean "is this call now redundant?" or "do w
neis 2017/05/24 13:59:46 I meant do we still need/want to force context all
adamk 2017/05/24 14:31:22 This would depend on how advanced the preparsing-o
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 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after
2525 DeclareFormalParameters(parameters->scope, parameters->params); 2526 DeclareFormalParameters(parameters->scope, parameters->params);
2526 if (!this->classifier() 2527 if (!this->classifier()
2527 ->is_valid_formal_parameter_list_without_duplicates()) { 2528 ->is_valid_formal_parameter_list_without_duplicates()) {
2528 *duplicate_loc = 2529 *duplicate_loc =
2529 this->classifier()->duplicate_formal_parameter_error().location; 2530 this->classifier()->duplicate_formal_parameter_error().location;
2530 } 2531 }
2531 DCHECK_EQ(parameters->is_simple, parameters->scope->has_simple_parameters()); 2532 DCHECK_EQ(parameters->is_simple, parameters->scope->has_simple_parameters());
2532 } 2533 }
2533 2534
2534 void Parser::PrepareGeneratorVariables() { 2535 void Parser::PrepareGeneratorVariables() {
2535 // For generators, allocating variables in contexts is currently a win because 2536 // The code produced for generators relies on forced context allocation of
2536 // it minimizes the work needed to suspend and resume an activation. The 2537 // parameters (it does not restore the frame's parameters upon resume).
2537 // code produced for generators relies on this forced context allocation (it 2538 function_state_->scope()->ForceContextAllocationForParameters();
2538 // does not restore the frame's parameters upon resume).
2539 function_state_->scope()->ForceContextAllocation();
2540 2539
2541 // Calling a generator returns a generator object. That object is stored 2540 // Calling a generator returns a generator object. That object is stored
2542 // in a temporary variable, a definition that is used by "yield" 2541 // in a temporary variable, a definition that is used by "yield"
2543 // expressions. 2542 // expressions.
2544 function_state_->scope()->DeclareGeneratorObjectVar( 2543 function_state_->scope()->DeclareGeneratorObjectVar(
2545 ast_value_factory()->dot_generator_object_string()); 2544 ast_value_factory()->dot_generator_object_string());
2546 } 2545 }
2547 2546
2548 FunctionLiteral* Parser::ParseFunctionLiteral( 2547 FunctionLiteral* Parser::ParseFunctionLiteral(
2549 const AstRawString* function_name, Scanner::Location function_name_location, 2548 const AstRawString* function_name, Scanner::Location function_name_location,
(...skipping 2594 matching lines...) Expand 10 before | Expand all | Expand 10 after
5144 literal->SetShouldEagerCompile(); 5143 literal->SetShouldEagerCompile();
5145 } 5144 }
5146 } 5145 }
5147 5146
5148 #undef CHECK_OK 5147 #undef CHECK_OK
5149 #undef CHECK_OK_VOID 5148 #undef CHECK_OK_VOID
5150 #undef CHECK_FAILED 5149 #undef CHECK_FAILED
5151 5150
5152 } // namespace internal 5151 } // namespace internal
5153 } // namespace v8 5152 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698