OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/effect-control-linearizer.h" | 5 #include "src/compiler/effect-control-linearizer.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 } | 755 } |
756 NodeProperties::ReplaceUses(node, state.value, state.effect, state.control); | 756 NodeProperties::ReplaceUses(node, state.value, state.effect, state.control); |
757 *effect = state.effect; | 757 *effect = state.effect; |
758 *control = state.control; | 758 *control = state.control; |
759 return true; | 759 return true; |
760 } | 760 } |
761 | 761 |
762 EffectControlLinearizer::ValueEffectControl | 762 EffectControlLinearizer::ValueEffectControl |
763 EffectControlLinearizer::LowerChangeFloat64ToTagged(Node* node, Node* effect, | 763 EffectControlLinearizer::LowerChangeFloat64ToTagged(Node* node, Node* effect, |
764 Node* control) { | 764 Node* control) { |
| 765 CheckForMinusZeroMode mode = CheckMinusZeroModeOf(node->op()); |
765 Node* value = node->InputAt(0); | 766 Node* value = node->InputAt(0); |
766 | 767 |
767 Node* value32 = graph()->NewNode(machine()->RoundFloat64ToInt32(), value); | 768 Node* value32 = graph()->NewNode(machine()->RoundFloat64ToInt32(), value); |
768 Node* check_same = graph()->NewNode( | 769 Node* check_same = graph()->NewNode( |
769 machine()->Float64Equal(), value, | 770 machine()->Float64Equal(), value, |
770 graph()->NewNode(machine()->ChangeInt32ToFloat64(), value32)); | 771 graph()->NewNode(machine()->ChangeInt32ToFloat64(), value32)); |
771 Node* branch_same = graph()->NewNode(common()->Branch(), check_same, control); | 772 Node* branch_same = graph()->NewNode(common()->Branch(), check_same, control); |
772 | 773 |
773 Node* if_smi = graph()->NewNode(common()->IfTrue(), branch_same); | 774 Node* if_smi = graph()->NewNode(common()->IfTrue(), branch_same); |
774 Node* vsmi; | 775 Node* vsmi; |
775 Node* if_box = graph()->NewNode(common()->IfFalse(), branch_same); | 776 Node* if_box = graph()->NewNode(common()->IfFalse(), branch_same); |
776 | 777 |
777 // Check if {value} is -0. | 778 if (mode == CheckForMinusZeroMode::kCheckForMinusZero) { |
778 Node* check_zero = graph()->NewNode(machine()->Word32Equal(), value32, | 779 // Check if {value} is -0. |
779 jsgraph()->Int32Constant(0)); | 780 Node* check_zero = graph()->NewNode(machine()->Word32Equal(), value32, |
780 Node* branch_zero = graph()->NewNode(common()->Branch(BranchHint::kFalse), | 781 jsgraph()->Int32Constant(0)); |
781 check_zero, if_smi); | 782 Node* branch_zero = graph()->NewNode(common()->Branch(BranchHint::kFalse), |
| 783 check_zero, if_smi); |
782 | 784 |
783 Node* if_zero = graph()->NewNode(common()->IfTrue(), branch_zero); | 785 Node* if_zero = graph()->NewNode(common()->IfTrue(), branch_zero); |
784 Node* if_notzero = graph()->NewNode(common()->IfFalse(), branch_zero); | 786 Node* if_notzero = graph()->NewNode(common()->IfFalse(), branch_zero); |
785 | 787 |
786 // In case of 0, we need to check the high bits for the IEEE -0 pattern. | 788 // In case of 0, we need to check the high bits for the IEEE -0 pattern. |
787 Node* check_negative = graph()->NewNode( | 789 Node* check_negative = graph()->NewNode( |
788 machine()->Int32LessThan(), | 790 machine()->Int32LessThan(), |
789 graph()->NewNode(machine()->Float64ExtractHighWord32(), value), | 791 graph()->NewNode(machine()->Float64ExtractHighWord32(), value), |
790 jsgraph()->Int32Constant(0)); | 792 jsgraph()->Int32Constant(0)); |
791 Node* branch_negative = graph()->NewNode(common()->Branch(BranchHint::kFalse), | 793 Node* branch_negative = graph()->NewNode( |
792 check_negative, if_zero); | 794 common()->Branch(BranchHint::kFalse), check_negative, if_zero); |
793 | 795 |
794 Node* if_negative = graph()->NewNode(common()->IfTrue(), branch_negative); | 796 Node* if_negative = graph()->NewNode(common()->IfTrue(), branch_negative); |
795 Node* if_notnegative = graph()->NewNode(common()->IfFalse(), branch_negative); | 797 Node* if_notnegative = |
| 798 graph()->NewNode(common()->IfFalse(), branch_negative); |
796 | 799 |
797 // We need to create a box for negative 0. | 800 // We need to create a box for negative 0. |
798 if_smi = graph()->NewNode(common()->Merge(2), if_notzero, if_notnegative); | 801 if_smi = graph()->NewNode(common()->Merge(2), if_notzero, if_notnegative); |
799 if_box = graph()->NewNode(common()->Merge(2), if_box, if_negative); | 802 if_box = graph()->NewNode(common()->Merge(2), if_box, if_negative); |
| 803 } |
800 | 804 |
801 // On 64-bit machines we can just wrap the 32-bit integer in a smi, for 32-bit | 805 // On 64-bit machines we can just wrap the 32-bit integer in a smi, for 32-bit |
802 // machines we need to deal with potential overflow and fallback to boxing. | 806 // machines we need to deal with potential overflow and fallback to boxing. |
803 if (machine()->Is64()) { | 807 if (machine()->Is64()) { |
804 vsmi = ChangeInt32ToSmi(value32); | 808 vsmi = ChangeInt32ToSmi(value32); |
805 } else { | 809 } else { |
806 Node* smi_tag = graph()->NewNode(machine()->Int32AddWithOverflow(), value32, | 810 Node* smi_tag = graph()->NewNode(machine()->Int32AddWithOverflow(), value32, |
807 value32, if_smi); | 811 value32, if_smi); |
808 | 812 |
809 Node* check_ovf = | 813 Node* check_ovf = |
(...skipping 2495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3305 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3309 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
3306 Operator::kNoThrow); | 3310 Operator::kNoThrow); |
3307 to_number_operator_.set(common()->Call(desc)); | 3311 to_number_operator_.set(common()->Call(desc)); |
3308 } | 3312 } |
3309 return to_number_operator_.get(); | 3313 return to_number_operator_.get(); |
3310 } | 3314 } |
3311 | 3315 |
3312 } // namespace compiler | 3316 } // namespace compiler |
3313 } // namespace internal | 3317 } // namespace internal |
3314 } // namespace v8 | 3318 } // namespace v8 |
OLD | NEW |