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

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: Oops. 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 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after
3185 // Assign the object to the arguments variable. 3180 // Assign the object to the arguments variable.
3186 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); 3181 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated());
3187 // This should never lazy deopt, so it is fine to send invalid bailout id. 3182 // This should never lazy deopt, so it is fine to send invalid bailout id.
3188 FrameStateBeforeAndAfter states(this, BailoutId::None()); 3183 FrameStateBeforeAndAfter states(this, BailoutId::None());
3189 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(), 3184 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(),
3190 BailoutId::None(), states); 3185 BailoutId::None(), states);
3191 return object; 3186 return object;
3192 } 3187 }
3193 3188
3194 3189
3195 Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest, int index) {
3196 if (rest == NULL) return NULL;
3197
3198 DCHECK(index >= 0);
3199 const Operator* op = javascript()->CallRuntime(Runtime::kNewRestParamSlow, 2);
3200 Node* object = NewNode(op, jsgraph()->SmiConstant(index),
3201 jsgraph()->SmiConstant(language_mode()));
3202
3203 // Assign the object to the rest parameter variable.
3204 DCHECK(rest->IsContextSlot() || rest->IsStackAllocated());
3205 // This should never lazy deopt, so it is fine to send invalid bailout id.
3206 FrameStateBeforeAndAfter states(this, BailoutId::None());
3207 BuildVariableAssignment(rest, object, Token::ASSIGN, VectorSlotPair(),
3208 BailoutId::None(), states);
3209 return object;
3210 }
3211
3212
3213 Node* AstGraphBuilder::BuildThisFunctionVariable(Variable* this_function_var) { 3190 Node* AstGraphBuilder::BuildThisFunctionVariable(Variable* this_function_var) {
3214 if (this_function_var == nullptr) return nullptr; 3191 if (this_function_var == nullptr) return nullptr;
3215 3192
3216 // Retrieve the closure we were called with. 3193 // Retrieve the closure we were called with.
3217 Node* this_function = GetFunctionClosure(); 3194 Node* this_function = GetFunctionClosure();
3218 3195
3219 // Assign the object to the {.this_function} variable. 3196 // Assign the object to the {.this_function} variable.
3220 FrameStateBeforeAndAfter states(this, BailoutId::None()); 3197 FrameStateBeforeAndAfter states(this, BailoutId::None());
3221 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST, 3198 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST,
3222 VectorSlotPair(), BailoutId::None(), states); 3199 VectorSlotPair(), BailoutId::None(), states);
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
4292 // Phi does not exist yet, introduce one. 4269 // Phi does not exist yet, introduce one.
4293 value = NewPhi(inputs, value, control); 4270 value = NewPhi(inputs, value, control);
4294 value->ReplaceInput(inputs - 1, other); 4271 value->ReplaceInput(inputs - 1, other);
4295 } 4272 }
4296 return value; 4273 return value;
4297 } 4274 }
4298 4275
4299 } // namespace compiler 4276 } // namespace compiler
4300 } // namespace internal 4277 } // namespace internal
4301 } // namespace v8 4278 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/linkage.cc » ('j') | src/parser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698