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 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 | 836 |
837 | 837 |
838 TEST(LowerBooleanNot_bit_tagged) { | 838 TEST(LowerBooleanNot_bit_tagged) { |
839 // BooleanNot(x: kRepBit) used as kRepTagged | 839 // BooleanNot(x: kRepBit) used as kRepTagged |
840 TestingGraph t(Type::Boolean()); | 840 TestingGraph t(Type::Boolean()); |
841 Node* b = t.ExampleWithOutput(MachineType::Bool()); | 841 Node* b = t.ExampleWithOutput(MachineType::Bool()); |
842 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); | 842 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); |
843 Node* use = t.Use(inv, MachineType::AnyTagged()); | 843 Node* use = t.Use(inv, MachineType::AnyTagged()); |
844 t.Return(use); | 844 t.Return(use); |
845 t.Lower(); | 845 t.Lower(); |
846 CHECK_EQ(IrOpcode::kChangeBitToTagged, use->InputAt(0)->opcode()); | 846 CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode()); |
847 Node* cmp = use->InputAt(0)->InputAt(0); | 847 Node* cmp = use->InputAt(0)->InputAt(0); |
848 CHECK_EQ(t.machine()->Word32Equal()->opcode(), cmp->opcode()); | 848 CHECK_EQ(t.machine()->Word32Equal()->opcode(), cmp->opcode()); |
849 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1)); | 849 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1)); |
850 Node* f = t.jsgraph.Int32Constant(0); | 850 Node* f = t.jsgraph.Int32Constant(0); |
851 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1)); | 851 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1)); |
852 } | 852 } |
853 | 853 |
854 | 854 |
855 TEST(LowerBooleanNot_tagged_bit) { | 855 TEST(LowerBooleanNot_tagged_bit) { |
856 // BooleanNot(x: kRepTagged) used as kRepBit | 856 // BooleanNot(x: kRepTagged) used as kRepBit |
(...skipping 11 matching lines...) Expand all Loading... |
868 | 868 |
869 | 869 |
870 TEST(LowerBooleanNot_tagged_tagged) { | 870 TEST(LowerBooleanNot_tagged_tagged) { |
871 // BooleanNot(x: kRepTagged) used as kRepTagged | 871 // BooleanNot(x: kRepTagged) used as kRepTagged |
872 TestingGraph t(Type::Boolean()); | 872 TestingGraph t(Type::Boolean()); |
873 Node* b = t.p0; | 873 Node* b = t.p0; |
874 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); | 874 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); |
875 Node* use = t.Use(inv, MachineType::AnyTagged()); | 875 Node* use = t.Use(inv, MachineType::AnyTagged()); |
876 t.Return(use); | 876 t.Return(use); |
877 t.Lower(); | 877 t.Lower(); |
878 CHECK_EQ(IrOpcode::kChangeBitToTagged, use->InputAt(0)->opcode()); | 878 CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode()); |
879 Node* cmp = use->InputAt(0)->InputAt(0); | 879 Node* cmp = use->InputAt(0)->InputAt(0); |
880 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode()); | 880 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode()); |
881 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1)); | 881 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1)); |
882 Node* f = t.jsgraph.FalseConstant(); | 882 Node* f = t.jsgraph.FalseConstant(); |
883 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1)); | 883 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1)); |
884 } | 884 } |
885 | 885 |
886 | 886 |
887 TEST(LowerBooleanToNumber_bit_int32) { | 887 TEST(LowerBooleanToNumber_bit_int32) { |
888 // BooleanToNumber(x: kRepBit) used as MachineType::Int32() | 888 // BooleanToNumber(x: kRepBit) used as MachineType::Int32() |
(...skipping 24 matching lines...) Expand all Loading... |
913 | 913 |
914 TEST(LowerBooleanToNumber_bit_tagged) { | 914 TEST(LowerBooleanToNumber_bit_tagged) { |
915 // BooleanToNumber(x: kRepBit) used as MachineType::AnyTagged() | 915 // BooleanToNumber(x: kRepBit) used as MachineType::AnyTagged() |
916 TestingGraph t(Type::Boolean()); | 916 TestingGraph t(Type::Boolean()); |
917 Node* b = t.ExampleWithOutput(MachineType::Bool()); | 917 Node* b = t.ExampleWithOutput(MachineType::Bool()); |
918 Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); | 918 Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); |
919 Node* use = t.Use(cnv, MachineType::AnyTagged()); | 919 Node* use = t.Use(cnv, MachineType::AnyTagged()); |
920 t.Return(use); | 920 t.Return(use); |
921 t.Lower(); | 921 t.Lower(); |
922 CHECK_EQ(b, use->InputAt(0)->InputAt(0)); | 922 CHECK_EQ(b, use->InputAt(0)->InputAt(0)); |
923 CHECK_EQ(IrOpcode::kChangeInt31ToTaggedSigned, use->InputAt(0)->opcode()); | 923 CHECK_EQ(IrOpcode::kChangeInt31ToTagged, use->InputAt(0)->opcode()); |
924 } | 924 } |
925 | 925 |
926 | 926 |
927 TEST(LowerBooleanToNumber_tagged_tagged) { | 927 TEST(LowerBooleanToNumber_tagged_tagged) { |
928 // BooleanToNumber(x: kRepTagged) used as MachineType::AnyTagged() | 928 // BooleanToNumber(x: kRepTagged) used as MachineType::AnyTagged() |
929 TestingGraph t(Type::Boolean()); | 929 TestingGraph t(Type::Boolean()); |
930 Node* b = t.p0; | 930 Node* b = t.p0; |
931 Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); | 931 Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); |
932 Node* use = t.Use(cnv, MachineType::AnyTagged()); | 932 Node* use = t.Use(cnv, MachineType::AnyTagged()); |
933 t.Return(use); | 933 t.Return(use); |
934 t.Lower(); | 934 t.Lower(); |
935 CHECK_EQ(cnv, use->InputAt(0)->InputAt(0)); | 935 CHECK_EQ(cnv, use->InputAt(0)->InputAt(0)); |
936 CHECK_EQ(IrOpcode::kChangeInt31ToTaggedSigned, use->InputAt(0)->opcode()); | 936 CHECK_EQ(IrOpcode::kChangeInt31ToTagged, use->InputAt(0)->opcode()); |
937 CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode()); | 937 CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode()); |
938 CHECK(b == cnv->InputAt(0) || b == cnv->InputAt(1)); | 938 CHECK(b == cnv->InputAt(0) || b == cnv->InputAt(1)); |
939 Node* c = t.jsgraph.TrueConstant(); | 939 Node* c = t.jsgraph.TrueConstant(); |
940 CHECK(c == cnv->InputAt(0) || c == cnv->InputAt(1)); | 940 CHECK(c == cnv->InputAt(0) || c == cnv->InputAt(1)); |
941 } | 941 } |
942 | 942 |
943 static Type* test_types[] = {Type::Signed32(), Type::Unsigned32(), | 943 static Type* test_types[] = {Type::Signed32(), Type::Unsigned32(), |
944 Type::Number()}; | 944 Type::Number()}; |
945 | 945 |
946 TEST(LowerNumberCmp_to_int32) { | 946 TEST(LowerNumberCmp_to_int32) { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 | 1214 |
1215 | 1215 |
1216 TEST(InsertChangesAroundInt32Cmp) { | 1216 TEST(InsertChangesAroundInt32Cmp) { |
1217 TestingGraph t(Type::Signed32(), Type::Signed32()); | 1217 TestingGraph t(Type::Signed32(), Type::Signed32()); |
1218 | 1218 |
1219 const Operator* ops[] = {t.machine()->Int32LessThan(), | 1219 const Operator* ops[] = {t.machine()->Int32LessThan(), |
1220 t.machine()->Int32LessThanOrEqual()}; | 1220 t.machine()->Int32LessThanOrEqual()}; |
1221 | 1221 |
1222 for (size_t i = 0; i < arraysize(ops); i++) { | 1222 for (size_t i = 0; i < arraysize(ops); i++) { |
1223 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, | 1223 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, |
1224 IrOpcode::kChangeBitToTagged); | 1224 IrOpcode::kChangeBitToBool); |
1225 } | 1225 } |
1226 } | 1226 } |
1227 | 1227 |
1228 | 1228 |
1229 TEST(InsertChangesAroundUint32Cmp) { | 1229 TEST(InsertChangesAroundUint32Cmp) { |
1230 TestingGraph t(Type::Unsigned32(), Type::Unsigned32()); | 1230 TestingGraph t(Type::Unsigned32(), Type::Unsigned32()); |
1231 | 1231 |
1232 const Operator* ops[] = {t.machine()->Uint32LessThan(), | 1232 const Operator* ops[] = {t.machine()->Uint32LessThan(), |
1233 t.machine()->Uint32LessThanOrEqual()}; | 1233 t.machine()->Uint32LessThanOrEqual()}; |
1234 | 1234 |
1235 for (size_t i = 0; i < arraysize(ops); i++) { | 1235 for (size_t i = 0; i < arraysize(ops); i++) { |
1236 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32, | 1236 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32, |
1237 IrOpcode::kChangeBitToTagged); | 1237 IrOpcode::kChangeBitToBool); |
1238 } | 1238 } |
1239 } | 1239 } |
1240 | 1240 |
1241 | 1241 |
1242 TEST(InsertChangesAroundFloat64Binops) { | 1242 TEST(InsertChangesAroundFloat64Binops) { |
1243 TestingGraph t(Type::Number(), Type::Number()); | 1243 TestingGraph t(Type::Number(), Type::Number()); |
1244 | 1244 |
1245 const Operator* ops[] = { | 1245 const Operator* ops[] = { |
1246 t.machine()->Float64Add(), t.machine()->Float64Sub(), | 1246 t.machine()->Float64Add(), t.machine()->Float64Sub(), |
1247 t.machine()->Float64Mul(), t.machine()->Float64Div(), | 1247 t.machine()->Float64Mul(), t.machine()->Float64Div(), |
1248 t.machine()->Float64Mod(), | 1248 t.machine()->Float64Mod(), |
1249 }; | 1249 }; |
1250 | 1250 |
1251 for (size_t i = 0; i < arraysize(ops); i++) { | 1251 for (size_t i = 0; i < arraysize(ops); i++) { |
1252 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, | 1252 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, |
1253 IrOpcode::kChangeFloat64ToTagged); | 1253 IrOpcode::kChangeFloat64ToTagged); |
1254 } | 1254 } |
1255 } | 1255 } |
1256 | 1256 |
1257 | 1257 |
1258 TEST(InsertChangesAroundFloat64Cmp) { | 1258 TEST(InsertChangesAroundFloat64Cmp) { |
1259 TestingGraph t(Type::Number(), Type::Number()); | 1259 TestingGraph t(Type::Number(), Type::Number()); |
1260 | 1260 |
1261 const Operator* ops[] = {t.machine()->Float64Equal(), | 1261 const Operator* ops[] = {t.machine()->Float64Equal(), |
1262 t.machine()->Float64LessThan(), | 1262 t.machine()->Float64LessThan(), |
1263 t.machine()->Float64LessThanOrEqual()}; | 1263 t.machine()->Float64LessThanOrEqual()}; |
1264 | 1264 |
1265 for (size_t i = 0; i < arraysize(ops); i++) { | 1265 for (size_t i = 0; i < arraysize(ops); i++) { |
1266 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, | 1266 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, |
1267 IrOpcode::kChangeBitToTagged); | 1267 IrOpcode::kChangeBitToBool); |
1268 } | 1268 } |
1269 } | 1269 } |
1270 | 1270 |
1271 | 1271 |
1272 namespace { | 1272 namespace { |
1273 | 1273 |
1274 void CheckFieldAccessArithmetic(FieldAccess access, Node* load_or_store) { | 1274 void CheckFieldAccessArithmetic(FieldAccess access, Node* load_or_store) { |
1275 IntPtrMatcher mindex(load_or_store->InputAt(1)); | 1275 IntPtrMatcher mindex(load_or_store->InputAt(1)); |
1276 CHECK(mindex.Is(access.offset - access.tag())); | 1276 CHECK(mindex.Is(access.offset - access.tag())); |
1277 } | 1277 } |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 t.Return(use); | 1939 t.Return(use); |
1940 t.Lower(); | 1940 t.Lower(); |
1941 | 1941 |
1942 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); | 1942 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); |
1943 } | 1943 } |
1944 } | 1944 } |
1945 | 1945 |
1946 } // namespace compiler | 1946 } // namespace compiler |
1947 } // namespace internal | 1947 } // namespace internal |
1948 } // namespace v8 | 1948 } // namespace v8 |
OLD | NEW |