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/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 int params = info()->num_parameters_including_this(); | 486 int params = info()->num_parameters_including_this(); |
487 int index = Linkage::GetJSCallContextParamIndex(params); | 487 int index = Linkage::GetJSCallContextParamIndex(params); |
488 const Operator* op = common()->Parameter(index, "%context"); | 488 const Operator* op = common()->Parameter(index, "%context"); |
489 Node* node = NewNode(op, graph()->start()); | 489 Node* node = NewNode(op, graph()->start()); |
490 function_context_.set(node); | 490 function_context_.set(node); |
491 } | 491 } |
492 return function_context_.get(); | 492 return function_context_.get(); |
493 } | 493 } |
494 | 494 |
495 | 495 |
| 496 Node* AstGraphBuilder::GetIncomingNewTarget() { |
| 497 if (!incoming_new_target_.is_set()) { |
| 498 int params = info()->num_parameters_including_this(); |
| 499 int index = Linkage::GetJSCallNewTargetParamIndex(params); |
| 500 const Operator* op = common()->Parameter(index, "%new.target"); |
| 501 Node* node = NewNode(op, graph()->start()); |
| 502 incoming_new_target_.set(node); |
| 503 } |
| 504 return incoming_new_target_.get(); |
| 505 } |
| 506 |
| 507 |
496 bool AstGraphBuilder::CreateGraph(bool stack_check) { | 508 bool AstGraphBuilder::CreateGraph(bool stack_check) { |
497 Scope* scope = info()->scope(); | 509 Scope* scope = info()->scope(); |
498 DCHECK(graph() != NULL); | 510 DCHECK(graph() != NULL); |
499 | 511 |
500 // Set up the basic structure of the graph. Outputs for {Start} are the formal | 512 // Set up the basic structure of the graph. Outputs for {Start} are the formal |
501 // parameters (including the receiver) plus new target, number of arguments, | 513 // parameters (including the receiver) plus new target, number of arguments, |
502 // context and closure. | 514 // context and closure. |
503 int actual_parameter_count = info()->num_parameters_including_this() + 4; | 515 int actual_parameter_count = info()->num_parameters_including_this() + 4; |
504 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); | 516 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); |
505 | 517 |
(...skipping 2703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3209 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 3221 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
3210 BuildVariableAssignment(this_function_var, this_function, Token::INIT, | 3222 BuildVariableAssignment(this_function_var, this_function, Token::INIT, |
3211 VectorSlotPair(), BailoutId::None(), states); | 3223 VectorSlotPair(), BailoutId::None(), states); |
3212 return this_function; | 3224 return this_function; |
3213 } | 3225 } |
3214 | 3226 |
3215 | 3227 |
3216 Node* AstGraphBuilder::BuildNewTargetVariable(Variable* new_target_var) { | 3228 Node* AstGraphBuilder::BuildNewTargetVariable(Variable* new_target_var) { |
3217 if (new_target_var == nullptr) return nullptr; | 3229 if (new_target_var == nullptr) return nullptr; |
3218 | 3230 |
3219 // Retrieve the new target in case we are called as a constructor. | 3231 // Retrieve the new target we were called with. |
3220 const Operator* op = javascript()->CallRuntime(Runtime::kGetNewTarget, 0); | 3232 Node* object = GetIncomingNewTarget(); |
3221 Node* object = NewNode(op); | |
3222 // TODO(4544): Bailout id only needed for JavaScriptFrame::Summarize. | |
3223 PrepareFrameState(object, BailoutId::FunctionContext()); | |
3224 | 3233 |
3225 // Assign the object to the {new.target} variable. This should never lazy | 3234 // Assign the object to the {new.target} variable. This should never lazy |
3226 // deopt, so it is fine to send invalid bailout id. | 3235 // deopt, so it is fine to send invalid bailout id. |
3227 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 3236 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
3228 BuildVariableAssignment(new_target_var, object, Token::INIT, VectorSlotPair(), | 3237 BuildVariableAssignment(new_target_var, object, Token::INIT, VectorSlotPair(), |
3229 BailoutId::None(), states); | 3238 BailoutId::None(), states); |
3230 return object; | 3239 return object; |
3231 } | 3240 } |
3232 | 3241 |
3233 | 3242 |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4301 // Phi does not exist yet, introduce one. | 4310 // Phi does not exist yet, introduce one. |
4302 value = NewPhi(inputs, value, control); | 4311 value = NewPhi(inputs, value, control); |
4303 value->ReplaceInput(inputs - 1, other); | 4312 value->ReplaceInput(inputs - 1, other); |
4304 } | 4313 } |
4305 return value; | 4314 return value; |
4306 } | 4315 } |
4307 | 4316 |
4308 } // namespace compiler | 4317 } // namespace compiler |
4309 } // namespace internal | 4318 } // namespace internal |
4310 } // namespace v8 | 4319 } // namespace v8 |
OLD | NEW |