| 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/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
| 10 #include "src/compiler/effect-control-linearizer.h" | 10 #include "src/compiler/effect-control-linearizer.h" |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 t.Return(use); | 892 t.Return(use); |
| 893 t.Lower(); | 893 t.Lower(); |
| 894 CHECK_EQ(IrOpcode::kChangeBitToTagged, use->InputAt(0)->opcode()); | 894 CHECK_EQ(IrOpcode::kChangeBitToTagged, use->InputAt(0)->opcode()); |
| 895 Node* cmp = use->InputAt(0)->InputAt(0); | 895 Node* cmp = use->InputAt(0)->InputAt(0); |
| 896 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode()); | 896 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode()); |
| 897 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1)); | 897 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1)); |
| 898 Node* f = t.jsgraph.FalseConstant(); | 898 Node* f = t.jsgraph.FalseConstant(); |
| 899 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1)); | 899 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1)); |
| 900 } | 900 } |
| 901 | 901 |
| 902 | |
| 903 TEST(LowerBooleanToNumber_bit_int32) { | |
| 904 // BooleanToNumber(x: kRepBit) used as MachineType::Int32() | |
| 905 TestingGraph t(Type::Boolean()); | |
| 906 Node* b = t.ExampleWithOutput(MachineType::Bool()); | |
| 907 Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); | |
| 908 Node* use = t.Use(cnv, MachineType::Int32()); | |
| 909 t.Return(use); | |
| 910 t.Lower(); | |
| 911 CHECK_EQ(b, use->InputAt(0)); | |
| 912 } | |
| 913 | |
| 914 | |
| 915 TEST(LowerBooleanToNumber_tagged_int32) { | |
| 916 // BooleanToNumber(x: kRepTagged) used as MachineType::Int32() | |
| 917 TestingGraph t(Type::Boolean()); | |
| 918 Node* b = t.p0; | |
| 919 Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); | |
| 920 Node* use = t.Use(cnv, MachineType::Int32()); | |
| 921 t.Return(use); | |
| 922 t.Lower(); | |
| 923 CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode()); | |
| 924 CHECK(b == cnv->InputAt(0) || b == cnv->InputAt(1)); | |
| 925 Node* c = t.jsgraph.TrueConstant(); | |
| 926 CHECK(c == cnv->InputAt(0) || c == cnv->InputAt(1)); | |
| 927 } | |
| 928 | |
| 929 | |
| 930 TEST(LowerBooleanToNumber_bit_tagged) { | |
| 931 // BooleanToNumber(x: kRepBit) used as MachineType::AnyTagged() | |
| 932 TestingGraph t(Type::Boolean()); | |
| 933 Node* b = t.ExampleWithOutput(MachineType::Bool()); | |
| 934 Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); | |
| 935 Node* use = t.Use(cnv, MachineType::AnyTagged()); | |
| 936 t.Return(use); | |
| 937 t.Lower(); | |
| 938 CHECK_EQ(b, use->InputAt(0)->InputAt(0)); | |
| 939 CHECK_EQ(IrOpcode::kChangeInt31ToTaggedSigned, use->InputAt(0)->opcode()); | |
| 940 } | |
| 941 | |
| 942 | |
| 943 TEST(LowerBooleanToNumber_tagged_tagged) { | |
| 944 // BooleanToNumber(x: kRepTagged) used as MachineType::AnyTagged() | |
| 945 TestingGraph t(Type::Boolean()); | |
| 946 Node* b = t.p0; | |
| 947 Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); | |
| 948 Node* use = t.Use(cnv, MachineType::AnyTagged()); | |
| 949 t.Return(use); | |
| 950 t.Lower(); | |
| 951 CHECK_EQ(cnv, use->InputAt(0)->InputAt(0)); | |
| 952 CHECK_EQ(IrOpcode::kChangeInt31ToTaggedSigned, use->InputAt(0)->opcode()); | |
| 953 CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode()); | |
| 954 CHECK(b == cnv->InputAt(0) || b == cnv->InputAt(1)); | |
| 955 Node* c = t.jsgraph.TrueConstant(); | |
| 956 CHECK(c == cnv->InputAt(0) || c == cnv->InputAt(1)); | |
| 957 } | |
| 958 | |
| 959 static Type* test_types[] = {Type::Signed32(), Type::Unsigned32(), | 902 static Type* test_types[] = {Type::Signed32(), Type::Unsigned32(), |
| 960 Type::Number()}; | 903 Type::Number()}; |
| 961 | 904 |
| 962 TEST(LowerNumberCmp_to_int32) { | 905 TEST(LowerNumberCmp_to_int32) { |
| 963 TestingGraph t(Type::Signed32(), Type::Signed32()); | 906 TestingGraph t(Type::Signed32(), Type::Signed32()); |
| 964 | 907 |
| 965 t.CheckLoweringBinop(IrOpcode::kWord32Equal, t.simplified()->NumberEqual()); | 908 t.CheckLoweringBinop(IrOpcode::kWord32Equal, t.simplified()->NumberEqual()); |
| 966 t.CheckLoweringBinop(IrOpcode::kInt32LessThan, | 909 t.CheckLoweringBinop(IrOpcode::kInt32LessThan, |
| 967 t.simplified()->NumberLessThan()); | 910 t.simplified()->NumberLessThan()); |
| 968 t.CheckLoweringBinop(IrOpcode::kInt32LessThanOrEqual, | 911 t.CheckLoweringBinop(IrOpcode::kInt32LessThanOrEqual, |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 t.Return(use); | 1902 t.Return(use); |
| 1960 t.Lower(); | 1903 t.Lower(); |
| 1961 | 1904 |
| 1962 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); | 1905 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); |
| 1963 } | 1906 } |
| 1964 } | 1907 } |
| 1965 | 1908 |
| 1966 } // namespace compiler | 1909 } // namespace compiler |
| 1967 } // namespace internal | 1910 } // namespace internal |
| 1968 } // namespace v8 | 1911 } // namespace v8 |
| OLD | NEW |