| 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/compiler-source-position-table.h" | 9 #include "src/compiler/compiler-source-position-table.h" |
| 10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 } | 822 } |
| 823 *effect = gasm()->ExtractCurrentEffect(); | 823 *effect = gasm()->ExtractCurrentEffect(); |
| 824 *control = gasm()->ExtractCurrentControl(); | 824 *control = gasm()->ExtractCurrentControl(); |
| 825 NodeProperties::ReplaceUses(node, result, *effect, *control); | 825 NodeProperties::ReplaceUses(node, result, *effect, *control); |
| 826 return true; | 826 return true; |
| 827 } | 827 } |
| 828 | 828 |
| 829 #define __ gasm()-> | 829 #define __ gasm()-> |
| 830 | 830 |
| 831 Node* EffectControlLinearizer::LowerChangeFloat64ToTagged(Node* node) { | 831 Node* EffectControlLinearizer::LowerChangeFloat64ToTagged(Node* node) { |
| 832 CheckForMinusZeroMode mode = CheckMinusZeroModeOf(node->op()); |
| 832 Node* value = node->InputAt(0); | 833 Node* value = node->InputAt(0); |
| 833 return AllocateHeapNumberWithValue(value); | 834 |
| 835 auto done = __ MakeLabel<2>(MachineRepresentation::kTagged); |
| 836 auto if_heapnumber = |
| 837 __ MakeLabelFor(GraphAssemblerLabelType::kNonDeferred, |
| 838 1 + (mode == CheckForMinusZeroMode::kCheckForMinusZero) + |
| 839 !machine()->Is64()); |
| 840 auto if_int32 = __ MakeLabel<1>(); |
| 841 |
| 842 Node* value32 = __ RoundFloat64ToInt32(value); |
| 843 __ GotoIf(__ Float64Equal(value, __ ChangeInt32ToFloat64(value32)), |
| 844 &if_int32); |
| 845 __ Goto(&if_heapnumber); |
| 846 |
| 847 __ Bind(&if_int32); |
| 848 { |
| 849 if (mode == CheckForMinusZeroMode::kCheckForMinusZero) { |
| 850 Node* zero = __ Int32Constant(0); |
| 851 auto if_zero = __ MakeDeferredLabel<1>(); |
| 852 auto if_smi = __ MakeLabel<2>(); |
| 853 |
| 854 __ GotoIf(__ Word32Equal(value32, zero), &if_zero); |
| 855 __ Goto(&if_smi); |
| 856 |
| 857 __ Bind(&if_zero); |
| 858 { |
| 859 // In case of 0, we need to check the high bits for the IEEE -0 pattern. |
| 860 __ GotoIf(__ Int32LessThan(__ Float64ExtractHighWord32(value), zero), |
| 861 &if_heapnumber); |
| 862 __ Goto(&if_smi); |
| 863 } |
| 864 |
| 865 __ Bind(&if_smi); |
| 866 } |
| 867 |
| 868 if (machine()->Is64()) { |
| 869 Node* value_smi = ChangeInt32ToSmi(value32); |
| 870 __ Goto(&done, value_smi); |
| 871 } else { |
| 872 Node* add = __ Int32AddWithOverflow(value32, value32); |
| 873 Node* ovf = __ Projection(1, add); |
| 874 __ GotoIf(ovf, &if_heapnumber); |
| 875 Node* value_smi = __ Projection(0, add); |
| 876 __ Goto(&done, value_smi); |
| 877 } |
| 878 } |
| 879 |
| 880 __ Bind(&if_heapnumber); |
| 881 { |
| 882 Node* value_number = AllocateHeapNumberWithValue(value); |
| 883 __ Goto(&done, value_number); |
| 884 } |
| 885 |
| 886 __ Bind(&done); |
| 887 return done.PhiAt(0); |
| 834 } | 888 } |
| 835 | 889 |
| 836 Node* EffectControlLinearizer::LowerChangeFloat64ToTaggedPointer(Node* node) { | 890 Node* EffectControlLinearizer::LowerChangeFloat64ToTaggedPointer(Node* node) { |
| 837 Node* value = node->InputAt(0); | 891 Node* value = node->InputAt(0); |
| 838 return AllocateHeapNumberWithValue(value); | 892 return AllocateHeapNumberWithValue(value); |
| 839 } | 893 } |
| 840 | 894 |
| 841 Node* EffectControlLinearizer::LowerChangeBitToTagged(Node* node) { | 895 Node* EffectControlLinearizer::LowerChangeBitToTagged(Node* node) { |
| 842 Node* value = node->InputAt(0); | 896 Node* value = node->InputAt(0); |
| 843 | 897 |
| (...skipping 2087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2931 return isolate()->factory(); | 2985 return isolate()->factory(); |
| 2932 } | 2986 } |
| 2933 | 2987 |
| 2934 Isolate* EffectControlLinearizer::isolate() const { | 2988 Isolate* EffectControlLinearizer::isolate() const { |
| 2935 return jsgraph()->isolate(); | 2989 return jsgraph()->isolate(); |
| 2936 } | 2990 } |
| 2937 | 2991 |
| 2938 } // namespace compiler | 2992 } // namespace compiler |
| 2939 } // namespace internal | 2993 } // namespace internal |
| 2940 } // namespace v8 | 2994 } // namespace v8 |
| OLD | NEW |