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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1272673003: [es6] Re-implement rest parameters via desugaring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase + fix brokenness Created 5 years, 3 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/js-type-feedback.h" 10 #include "src/compiler/js-type-feedback.h"
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 return !HasStackOverflow(); 561 return !HasStackOverflow();
562 } 562 }
563 563
564 564
565 void AstGraphBuilder::CreateGraphBody(bool stack_check) { 565 void AstGraphBuilder::CreateGraphBody(bool stack_check) {
566 Scope* scope = info()->scope(); 566 Scope* scope = info()->scope();
567 567
568 // Build the arguments object if it is used. 568 // Build the arguments object if it is used.
569 BuildArgumentsObject(scope->arguments()); 569 BuildArgumentsObject(scope->arguments());
570 570
571 // Build rest arguments array if it is used.
572 int rest_index;
573 Variable* rest_parameter = scope->rest_parameter(&rest_index);
574 BuildRestArgumentsArray(rest_parameter, rest_index);
575
576 // Build assignment to {.this_function} variable if it is used. 571 // Build assignment to {.this_function} variable if it is used.
577 BuildThisFunctionVariable(scope->this_function_var()); 572 BuildThisFunctionVariable(scope->this_function_var());
578 573
579 // Build assignment to {new.target} variable if it is used. 574 // Build assignment to {new.target} variable if it is used.
580 BuildNewTargetVariable(scope->new_target_var()); 575 BuildNewTargetVariable(scope->new_target_var());
581 576
582 // Emit tracing call if requested to do so. 577 // Emit tracing call if requested to do so.
583 if (FLAG_trace) { 578 if (FLAG_trace) {
584 NewNode(javascript()->CallRuntime(Runtime::kTraceEnter, 0)); 579 NewNode(javascript()->CallRuntime(Runtime::kTraceEnter, 0));
585 } 580 }
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 1678
1684 void AstGraphBuilder::VisitVariableProxy(VariableProxy* expr) { 1679 void AstGraphBuilder::VisitVariableProxy(VariableProxy* expr) {
1685 VectorSlotPair pair = CreateVectorSlotPair(expr->VariableFeedbackSlot()); 1680 VectorSlotPair pair = CreateVectorSlotPair(expr->VariableFeedbackSlot());
1686 FrameStateBeforeAndAfter states(this, BeforeId(expr)); 1681 FrameStateBeforeAndAfter states(this, BeforeId(expr));
1687 Node* value = BuildVariableLoad(expr->var(), expr->id(), states, pair, 1682 Node* value = BuildVariableLoad(expr->var(), expr->id(), states, pair,
1688 ast_context()->GetStateCombine()); 1683 ast_context()->GetStateCombine());
1689 ast_context()->ProduceValue(value); 1684 ast_context()->ProduceValue(value);
1690 } 1685 }
1691 1686
1692 1687
1688 void AstGraphBuilder::VisitRestParameter(RestParameter* expr) { UNREACHABLE(); }
1689
1690
1693 void AstGraphBuilder::VisitLiteral(Literal* expr) { 1691 void AstGraphBuilder::VisitLiteral(Literal* expr) {
1694 Node* value = jsgraph()->Constant(expr->value()); 1692 Node* value = jsgraph()->Constant(expr->value());
1695 ast_context()->ProduceValue(value); 1693 ast_context()->ProduceValue(value);
1696 } 1694 }
1697 1695
1698 1696
1699 void AstGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { 1697 void AstGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) {
1700 Node* closure = GetFunctionClosure(); 1698 Node* closure = GetFunctionClosure();
1701 1699
1702 // Create node to materialize a regular expression literal. 1700 // Create node to materialize a regular expression literal.
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 // Assign the object to the arguments variable. 3184 // Assign the object to the arguments variable.
3187 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); 3185 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated());
3188 // This should never lazy deopt, so it is fine to send invalid bailout id. 3186 // This should never lazy deopt, so it is fine to send invalid bailout id.
3189 FrameStateBeforeAndAfter states(this, BailoutId::None()); 3187 FrameStateBeforeAndAfter states(this, BailoutId::None());
3190 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(), 3188 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(),
3191 BailoutId::None(), states); 3189 BailoutId::None(), states);
3192 return object; 3190 return object;
3193 } 3191 }
3194 3192
3195 3193
3196 Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest, int index) {
3197 if (rest == NULL) return NULL;
3198
3199 DCHECK(index >= 0);
3200 const Operator* op = javascript()->CallRuntime(Runtime::kNewRestParamSlow, 2);
3201 Node* object = NewNode(op, jsgraph()->SmiConstant(index),
3202 jsgraph()->SmiConstant(language_mode()));
3203
3204 // Assign the object to the rest parameter variable.
3205 DCHECK(rest->IsContextSlot() || rest->IsStackAllocated());
3206 // This should never lazy deopt, so it is fine to send invalid bailout id.
3207 FrameStateBeforeAndAfter states(this, BailoutId::None());
3208 BuildVariableAssignment(rest, object, Token::ASSIGN, VectorSlotPair(),
3209 BailoutId::None(), states);
3210 return object;
3211 }
3212
3213
3214 Node* AstGraphBuilder::BuildThisFunctionVariable(Variable* this_function_var) { 3194 Node* AstGraphBuilder::BuildThisFunctionVariable(Variable* this_function_var) {
3215 if (this_function_var == nullptr) return nullptr; 3195 if (this_function_var == nullptr) return nullptr;
3216 3196
3217 // Retrieve the closure we were called with. 3197 // Retrieve the closure we were called with.
3218 Node* this_function = GetFunctionClosure(); 3198 Node* this_function = GetFunctionClosure();
3219 3199
3220 // Assign the object to the {.this_function} variable. 3200 // Assign the object to the {.this_function} variable.
3221 FrameStateBeforeAndAfter states(this, BailoutId::None()); 3201 FrameStateBeforeAndAfter states(this, BailoutId::None());
3222 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST, 3202 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST,
3223 VectorSlotPair(), BailoutId::None(), states); 3203 VectorSlotPair(), BailoutId::None(), states);
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
4294 // Phi does not exist yet, introduce one. 4274 // Phi does not exist yet, introduce one.
4295 value = NewPhi(inputs, value, control); 4275 value = NewPhi(inputs, value, control);
4296 value->ReplaceInput(inputs - 1, other); 4276 value->ReplaceInput(inputs - 1, other);
4297 } 4277 }
4298 return value; 4278 return value;
4299 } 4279 }
4300 4280
4301 } // namespace compiler 4281 } // namespace compiler
4302 } // namespace internal 4282 } // namespace internal
4303 } // namespace v8 4283 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698