| 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::GetNewTarget() { |
| 497 if (!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 new_target_.set(node); |
| 503 } |
| 504 return 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 2706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3212 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 3224 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
| 3213 BuildVariableAssignment(this_function_var, this_function, Token::INIT, | 3225 BuildVariableAssignment(this_function_var, this_function, Token::INIT, |
| 3214 VectorSlotPair(), BailoutId::None(), states); | 3226 VectorSlotPair(), BailoutId::None(), states); |
| 3215 return this_function; | 3227 return this_function; |
| 3216 } | 3228 } |
| 3217 | 3229 |
| 3218 | 3230 |
| 3219 Node* AstGraphBuilder::BuildNewTargetVariable(Variable* new_target_var) { | 3231 Node* AstGraphBuilder::BuildNewTargetVariable(Variable* new_target_var) { |
| 3220 if (new_target_var == nullptr) return nullptr; | 3232 if (new_target_var == nullptr) return nullptr; |
| 3221 | 3233 |
| 3222 // Retrieve the new target in case we are called as a constructor. | 3234 // Retrieve the new target we were called with. |
| 3223 const Operator* op = javascript()->CallRuntime(Runtime::kGetNewTarget, 0); | 3235 Node* object = GetNewTarget(); |
| 3224 Node* object = NewNode(op); | |
| 3225 // TODO(4544): Bailout id only needed for JavaScriptFrame::Summarize. | |
| 3226 PrepareFrameState(object, BailoutId::FunctionContext()); | |
| 3227 | 3236 |
| 3228 // Assign the object to the {new.target} variable. This should never lazy | 3237 // Assign the object to the {new.target} variable. This should never lazy |
| 3229 // deopt, so it is fine to send invalid bailout id. | 3238 // deopt, so it is fine to send invalid bailout id. |
| 3230 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 3239 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
| 3231 BuildVariableAssignment(new_target_var, object, Token::INIT, VectorSlotPair(), | 3240 BuildVariableAssignment(new_target_var, object, Token::INIT, VectorSlotPair(), |
| 3232 BailoutId::None(), states); | 3241 BailoutId::None(), states); |
| 3233 return object; | 3242 return object; |
| 3234 } | 3243 } |
| 3235 | 3244 |
| 3236 | 3245 |
| (...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4303 // Phi does not exist yet, introduce one. | 4312 // Phi does not exist yet, introduce one. |
| 4304 value = NewPhi(inputs, value, control); | 4313 value = NewPhi(inputs, value, control); |
| 4305 value->ReplaceInput(inputs - 1, other); | 4314 value->ReplaceInput(inputs - 1, other); |
| 4306 } | 4315 } |
| 4307 return value; | 4316 return value; |
| 4308 } | 4317 } |
| 4309 | 4318 |
| 4310 } // namespace compiler | 4319 } // namespace compiler |
| 4311 } // namespace internal | 4320 } // namespace internal |
| 4312 } // namespace v8 | 4321 } // namespace v8 |
| OLD | NEW |