| 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 2629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3208 // Assign the object to the arguments variable. | 3203 // Assign the object to the arguments variable. |
| 3209 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); | 3204 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); |
| 3210 // This should never lazy deopt, so it is fine to send invalid bailout id. | 3205 // This should never lazy deopt, so it is fine to send invalid bailout id. |
| 3211 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 3206 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
| 3212 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(), | 3207 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(), |
| 3213 BailoutId::None(), states); | 3208 BailoutId::None(), states); |
| 3214 return object; | 3209 return object; |
| 3215 } | 3210 } |
| 3216 | 3211 |
| 3217 | 3212 |
| 3218 Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest, int index) { | |
| 3219 if (rest == NULL) return NULL; | |
| 3220 | |
| 3221 DCHECK(index >= 0); | |
| 3222 const Operator* op = javascript()->CallRuntime(Runtime::kNewRestParamSlow, 2); | |
| 3223 Node* object = NewNode(op, jsgraph()->SmiConstant(index), | |
| 3224 jsgraph()->SmiConstant(language_mode())); | |
| 3225 | |
| 3226 // Assign the object to the rest parameter variable. | |
| 3227 DCHECK(rest->IsContextSlot() || rest->IsStackAllocated()); | |
| 3228 // This should never lazy deopt, so it is fine to send invalid bailout id. | |
| 3229 FrameStateBeforeAndAfter states(this, BailoutId::None()); | |
| 3230 BuildVariableAssignment(rest, object, Token::ASSIGN, VectorSlotPair(), | |
| 3231 BailoutId::None(), states); | |
| 3232 return object; | |
| 3233 } | |
| 3234 | |
| 3235 | |
| 3236 Node* AstGraphBuilder::BuildThisFunctionVariable(Variable* this_function_var) { | 3213 Node* AstGraphBuilder::BuildThisFunctionVariable(Variable* this_function_var) { |
| 3237 if (this_function_var == nullptr) return nullptr; | 3214 if (this_function_var == nullptr) return nullptr; |
| 3238 | 3215 |
| 3239 // Retrieve the closure we were called with. | 3216 // Retrieve the closure we were called with. |
| 3240 Node* this_function = GetFunctionClosure(); | 3217 Node* this_function = GetFunctionClosure(); |
| 3241 | 3218 |
| 3242 // Assign the object to the {.this_function} variable. | 3219 // Assign the object to the {.this_function} variable. |
| 3243 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 3220 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
| 3244 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST, | 3221 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST, |
| 3245 VectorSlotPair(), BailoutId::None(), states); | 3222 VectorSlotPair(), BailoutId::None(), states); |
| (...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4289 // Phi does not exist yet, introduce one. | 4266 // Phi does not exist yet, introduce one. |
| 4290 value = NewPhi(inputs, value, control); | 4267 value = NewPhi(inputs, value, control); |
| 4291 value->ReplaceInput(inputs - 1, other); | 4268 value->ReplaceInput(inputs - 1, other); |
| 4292 } | 4269 } |
| 4293 return value; | 4270 return value; |
| 4294 } | 4271 } |
| 4295 | 4272 |
| 4296 } // namespace compiler | 4273 } // namespace compiler |
| 4297 } // namespace internal | 4274 } // namespace internal |
| 4298 } // namespace v8 | 4275 } // namespace v8 |
| OLD | NEW |