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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 break; | 632 break; |
633 case IrOpcode::kChangeTaggedToFloat64: | 633 case IrOpcode::kChangeTaggedToFloat64: |
634 result = LowerChangeTaggedToFloat64(node); | 634 result = LowerChangeTaggedToFloat64(node); |
635 break; | 635 break; |
636 case IrOpcode::kChangeTaggedToTaggedSigned: | 636 case IrOpcode::kChangeTaggedToTaggedSigned: |
637 result = LowerChangeTaggedToTaggedSigned(node); | 637 result = LowerChangeTaggedToTaggedSigned(node); |
638 break; | 638 break; |
639 case IrOpcode::kTruncateTaggedToBit: | 639 case IrOpcode::kTruncateTaggedToBit: |
640 result = LowerTruncateTaggedToBit(node); | 640 result = LowerTruncateTaggedToBit(node); |
641 break; | 641 break; |
| 642 case IrOpcode::kTruncateTaggedPointerToBit: |
| 643 result = LowerTruncateTaggedPointerToBit(node); |
| 644 break; |
642 case IrOpcode::kTruncateTaggedToFloat64: | 645 case IrOpcode::kTruncateTaggedToFloat64: |
643 result = LowerTruncateTaggedToFloat64(node); | 646 result = LowerTruncateTaggedToFloat64(node); |
644 break; | 647 break; |
645 case IrOpcode::kCheckBounds: | 648 case IrOpcode::kCheckBounds: |
646 result = LowerCheckBounds(node, frame_state); | 649 result = LowerCheckBounds(node, frame_state); |
647 break; | 650 break; |
648 case IrOpcode::kCheckMaps: | 651 case IrOpcode::kCheckMaps: |
649 result = LowerCheckMaps(node, frame_state); | 652 result = LowerCheckMaps(node, frame_state); |
650 break; | 653 break; |
651 case IrOpcode::kCheckNumber: | 654 case IrOpcode::kCheckNumber: |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 { | 979 { |
977 // If {value} is a Smi, then we only need to check that it's not zero. | 980 // If {value} is a Smi, then we only need to check that it's not zero. |
978 __ Goto(&done, | 981 __ Goto(&done, |
979 __ Word32Equal(__ WordEqual(value, __ IntPtrConstant(0)), zero)); | 982 __ Word32Equal(__ WordEqual(value, __ IntPtrConstant(0)), zero)); |
980 } | 983 } |
981 | 984 |
982 __ Bind(&done); | 985 __ Bind(&done); |
983 return done.PhiAt(0); | 986 return done.PhiAt(0); |
984 } | 987 } |
985 | 988 |
| 989 Node* EffectControlLinearizer::LowerTruncateTaggedPointerToBit(Node* node) { |
| 990 Node* value = node->InputAt(0); |
| 991 |
| 992 auto if_heapnumber = __ MakeDeferredLabel<1>(); |
| 993 auto done = __ MakeLabel<5>(MachineRepresentation::kBit); |
| 994 |
| 995 Node* zero = __ Int32Constant(0); |
| 996 Node* fzero = __ Float64Constant(0.0); |
| 997 |
| 998 // Check if {value} is false. |
| 999 __ GotoIf(__ WordEqual(value, __ FalseConstant()), &done, zero); |
| 1000 |
| 1001 // Check if {value} is the empty string. |
| 1002 __ GotoIf(__ WordEqual(value, __ EmptyStringConstant()), &done, zero); |
| 1003 |
| 1004 // Load the map of {value}. |
| 1005 Node* value_map = __ LoadField(AccessBuilder::ForMap(), value); |
| 1006 |
| 1007 // Check if the {value} is undetectable and immediately return false. |
| 1008 Node* value_map_bitfield = |
| 1009 __ LoadField(AccessBuilder::ForMapBitField(), value_map); |
| 1010 __ GotoUnless( |
| 1011 __ Word32Equal(__ Word32And(value_map_bitfield, |
| 1012 __ Int32Constant(1 << Map::kIsUndetectable)), |
| 1013 zero), |
| 1014 &done, zero); |
| 1015 |
| 1016 // Check if {value} is a HeapNumber. |
| 1017 __ GotoIf(__ WordEqual(value_map, __ HeapNumberMapConstant()), |
| 1018 &if_heapnumber); |
| 1019 |
| 1020 // All other values that reach here are true. |
| 1021 __ Goto(&done, __ Int32Constant(1)); |
| 1022 |
| 1023 __ Bind(&if_heapnumber); |
| 1024 { |
| 1025 // For HeapNumber {value}, just check that its value is not 0.0, -0.0 or |
| 1026 // NaN. |
| 1027 Node* value_value = |
| 1028 __ LoadField(AccessBuilder::ForHeapNumberValue(), value); |
| 1029 __ Goto(&done, __ Float64LessThan(fzero, __ Float64Abs(value_value))); |
| 1030 } |
| 1031 |
| 1032 __ Bind(&done); |
| 1033 return done.PhiAt(0); |
| 1034 } |
| 1035 |
986 Node* EffectControlLinearizer::LowerChangeTaggedToInt32(Node* node) { | 1036 Node* EffectControlLinearizer::LowerChangeTaggedToInt32(Node* node) { |
987 Node* value = node->InputAt(0); | 1037 Node* value = node->InputAt(0); |
988 | 1038 |
989 auto if_not_smi = __ MakeDeferredLabel<1>(); | 1039 auto if_not_smi = __ MakeDeferredLabel<1>(); |
990 auto done = __ MakeLabel<2>(MachineRepresentation::kWord32); | 1040 auto done = __ MakeLabel<2>(MachineRepresentation::kWord32); |
991 | 1041 |
992 Node* check = ObjectIsSmi(value); | 1042 Node* check = ObjectIsSmi(value); |
993 __ GotoUnless(check, &if_not_smi); | 1043 __ GotoUnless(check, &if_not_smi); |
994 __ Goto(&done, ChangeSmiToInt32(value)); | 1044 __ Goto(&done, ChangeSmiToInt32(value)); |
995 | 1045 |
(...skipping 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2875 return isolate()->factory(); | 2925 return isolate()->factory(); |
2876 } | 2926 } |
2877 | 2927 |
2878 Isolate* EffectControlLinearizer::isolate() const { | 2928 Isolate* EffectControlLinearizer::isolate() const { |
2879 return jsgraph()->isolate(); | 2929 return jsgraph()->isolate(); |
2880 } | 2930 } |
2881 | 2931 |
2882 } // namespace compiler | 2932 } // namespace compiler |
2883 } // namespace internal | 2933 } // namespace internal |
2884 } // namespace v8 | 2934 } // namespace v8 |
OLD | NEW |