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/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/compilation-info.h" | 8 #include "src/compilation-info.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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 FrameStateType::kConstructStub, info.shared_info()); | 593 FrameStateType::kConstructStub, info.shared_info()); |
594 } | 594 } |
595 | 595 |
596 // The inlinee specializes to the context from the JSFunction object. | 596 // The inlinee specializes to the context from the JSFunction object. |
597 // TODO(turbofan): We might want to load the context from the JSFunction at | 597 // TODO(turbofan): We might want to load the context from the JSFunction at |
598 // runtime in case we only know the SharedFunctionInfo once we have dynamic | 598 // runtime in case we only know the SharedFunctionInfo once we have dynamic |
599 // type feedback in the compiler. | 599 // type feedback in the compiler. |
600 Node* context = jsgraph()->Constant(handle(function->context())); | 600 Node* context = jsgraph()->Constant(handle(function->context())); |
601 | 601 |
602 // Insert a JSConvertReceiver node for sloppy callees. Note that the context | 602 // Insert a JSConvertReceiver node for sloppy callees. Note that the context |
603 // passed into this node has to be the callees context (loaded above). Note | 603 // passed into this node has to be the callees context (loaded above). |
604 // that the frame state passed to the JSConvertReceiver must be the frame | |
605 // state _before_ the call; it is not necessary to fiddle with the receiver | |
606 // in that frame state tho, as the conversion of the receiver can be repeated | |
607 // any number of times, it's not observable. | |
608 if (node->opcode() == IrOpcode::kJSCall && | 604 if (node->opcode() == IrOpcode::kJSCall && |
609 is_sloppy(shared_info->language_mode()) && !shared_info->native()) { | 605 is_sloppy(shared_info->language_mode()) && !shared_info->native()) { |
610 Node* effect = NodeProperties::GetEffectInput(node); | 606 Node* effect = NodeProperties::GetEffectInput(node); |
611 if (NeedsConvertReceiver(call.receiver(), effect)) { | 607 if (NeedsConvertReceiver(call.receiver(), effect)) { |
612 const CallParameters& p = CallParametersOf(node->op()); | 608 const CallParameters& p = CallParametersOf(node->op()); |
613 Node* frame_state_before = NodeProperties::FindFrameStateBefore(node); | 609 Node* convert = effect = |
614 Node* convert = effect = graph()->NewNode( | 610 graph()->NewNode(javascript()->ConvertReceiver(p.convert_mode()), |
615 javascript()->ConvertReceiver(p.convert_mode()), call.receiver(), | 611 call.receiver(), context, effect, start); |
616 context, frame_state_before, effect, start); | |
617 NodeProperties::ReplaceValueInput(node, convert, 1); | 612 NodeProperties::ReplaceValueInput(node, convert, 1); |
618 NodeProperties::ReplaceEffectInput(node, effect); | 613 NodeProperties::ReplaceEffectInput(node, effect); |
619 } | 614 } |
620 } | 615 } |
621 | 616 |
622 // If we are inlining a JS call at tail position then we have to pop current | 617 // If we are inlining a JS call at tail position then we have to pop current |
623 // frame state and its potential arguments adaptor frame state in order to | 618 // frame state and its potential arguments adaptor frame state in order to |
624 // make the call stack be consistent with non-inlining case. | 619 // make the call stack be consistent with non-inlining case. |
625 // After that we add a tail caller frame state which lets deoptimizer handle | 620 // After that we add a tail caller frame state which lets deoptimizer handle |
626 // the case when the outermost function inlines a tail call (it should remove | 621 // the case when the outermost function inlines a tail call (it should remove |
(...skipping 30 matching lines...) Expand all Loading... |
657 | 652 |
658 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } | 653 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } |
659 | 654 |
660 SimplifiedOperatorBuilder* JSInliner::simplified() const { | 655 SimplifiedOperatorBuilder* JSInliner::simplified() const { |
661 return jsgraph()->simplified(); | 656 return jsgraph()->simplified(); |
662 } | 657 } |
663 | 658 |
664 } // namespace compiler | 659 } // namespace compiler |
665 } // namespace internal | 660 } // namespace internal |
666 } // namespace v8 | 661 } // namespace v8 |
OLD | NEW |