| 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 <limits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
| 9 #include "src/compiler/change-lowering.h" | 9 #include "src/compiler/change-lowering.h" |
| 10 #include "src/compiler/control-builders.h" | 10 #include "src/compiler/control-builders.h" |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 t.Return(use); | 921 t.Return(use); |
| 922 t.Lower(); | 922 t.Lower(); |
| 923 CHECK_EQ(cnv, use->InputAt(0)->InputAt(0)); | 923 CHECK_EQ(cnv, use->InputAt(0)->InputAt(0)); |
| 924 CHECK_EQ(IrOpcode::kChangeUint32ToTagged, use->InputAt(0)->opcode()); | 924 CHECK_EQ(IrOpcode::kChangeUint32ToTagged, use->InputAt(0)->opcode()); |
| 925 CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode()); | 925 CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode()); |
| 926 CHECK(b == cnv->InputAt(0) || b == cnv->InputAt(1)); | 926 CHECK(b == cnv->InputAt(0) || b == cnv->InputAt(1)); |
| 927 Node* c = t.jsgraph.TrueConstant(); | 927 Node* c = t.jsgraph.TrueConstant(); |
| 928 CHECK(c == cnv->InputAt(0) || c == cnv->InputAt(1)); | 928 CHECK(c == cnv->InputAt(0) || c == cnv->InputAt(1)); |
| 929 } | 929 } |
| 930 | 930 |
| 931 | |
| 932 static Type* test_types[] = {Type::Signed32(), Type::Unsigned32(), | 931 static Type* test_types[] = {Type::Signed32(), Type::Unsigned32(), |
| 933 Type::Number(), Type::Any()}; | 932 Type::Number()}; |
| 934 | |
| 935 | 933 |
| 936 TEST(LowerNumberCmp_to_int32) { | 934 TEST(LowerNumberCmp_to_int32) { |
| 937 TestingGraph t(Type::Signed32(), Type::Signed32()); | 935 TestingGraph t(Type::Signed32(), Type::Signed32()); |
| 938 | 936 |
| 939 t.CheckLoweringBinop(IrOpcode::kWord32Equal, t.simplified()->NumberEqual()); | 937 t.CheckLoweringBinop(IrOpcode::kWord32Equal, t.simplified()->NumberEqual()); |
| 940 t.CheckLoweringBinop(IrOpcode::kInt32LessThan, | 938 t.CheckLoweringBinop(IrOpcode::kInt32LessThan, |
| 941 t.simplified()->NumberLessThan()); | 939 t.simplified()->NumberLessThan()); |
| 942 t.CheckLoweringBinop(IrOpcode::kInt32LessThanOrEqual, | 940 t.CheckLoweringBinop(IrOpcode::kInt32LessThanOrEqual, |
| 943 t.simplified()->NumberLessThanOrEqual()); | 941 t.simplified()->NumberLessThanOrEqual()); |
| 944 } | 942 } |
| 945 | 943 |
| 946 | 944 |
| 947 TEST(LowerNumberCmp_to_uint32) { | 945 TEST(LowerNumberCmp_to_uint32) { |
| 948 TestingGraph t(Type::Unsigned32(), Type::Unsigned32()); | 946 TestingGraph t(Type::Unsigned32(), Type::Unsigned32()); |
| 949 | 947 |
| 950 t.CheckLoweringBinop(IrOpcode::kWord32Equal, t.simplified()->NumberEqual()); | 948 t.CheckLoweringBinop(IrOpcode::kWord32Equal, t.simplified()->NumberEqual()); |
| 951 t.CheckLoweringBinop(IrOpcode::kUint32LessThan, | 949 t.CheckLoweringBinop(IrOpcode::kUint32LessThan, |
| 952 t.simplified()->NumberLessThan()); | 950 t.simplified()->NumberLessThan()); |
| 953 t.CheckLoweringBinop(IrOpcode::kUint32LessThanOrEqual, | 951 t.CheckLoweringBinop(IrOpcode::kUint32LessThanOrEqual, |
| 954 t.simplified()->NumberLessThanOrEqual()); | 952 t.simplified()->NumberLessThanOrEqual()); |
| 955 } | 953 } |
| 956 | 954 |
| 957 | 955 |
| 958 TEST(LowerNumberCmp_to_float64) { | 956 TEST(LowerNumberCmp_to_float64) { |
| 959 static Type* types[] = {Type::Number(), Type::Any()}; | 957 TestingGraph t(Type::Number(), Type::Number()); |
| 960 | 958 |
| 961 for (size_t i = 0; i < arraysize(types); i++) { | 959 t.CheckLoweringBinop(IrOpcode::kFloat64Equal, t.simplified()->NumberEqual()); |
| 962 TestingGraph t(types[i], types[i]); | 960 t.CheckLoweringBinop(IrOpcode::kFloat64LessThan, |
| 963 | 961 t.simplified()->NumberLessThan()); |
| 964 t.CheckLoweringBinop(IrOpcode::kFloat64Equal, | 962 t.CheckLoweringBinop(IrOpcode::kFloat64LessThanOrEqual, |
| 965 t.simplified()->NumberEqual()); | 963 t.simplified()->NumberLessThanOrEqual()); |
| 966 t.CheckLoweringBinop(IrOpcode::kFloat64LessThan, | |
| 967 t.simplified()->NumberLessThan()); | |
| 968 t.CheckLoweringBinop(IrOpcode::kFloat64LessThanOrEqual, | |
| 969 t.simplified()->NumberLessThanOrEqual()); | |
| 970 } | |
| 971 } | 964 } |
| 972 | 965 |
| 973 | 966 |
| 974 TEST(LowerNumberAddSub_to_int32) { | 967 TEST(LowerNumberAddSub_to_int32) { |
| 975 HandleAndZoneScope scope; | 968 HandleAndZoneScope scope; |
| 976 Type* small_range = Type::Range(1, 10, scope.main_zone()); | 969 Type* small_range = Type::Range(1, 10, scope.main_zone()); |
| 977 Type* large_range = Type::Range(-1e+13, 1e+14, scope.main_zone()); | 970 Type* large_range = Type::Range(-1e+13, 1e+14, scope.main_zone()); |
| 978 static Type* types[] = {Type::Signed32(), Type::Integral32(), small_range, | 971 static Type* types[] = {Type::Signed32(), Type::Integral32(), small_range, |
| 979 large_range}; | 972 large_range}; |
| 980 | 973 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 Type::Integral32()); | 1155 Type::Integral32()); |
| 1163 CheckChangeInsertion(IrOpcode::kChangeTaggedToInt32, MachineType::AnyTagged(), | 1156 CheckChangeInsertion(IrOpcode::kChangeTaggedToInt32, MachineType::AnyTagged(), |
| 1164 MachineType::Int32(), Type::Signed32()); | 1157 MachineType::Int32(), Type::Signed32()); |
| 1165 CheckChangeInsertion(IrOpcode::kChangeTaggedToUint32, | 1158 CheckChangeInsertion(IrOpcode::kChangeTaggedToUint32, |
| 1166 MachineType::AnyTagged(), MachineType::Uint32(), | 1159 MachineType::AnyTagged(), MachineType::Uint32(), |
| 1167 Type::Unsigned32()); | 1160 Type::Unsigned32()); |
| 1168 | 1161 |
| 1169 CheckChangeInsertion(IrOpcode::kChangeFloat64ToTagged, MachineType::Float64(), | 1162 CheckChangeInsertion(IrOpcode::kChangeFloat64ToTagged, MachineType::Float64(), |
| 1170 MachineType::AnyTagged()); | 1163 MachineType::AnyTagged()); |
| 1171 CheckChangeInsertion(IrOpcode::kChangeTaggedToFloat64, | 1164 CheckChangeInsertion(IrOpcode::kChangeTaggedToFloat64, |
| 1172 MachineType::AnyTagged(), MachineType::Float64()); | 1165 MachineType::AnyTagged(), MachineType::Float64(), |
| 1166 Type::Number()); |
| 1173 | 1167 |
| 1174 CheckChangeInsertion(IrOpcode::kChangeInt32ToFloat64, MachineType::Int32(), | 1168 CheckChangeInsertion(IrOpcode::kChangeInt32ToFloat64, MachineType::Int32(), |
| 1175 MachineType::Float64(), Type::Signed32()); | 1169 MachineType::Float64(), Type::Signed32()); |
| 1176 CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, MachineType::Int32(), | 1170 CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, MachineType::Int32(), |
| 1177 MachineType::AnyTagged(), Type::Signed32()); | 1171 MachineType::AnyTagged(), Type::Signed32()); |
| 1178 | 1172 |
| 1179 CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, MachineType::Uint32(), | 1173 CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, MachineType::Uint32(), |
| 1180 MachineType::Float64(), Type::Unsigned32()); | 1174 MachineType::Float64(), Type::Unsigned32()); |
| 1181 CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, MachineType::Uint32(), | 1175 CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, MachineType::Uint32(), |
| 1182 MachineType::AnyTagged(), Type::Unsigned32()); | 1176 MachineType::AnyTagged(), Type::Unsigned32()); |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1948 t.Return(use); | 1942 t.Return(use); |
| 1949 t.Lower(); | 1943 t.Lower(); |
| 1950 | 1944 |
| 1951 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); | 1945 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); |
| 1952 } | 1946 } |
| 1953 } | 1947 } |
| 1954 | 1948 |
| 1955 } // namespace compiler | 1949 } // namespace compiler |
| 1956 } // namespace internal | 1950 } // namespace internal |
| 1957 } // namespace v8 | 1951 } // namespace v8 |
| OLD | NEW |