| 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/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/address-map.h" | 9 #include "src/address-map.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 MachineRepresentation representation = GetInfo(node)->representation(); | 723 MachineRepresentation representation = GetInfo(node)->representation(); |
| 724 return IsAnyTagged(representation); | 724 return IsAnyTagged(representation); |
| 725 } | 725 } |
| 726 | 726 |
| 727 bool OneInputCannotBe(Node* node, Type* type) { | 727 bool OneInputCannotBe(Node* node, Type* type) { |
| 728 DCHECK_EQ(2, node->op()->ValueInputCount()); | 728 DCHECK_EQ(2, node->op()->ValueInputCount()); |
| 729 return !GetUpperBound(node->InputAt(0))->Maybe(type) || | 729 return !GetUpperBound(node->InputAt(0))->Maybe(type) || |
| 730 !GetUpperBound(node->InputAt(1))->Maybe(type); | 730 !GetUpperBound(node->InputAt(1))->Maybe(type); |
| 731 } | 731 } |
| 732 | 732 |
| 733 void ConvertInput(Node* node, int index, UseInfo use) { | 733 // Converts input {index} of {node} according to given UseInfo {use}, |
| 734 // assuming the type of the input is {input_type}. If {input_type} is null, |
| 735 // it takes the input from the input node {TypeOf(node->InputAt(index))}. |
| 736 void ConvertInput(Node* node, int index, UseInfo use, |
| 737 Type* input_type = nullptr) { |
| 734 Node* input = node->InputAt(index); | 738 Node* input = node->InputAt(index); |
| 735 // In the change phase, insert a change before the use if necessary. | 739 // In the change phase, insert a change before the use if necessary. |
| 736 if (use.representation() == MachineRepresentation::kNone) | 740 if (use.representation() == MachineRepresentation::kNone) |
| 737 return; // No input requirement on the use. | 741 return; // No input requirement on the use. |
| 738 DCHECK_NOT_NULL(input); | 742 DCHECK_NOT_NULL(input); |
| 739 NodeInfo* input_info = GetInfo(input); | 743 NodeInfo* input_info = GetInfo(input); |
| 740 MachineRepresentation input_rep = input_info->representation(); | 744 MachineRepresentation input_rep = input_info->representation(); |
| 741 if (input_rep != use.representation() || | 745 if (input_rep != use.representation() || |
| 742 use.type_check() != TypeCheckKind::kNone) { | 746 use.type_check() != TypeCheckKind::kNone) { |
| 743 // Output representation doesn't match usage. | 747 // Output representation doesn't match usage. |
| 744 TRACE(" change: #%d:%s(@%d #%d:%s) ", node->id(), node->op()->mnemonic(), | 748 TRACE(" change: #%d:%s(@%d #%d:%s) ", node->id(), node->op()->mnemonic(), |
| 745 index, input->id(), input->op()->mnemonic()); | 749 index, input->id(), input->op()->mnemonic()); |
| 746 TRACE(" from "); | 750 TRACE(" from "); |
| 747 PrintOutputInfo(input_info); | 751 PrintOutputInfo(input_info); |
| 748 TRACE(" to "); | 752 TRACE(" to "); |
| 749 PrintUseInfo(use); | 753 PrintUseInfo(use); |
| 750 TRACE("\n"); | 754 TRACE("\n"); |
| 755 if (input_type == nullptr) { |
| 756 input_type = TypeOf(input); |
| 757 } |
| 751 Node* n = changer_->GetRepresentationFor( | 758 Node* n = changer_->GetRepresentationFor( |
| 752 input, input_info->representation(), TypeOf(input), node, use); | 759 input, input_info->representation(), input_type, node, use); |
| 753 node->ReplaceInput(index, n); | 760 node->ReplaceInput(index, n); |
| 754 } | 761 } |
| 755 } | 762 } |
| 756 | 763 |
| 757 void ProcessInput(Node* node, int index, UseInfo use) { | 764 void ProcessInput(Node* node, int index, UseInfo use) { |
| 758 switch (phase_) { | 765 switch (phase_) { |
| 759 case PROPAGATE: | 766 case PROPAGATE: |
| 760 EnqueueInput(node, index, use); | 767 EnqueueInput(node, index, use); |
| 761 break; | 768 break; |
| 762 case RETYPE: | 769 case RETYPE: |
| (...skipping 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2810 MachineRepresentation::kFloat64); | 2817 MachineRepresentation::kFloat64); |
| 2811 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 2818 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
| 2812 return; | 2819 return; |
| 2813 case IrOpcode::kFrameState: | 2820 case IrOpcode::kFrameState: |
| 2814 return VisitFrameState(node); | 2821 return VisitFrameState(node); |
| 2815 case IrOpcode::kStateValues: | 2822 case IrOpcode::kStateValues: |
| 2816 return VisitStateValues(node); | 2823 return VisitStateValues(node); |
| 2817 case IrOpcode::kObjectState: | 2824 case IrOpcode::kObjectState: |
| 2818 return VisitObjectState(node); | 2825 return VisitObjectState(node); |
| 2819 case IrOpcode::kTypeGuard: { | 2826 case IrOpcode::kTypeGuard: { |
| 2820 // We just get rid of the sigma here. In principle, it should be | 2827 // We just get rid of the sigma here, choosing the best representation |
| 2821 // possible to refine the truncation and representation based on | 2828 // for the sigma's type. |
| 2822 // the sigma's type. | 2829 Type* type = TypeOf(node); |
| 2823 MachineRepresentation representation = | 2830 MachineRepresentation representation = |
| 2824 GetOutputInfoForPhi(node, TypeOf(node->InputAt(0)), truncation); | 2831 GetOutputInfoForPhi(node, type, truncation); |
| 2825 | 2832 |
| 2826 // For now, we just handle specially the impossible case. | 2833 // Here we pretend that the input has the sigma's type for the |
| 2827 MachineRepresentation output = TypeOf(node)->IsInhabited() | 2834 // conversion. |
| 2828 ? representation | 2835 UseInfo use(representation, truncation); |
| 2829 : MachineRepresentation::kNone; | 2836 if (propagate()) { |
| 2830 | 2837 EnqueueInput(node, 0, use); |
| 2831 VisitUnop(node, UseInfo(representation, truncation), output); | 2838 } else if (lower()) { |
| 2839 ConvertInput(node, 0, use, type); |
| 2840 } |
| 2841 ProcessRemainingInputs(node, 1); |
| 2842 SetOutput(node, representation); |
| 2832 if (lower()) DeferReplacement(node, node->InputAt(0)); | 2843 if (lower()) DeferReplacement(node, node->InputAt(0)); |
| 2833 return; | 2844 return; |
| 2834 } | 2845 } |
| 2835 | 2846 |
| 2836 case IrOpcode::kFinishRegion: | 2847 case IrOpcode::kFinishRegion: |
| 2837 VisitInputs(node); | 2848 VisitInputs(node); |
| 2838 // Assume the output is tagged pointer. | 2849 // Assume the output is tagged pointer. |
| 2839 return SetOutput(node, MachineRepresentation::kTaggedPointer); | 2850 return SetOutput(node, MachineRepresentation::kTaggedPointer); |
| 2840 | 2851 |
| 2841 case IrOpcode::kReturn: | 2852 case IrOpcode::kReturn: |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3720 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3731 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
| 3721 Operator::kNoProperties); | 3732 Operator::kNoProperties); |
| 3722 to_number_operator_.set(common()->Call(desc)); | 3733 to_number_operator_.set(common()->Call(desc)); |
| 3723 } | 3734 } |
| 3724 return to_number_operator_.get(); | 3735 return to_number_operator_.get(); |
| 3725 } | 3736 } |
| 3726 | 3737 |
| 3727 } // namespace compiler | 3738 } // namespace compiler |
| 3728 } // namespace internal | 3739 } // namespace internal |
| 3729 } // namespace v8 | 3740 } // namespace v8 |
| OLD | NEW |