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

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: Tiny bit more cleanup 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 2600 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 // Assign the object to the arguments variable. 3181 // Assign the object to the arguments variable.
3187 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); 3182 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated());
3188 // This should never lazy deopt, so it is fine to send invalid bailout id. 3183 // This should never lazy deopt, so it is fine to send invalid bailout id.
3189 FrameStateBeforeAndAfter states(this, BailoutId::None()); 3184 FrameStateBeforeAndAfter states(this, BailoutId::None());
3190 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(), 3185 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(),
3191 BailoutId::None(), states); 3186 BailoutId::None(), states);
3192 return object; 3187 return object;
3193 } 3188 }
3194 3189
3195 3190
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) { 3191 Node* AstGraphBuilder::BuildThisFunctionVariable(Variable* this_function_var) {
3215 if (this_function_var == nullptr) return nullptr; 3192 if (this_function_var == nullptr) return nullptr;
3216 3193
3217 // Retrieve the closure we were called with. 3194 // Retrieve the closure we were called with.
3218 Node* this_function = GetFunctionClosure(); 3195 Node* this_function = GetFunctionClosure();
3219 3196
3220 // Assign the object to the {.this_function} variable. 3197 // Assign the object to the {.this_function} variable.
3221 FrameStateBeforeAndAfter states(this, BailoutId::None()); 3198 FrameStateBeforeAndAfter states(this, BailoutId::None());
3222 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST, 3199 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST,
3223 VectorSlotPair(), BailoutId::None(), states); 3200 VectorSlotPair(), BailoutId::None(), states);
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
4294 // Phi does not exist yet, introduce one. 4271 // Phi does not exist yet, introduce one.
4295 value = NewPhi(inputs, value, control); 4272 value = NewPhi(inputs, value, control);
4296 value->ReplaceInput(inputs - 1, other); 4273 value->ReplaceInput(inputs - 1, other);
4297 } 4274 }
4298 return value; 4275 return value;
4299 } 4276 }
4300 4277
4301 } // namespace compiler 4278 } // namespace compiler
4302 } // namespace internal 4279 } // namespace internal
4303 } // namespace v8 4280 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/linkage.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698