| 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 2608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3194 // Assign the object to the arguments variable. | 3189 // Assign the object to the arguments variable. |
| 3195 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); | 3190 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); |
| 3196 // This should never lazy deopt, so it is fine to send invalid bailout id. | 3191 // This should never lazy deopt, so it is fine to send invalid bailout id. |
| 3197 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 3192 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
| 3198 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(), | 3193 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(), |
| 3199 BailoutId::None(), states); | 3194 BailoutId::None(), states); |
| 3200 return object; | 3195 return object; |
| 3201 } | 3196 } |
| 3202 | 3197 |
| 3203 | 3198 |
| 3204 Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest, int index) { | |
| 3205 if (rest == NULL) return NULL; | |
| 3206 | |
| 3207 DCHECK(index >= 0); | |
| 3208 const Operator* op = javascript()->CallRuntime(Runtime::kNewRestParamSlow, 2); | |
| 3209 Node* object = NewNode(op, jsgraph()->SmiConstant(index), | |
| 3210 jsgraph()->SmiConstant(language_mode())); | |
| 3211 | |
| 3212 // Assign the object to the rest parameter variable. | |
| 3213 DCHECK(rest->IsContextSlot() || rest->IsStackAllocated()); | |
| 3214 // This should never lazy deopt, so it is fine to send invalid bailout id. | |
| 3215 FrameStateBeforeAndAfter states(this, BailoutId::None()); | |
| 3216 BuildVariableAssignment(rest, object, Token::ASSIGN, VectorSlotPair(), | |
| 3217 BailoutId::None(), states); | |
| 3218 return object; | |
| 3219 } | |
| 3220 | |
| 3221 | |
| 3222 Node* AstGraphBuilder::BuildThisFunctionVariable(Variable* this_function_var) { | 3199 Node* AstGraphBuilder::BuildThisFunctionVariable(Variable* this_function_var) { |
| 3223 if (this_function_var == nullptr) return nullptr; | 3200 if (this_function_var == nullptr) return nullptr; |
| 3224 | 3201 |
| 3225 // Retrieve the closure we were called with. | 3202 // Retrieve the closure we were called with. |
| 3226 Node* this_function = GetFunctionClosure(); | 3203 Node* this_function = GetFunctionClosure(); |
| 3227 | 3204 |
| 3228 // Assign the object to the {.this_function} variable. | 3205 // Assign the object to the {.this_function} variable. |
| 3229 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 3206 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
| 3230 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST, | 3207 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST, |
| 3231 VectorSlotPair(), BailoutId::None(), states); | 3208 VectorSlotPair(), BailoutId::None(), states); |
| (...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4305 // Phi does not exist yet, introduce one. | 4282 // Phi does not exist yet, introduce one. |
| 4306 value = NewPhi(inputs, value, control); | 4283 value = NewPhi(inputs, value, control); |
| 4307 value->ReplaceInput(inputs - 1, other); | 4284 value->ReplaceInput(inputs - 1, other); |
| 4308 } | 4285 } |
| 4309 return value; | 4286 return value; |
| 4310 } | 4287 } |
| 4311 | 4288 |
| 4312 } // namespace compiler | 4289 } // namespace compiler |
| 4313 } // namespace internal | 4290 } // namespace internal |
| 4314 } // namespace v8 | 4291 } // namespace v8 |
| OLD | NEW |