OLD | NEW |
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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 return !HasStackOverflow(); | 554 return !HasStackOverflow(); |
555 } | 555 } |
556 | 556 |
557 | 557 |
558 void AstGraphBuilder::CreateGraphBody(bool stack_check) { | 558 void AstGraphBuilder::CreateGraphBody(bool stack_check) { |
559 Scope* scope = info()->scope(); | 559 Scope* scope = info()->scope(); |
560 | 560 |
561 // Build the arguments object if it is used. | 561 // Build the arguments object if it is used. |
562 BuildArgumentsObject(scope->arguments()); | 562 BuildArgumentsObject(scope->arguments()); |
563 | 563 |
564 // Build rest arguments array if it is used. | |
565 int rest_index; | |
566 Variable* rest_parameter = scope->rest_parameter(&rest_index); | |
567 BuildRestArgumentsArray(rest_parameter, rest_index); | |
568 | |
569 // Build assignment to {.this_function} variable if it is used. | 564 // Build assignment to {.this_function} variable if it is used. |
570 BuildThisFunctionVariable(scope->this_function_var()); | 565 BuildThisFunctionVariable(scope->this_function_var()); |
571 | 566 |
572 // Build assignment to {new.target} variable if it is used. | 567 // Build assignment to {new.target} variable if it is used. |
573 BuildNewTargetVariable(scope->new_target_var()); | 568 BuildNewTargetVariable(scope->new_target_var()); |
574 | 569 |
575 // Emit tracing call if requested to do so. | 570 // Emit tracing call if requested to do so. |
576 if (FLAG_trace) { | 571 if (FLAG_trace) { |
577 NewNode(javascript()->CallRuntime(Runtime::kTraceEnter, 0)); | 572 NewNode(javascript()->CallRuntime(Runtime::kTraceEnter, 0)); |
578 } | 573 } |
(...skipping 2618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3197 // Assign the object to the arguments variable. | 3192 // Assign the object to the arguments variable. |
3198 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); | 3193 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); |
3199 // This should never lazy deopt, so it is fine to send invalid bailout id. | 3194 // This should never lazy deopt, so it is fine to send invalid bailout id. |
3200 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 3195 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
3201 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(), | 3196 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(), |
3202 BailoutId::None(), states); | 3197 BailoutId::None(), states); |
3203 return object; | 3198 return object; |
3204 } | 3199 } |
3205 | 3200 |
3206 | 3201 |
3207 Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest, int index) { | |
3208 if (rest == NULL) return NULL; | |
3209 | |
3210 DCHECK(index >= 0); | |
3211 const Operator* op = javascript()->CallRuntime(Runtime::kNewRestParamSlow, 2); | |
3212 Node* object = NewNode(op, jsgraph()->SmiConstant(index), | |
3213 jsgraph()->SmiConstant(language_mode())); | |
3214 | |
3215 // Assign the object to the rest parameter variable. | |
3216 DCHECK(rest->IsContextSlot() || rest->IsStackAllocated()); | |
3217 // This should never lazy deopt, so it is fine to send invalid bailout id. | |
3218 FrameStateBeforeAndAfter states(this, BailoutId::None()); | |
3219 BuildVariableAssignment(rest, object, Token::ASSIGN, VectorSlotPair(), | |
3220 BailoutId::None(), states); | |
3221 return object; | |
3222 } | |
3223 | |
3224 | |
3225 Node* AstGraphBuilder::BuildThisFunctionVariable(Variable* this_function_var) { | 3202 Node* AstGraphBuilder::BuildThisFunctionVariable(Variable* this_function_var) { |
3226 if (this_function_var == nullptr) return nullptr; | 3203 if (this_function_var == nullptr) return nullptr; |
3227 | 3204 |
3228 // Retrieve the closure we were called with. | 3205 // Retrieve the closure we were called with. |
3229 Node* this_function = GetFunctionClosure(); | 3206 Node* this_function = GetFunctionClosure(); |
3230 | 3207 |
3231 // Assign the object to the {.this_function} variable. | 3208 // Assign the object to the {.this_function} variable. |
3232 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 3209 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
3233 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST, | 3210 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST, |
3234 VectorSlotPair(), BailoutId::None(), states); | 3211 VectorSlotPair(), BailoutId::None(), states); |
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4313 // Phi does not exist yet, introduce one. | 4290 // Phi does not exist yet, introduce one. |
4314 value = NewPhi(inputs, value, control); | 4291 value = NewPhi(inputs, value, control); |
4315 value->ReplaceInput(inputs - 1, other); | 4292 value->ReplaceInput(inputs - 1, other); |
4316 } | 4293 } |
4317 return value; | 4294 return value; |
4318 } | 4295 } |
4319 | 4296 |
4320 } // namespace compiler | 4297 } // namespace compiler |
4321 } // namespace internal | 4298 } // namespace internal |
4322 } // namespace v8 | 4299 } // namespace v8 |
OLD | NEW |