| 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/js-inlining.h" | 5 #include "src/compiler/js-inlining.h" |
| 6 | 6 |
| 7 #include "src/ast.h" | 7 #include "src/ast.h" |
| 8 #include "src/ast-numbering.h" | 8 #include "src/ast-numbering.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/compiler/all-nodes.h" | 10 #include "src/compiler/all-nodes.h" |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 Node* end = visitor.GetCopy(graph.end()); | 445 Node* end = visitor.GetCopy(graph.end()); |
| 446 Node* frame_state = call.frame_state_after(); | 446 Node* frame_state = call.frame_state_after(); |
| 447 | 447 |
| 448 // Insert nodes around the call that model the behavior required for a | 448 // Insert nodes around the call that model the behavior required for a |
| 449 // constructor dispatch and turn the constructor call into a regular call. | 449 // constructor dispatch and turn the constructor call into a regular call. |
| 450 // This models the behavior usually accomplished by our {JSConstructStub}. | 450 // This models the behavior usually accomplished by our {JSConstructStub}. |
| 451 // Note that the context has to be the callers context (input to call node). | 451 // Note that the context has to be the callers context (input to call node). |
| 452 if (node->opcode() == IrOpcode::kJSCallConstruct) { | 452 if (node->opcode() == IrOpcode::kJSCallConstruct) { |
| 453 Node* effect = NodeProperties::GetEffectInput(node); | 453 Node* effect = NodeProperties::GetEffectInput(node); |
| 454 Node* context = NodeProperties::GetContextInput(node); | 454 Node* context = NodeProperties::GetContextInput(node); |
| 455 Node* create = jsgraph_->graph()->NewNode(jsgraph_->javascript()->Create(), | 455 Node* create = jsgraph_->graph()->NewNode( |
| 456 call.target(), context, effect); | 456 jsgraph_->javascript()->Create(), call.target(), |
| 457 call.original_constructor(), context, effect); |
| 457 NodeProperties::ReplaceEffectInput(node, create); | 458 NodeProperties::ReplaceEffectInput(node, create); |
| 458 // TODO(4544): For now {JSCreate} requires the actual constructor to | 459 // TODO(4544): For now Runtime_GetOriginalConstructor depends on the actual |
| 459 // coincide with the original constructor. Adapt JSGenericLowering to fix. | 460 // constructor to coincide with the original constructor. Fix this! |
| 460 // Also Runtime_GetOriginalConstructor depends on this for now. Fix as well! | |
| 461 CHECK_EQ(call.target(), call.original_constructor()); | 461 CHECK_EQ(call.target(), call.original_constructor()); |
| 462 // TODO(4544): For derived constructors we should not allocate an implicit | 462 // TODO(4544): For derived constructors we should not allocate an implicit |
| 463 // receiver and also the return value should not be checked afterwards. | 463 // receiver and also the return value should not be checked afterwards. |
| 464 CHECK(!IsClassConstructor(function->shared()->kind())); | 464 CHECK(!IsClassConstructor(function->shared()->kind())); |
| 465 // Swizzle the inputs of the {JSCallConstruct} node to look like inputs to | 465 // Swizzle the inputs of the {JSCallConstruct} node to look like inputs to |
| 466 // any {JSCallFunction} node so that the rest of the inlining machinery | 466 // any {JSCallFunction} node so that the rest of the inlining machinery |
| 467 // behaves as if we were dealing with a regular function invocation. | 467 // behaves as if we were dealing with a regular function invocation. |
| 468 node->RemoveInput(call.formal_arguments() + 1); // Drop new.target. | 468 node->RemoveInput(call.formal_arguments() + 1); // Drop new.target. |
| 469 node->InsertInput(jsgraph_->graph()->zone(), 1, create); | 469 node->InsertInput(jsgraph_->graph()->zone(), 1, create); |
| 470 // Insert a check of the return value to determine whether the return value | 470 // Insert a check of the return value to determine whether the return value |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 node, frame_state, call.formal_arguments(), | 517 node, frame_state, call.formal_arguments(), |
| 518 FrameStateType::kArgumentsAdaptor, info.shared_info()); | 518 FrameStateType::kArgumentsAdaptor, info.shared_info()); |
| 519 } | 519 } |
| 520 | 520 |
| 521 return InlineCall(node, context, frame_state, start, end); | 521 return InlineCall(node, context, frame_state, start, end); |
| 522 } | 522 } |
| 523 | 523 |
| 524 } // namespace compiler | 524 } // namespace compiler |
| 525 } // namespace internal | 525 } // namespace internal |
| 526 } // namespace v8 | 526 } // namespace v8 |
| OLD | NEW |