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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compilation-dependencies.h" | 6 #include "src/compilation-dependencies.h" |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 822 matching lines...) Loading... |
833 if (r.BothInputsAre(Type::String())) { | 833 if (r.BothInputsAre(Type::String())) { |
834 return r.ChangeToPureOperator(simplified()->StringEqual(), invert); | 834 return r.ChangeToPureOperator(simplified()->StringEqual(), invert); |
835 } | 835 } |
836 if (r.BothInputsAre(Type::Number())) { | 836 if (r.BothInputsAre(Type::Number())) { |
837 return r.ChangeToPureOperator(simplified()->NumberEqual(), invert); | 837 return r.ChangeToPureOperator(simplified()->NumberEqual(), invert); |
838 } | 838 } |
839 // TODO(turbofan): js-typed-lowering of StrictEqual(mixed types) | 839 // TODO(turbofan): js-typed-lowering of StrictEqual(mixed types) |
840 return NoChange(); | 840 return NoChange(); |
841 } | 841 } |
842 | 842 |
| 843 Reduction JSTypedLowering::ReduceJSSameValueZero(Node* node) { |
| 844 const bool invert = false; |
| 845 |
| 846 JSBinopReduction r(this, node); |
| 847 if (r.left() == r.right()) { |
| 848 // x === x is always true, even if x === NaN |
| 849 Node* replacement = jsgraph()->BooleanConstant(!invert); |
| 850 ReplaceWithValue(node, replacement); |
| 851 return Replace(replacement); |
| 852 } |
| 853 if (r.OneInputCannotBe(Type::NumberOrSimdOrString())) { |
| 854 // For values with canonical representation (i.e. neither String, nor |
| 855 // Simd128Value nor Number) an empty type intersection means the values |
| 856 // cannot be strictly equal. |
| 857 if (!r.left_type()->Maybe(r.right_type())) { |
| 858 Node* replacement = jsgraph()->BooleanConstant(invert); |
| 859 ReplaceWithValue(node, replacement); |
| 860 return Replace(replacement); |
| 861 } |
| 862 } |
| 863 Reduction const reduction = ReduceJSEqualTypeOf(node, invert); |
| 864 if (reduction.Changed()) { |
| 865 return reduction; |
| 866 } |
| 867 if (r.OneInputIs(the_hole_type_)) { |
| 868 return r.ChangeToPureOperator(simplified()->ReferenceEqual(the_hole_type_), |
| 869 invert); |
| 870 } |
| 871 if (r.OneInputIs(Type::Undefined())) { |
| 872 return r.ChangeToPureOperator( |
| 873 simplified()->ReferenceEqual(Type::Undefined()), invert); |
| 874 } |
| 875 if (r.OneInputIs(Type::Null())) { |
| 876 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Null()), |
| 877 invert); |
| 878 } |
| 879 if (r.OneInputIs(Type::Boolean())) { |
| 880 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Boolean()), |
| 881 invert); |
| 882 } |
| 883 if (r.OneInputIs(Type::Object())) { |
| 884 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Object()), |
| 885 invert); |
| 886 } |
| 887 if (r.OneInputIs(Type::Receiver())) { |
| 888 return r.ChangeToPureOperator( |
| 889 simplified()->ReferenceEqual(Type::Receiver()), invert); |
| 890 } |
| 891 if (r.BothInputsAre(Type::Unique())) { |
| 892 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Unique()), |
| 893 invert); |
| 894 } |
| 895 if (r.BothInputsAre(Type::String())) { |
| 896 return r.ChangeToPureOperator(simplified()->StringEqual(), invert); |
| 897 } |
| 898 if (r.BothInputsAre(Type::Number())) { |
| 899 return r.ChangeToPureOperator(simplified()->NumberEqual(), invert); |
| 900 } |
| 901 // TODO(turbofan): js-typed-lowering of StrictEqual(mixed types) |
| 902 return NoChange(); |
| 903 } |
843 | 904 |
844 Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) { | 905 Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) { |
845 Node* const input = node->InputAt(0); | 906 Node* const input = node->InputAt(0); |
846 Type* const input_type = NodeProperties::GetType(input); | 907 Type* const input_type = NodeProperties::GetType(input); |
847 if (input_type->Is(Type::Boolean())) { | 908 if (input_type->Is(Type::Boolean())) { |
848 // JSToBoolean(x:boolean) => x | 909 // JSToBoolean(x:boolean) => x |
849 return Replace(input); | 910 return Replace(input); |
850 } else if (input_type->Is(Type::OrderedNumber())) { | 911 } else if (input_type->Is(Type::OrderedNumber())) { |
851 // JSToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x,#0)) | 912 // JSToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x,#0)) |
852 RelaxEffectsAndControls(node); | 913 RelaxEffectsAndControls(node); |
(...skipping 1096 matching lines...) Loading... |
1949 } | 2010 } |
1950 switch (node->opcode()) { | 2011 switch (node->opcode()) { |
1951 case IrOpcode::kJSEqual: | 2012 case IrOpcode::kJSEqual: |
1952 return ReduceJSEqual(node, false); | 2013 return ReduceJSEqual(node, false); |
1953 case IrOpcode::kJSNotEqual: | 2014 case IrOpcode::kJSNotEqual: |
1954 return ReduceJSEqual(node, true); | 2015 return ReduceJSEqual(node, true); |
1955 case IrOpcode::kJSStrictEqual: | 2016 case IrOpcode::kJSStrictEqual: |
1956 return ReduceJSStrictEqual(node, false); | 2017 return ReduceJSStrictEqual(node, false); |
1957 case IrOpcode::kJSStrictNotEqual: | 2018 case IrOpcode::kJSStrictNotEqual: |
1958 return ReduceJSStrictEqual(node, true); | 2019 return ReduceJSStrictEqual(node, true); |
| 2020 case IrOpcode::kJSSameValueZero: |
| 2021 return ReduceJSSameValueZero(node); |
1959 case IrOpcode::kJSLessThan: // fall through | 2022 case IrOpcode::kJSLessThan: // fall through |
1960 case IrOpcode::kJSGreaterThan: // fall through | 2023 case IrOpcode::kJSGreaterThan: // fall through |
1961 case IrOpcode::kJSLessThanOrEqual: // fall through | 2024 case IrOpcode::kJSLessThanOrEqual: // fall through |
1962 case IrOpcode::kJSGreaterThanOrEqual: | 2025 case IrOpcode::kJSGreaterThanOrEqual: |
1963 return ReduceJSComparison(node); | 2026 return ReduceJSComparison(node); |
1964 case IrOpcode::kJSBitwiseOr: | 2027 case IrOpcode::kJSBitwiseOr: |
1965 return ReduceInt32Binop(node, simplified()->NumberBitwiseOr()); | 2028 return ReduceInt32Binop(node, simplified()->NumberBitwiseOr()); |
1966 case IrOpcode::kJSBitwiseXor: | 2029 case IrOpcode::kJSBitwiseXor: |
1967 return ReduceInt32Binop(node, simplified()->NumberBitwiseXor()); | 2030 return ReduceInt32Binop(node, simplified()->NumberBitwiseXor()); |
1968 case IrOpcode::kJSBitwiseAnd: | 2031 case IrOpcode::kJSBitwiseAnd: |
(...skipping 115 matching lines...) Loading... |
2084 } | 2147 } |
2085 | 2148 |
2086 | 2149 |
2087 CompilationDependencies* JSTypedLowering::dependencies() const { | 2150 CompilationDependencies* JSTypedLowering::dependencies() const { |
2088 return dependencies_; | 2151 return dependencies_; |
2089 } | 2152 } |
2090 | 2153 |
2091 } // namespace compiler | 2154 } // namespace compiler |
2092 } // namespace internal | 2155 } // namespace internal |
2093 } // namespace v8 | 2156 } // namespace v8 |
OLD | NEW |