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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 MachineType::AnyTagged(), Type::Signed32()); | 1129 MachineType::AnyTagged(), Type::Signed32()); |
1130 | 1130 |
1131 CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, MachineType::Uint32(), | 1131 CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, MachineType::Uint32(), |
1132 MachineType::Float64(), Type::Unsigned32()); | 1132 MachineType::Float64(), Type::Unsigned32()); |
1133 CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, MachineType::Uint32(), | 1133 CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, MachineType::Uint32(), |
1134 MachineType::AnyTagged(), Type::Unsigned32()); | 1134 MachineType::AnyTagged(), Type::Unsigned32()); |
1135 } | 1135 } |
1136 | 1136 |
1137 static void CheckChangesAroundBinop(TestingGraph* t, const Operator* op, | 1137 static void CheckChangesAroundBinop(TestingGraph* t, const Operator* op, |
1138 IrOpcode::Value input_change, | 1138 IrOpcode::Value input_change, |
1139 IrOpcode::Value output_change, | 1139 IrOpcode::Value output_change, Type* type) { |
1140 Type* type = Type::Any()) { | |
1141 Node* binop = | 1140 Node* binop = |
1142 op->ControlInputCount() == 0 | 1141 op->ControlInputCount() == 0 |
1143 ? t->graph()->NewNode(op, t->p0, t->p1) | 1142 ? t->graph()->NewNode(op, t->p0, t->p1) |
1144 : t->graph()->NewNode(op, t->p0, t->p1, t->graph()->start()); | 1143 : t->graph()->NewNode(op, t->p0, t->p1, t->graph()->start()); |
1145 NodeProperties::SetType(binop, type); | 1144 NodeProperties::SetType(binop, type); |
1146 t->Return(binop); | 1145 t->Return(binop); |
1147 t->Lower(); | 1146 t->Lower(); |
1148 CHECK_EQ(input_change, binop->InputAt(0)->opcode()); | 1147 CHECK_EQ(input_change, binop->InputAt(0)->opcode()); |
1149 CHECK_EQ(input_change, binop->InputAt(1)->opcode()); | 1148 CHECK_EQ(input_change, binop->InputAt(1)->opcode()); |
1150 CHECK_EQ(t->p0, binop->InputAt(0)->InputAt(0)); | 1149 CHECK_EQ(t->p0, binop->InputAt(0)->InputAt(0)); |
(...skipping 22 matching lines...) Expand all Loading... |
1173 | 1172 |
1174 | 1173 |
1175 TEST(InsertChangesAroundInt32Cmp) { | 1174 TEST(InsertChangesAroundInt32Cmp) { |
1176 TestingGraph t(Type::Signed32(), Type::Signed32()); | 1175 TestingGraph t(Type::Signed32(), Type::Signed32()); |
1177 | 1176 |
1178 const Operator* ops[] = {t.machine()->Int32LessThan(), | 1177 const Operator* ops[] = {t.machine()->Int32LessThan(), |
1179 t.machine()->Int32LessThanOrEqual()}; | 1178 t.machine()->Int32LessThanOrEqual()}; |
1180 | 1179 |
1181 for (size_t i = 0; i < arraysize(ops); i++) { | 1180 for (size_t i = 0; i < arraysize(ops); i++) { |
1182 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, | 1181 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, |
1183 IrOpcode::kChangeBitToTagged); | 1182 IrOpcode::kChangeBitToTagged, Type::Boolean()); |
1184 } | 1183 } |
1185 } | 1184 } |
1186 | 1185 |
1187 | 1186 |
1188 TEST(InsertChangesAroundUint32Cmp) { | 1187 TEST(InsertChangesAroundUint32Cmp) { |
1189 TestingGraph t(Type::Unsigned32(), Type::Unsigned32()); | 1188 TestingGraph t(Type::Unsigned32(), Type::Unsigned32()); |
1190 | 1189 |
1191 const Operator* ops[] = {t.machine()->Uint32LessThan(), | 1190 const Operator* ops[] = {t.machine()->Uint32LessThan(), |
1192 t.machine()->Uint32LessThanOrEqual()}; | 1191 t.machine()->Uint32LessThanOrEqual()}; |
1193 | 1192 |
1194 for (size_t i = 0; i < arraysize(ops); i++) { | 1193 for (size_t i = 0; i < arraysize(ops); i++) { |
1195 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32, | 1194 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32, |
1196 IrOpcode::kChangeBitToTagged); | 1195 IrOpcode::kChangeBitToTagged, Type::Boolean()); |
1197 } | 1196 } |
1198 } | 1197 } |
1199 | 1198 |
1200 | 1199 |
1201 TEST(InsertChangesAroundFloat64Binops) { | 1200 TEST(InsertChangesAroundFloat64Binops) { |
1202 TestingGraph t(Type::Number(), Type::Number()); | 1201 TestingGraph t(Type::Number(), Type::Number()); |
1203 | 1202 |
1204 const Operator* ops[] = { | 1203 const Operator* ops[] = { |
1205 t.machine()->Float64Add(), t.machine()->Float64Sub(), | 1204 t.machine()->Float64Add(), t.machine()->Float64Sub(), |
1206 t.machine()->Float64Mul(), t.machine()->Float64Div(), | 1205 t.machine()->Float64Mul(), t.machine()->Float64Div(), |
1207 t.machine()->Float64Mod(), | 1206 t.machine()->Float64Mod(), |
1208 }; | 1207 }; |
1209 | 1208 |
1210 for (size_t i = 0; i < arraysize(ops); i++) { | 1209 for (size_t i = 0; i < arraysize(ops); i++) { |
1211 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, | 1210 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, |
1212 IrOpcode::kChangeFloat64ToTagged, Type::Number()); | 1211 IrOpcode::kChangeFloat64ToTagged, Type::Number()); |
1213 } | 1212 } |
1214 } | 1213 } |
1215 | 1214 |
1216 | 1215 |
1217 TEST(InsertChangesAroundFloat64Cmp) { | 1216 TEST(InsertChangesAroundFloat64Cmp) { |
1218 TestingGraph t(Type::Number(), Type::Number()); | 1217 TestingGraph t(Type::Number(), Type::Number()); |
1219 | 1218 |
1220 const Operator* ops[] = {t.machine()->Float64Equal(), | 1219 const Operator* ops[] = {t.machine()->Float64Equal(), |
1221 t.machine()->Float64LessThan(), | 1220 t.machine()->Float64LessThan(), |
1222 t.machine()->Float64LessThanOrEqual()}; | 1221 t.machine()->Float64LessThanOrEqual()}; |
1223 | 1222 |
1224 for (size_t i = 0; i < arraysize(ops); i++) { | 1223 for (size_t i = 0; i < arraysize(ops); i++) { |
1225 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, | 1224 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, |
1226 IrOpcode::kChangeBitToTagged); | 1225 IrOpcode::kChangeBitToTagged, Type::Boolean()); |
1227 } | 1226 } |
1228 } | 1227 } |
1229 | 1228 |
1230 | 1229 |
1231 namespace { | 1230 namespace { |
1232 | 1231 |
1233 void CheckFieldAccessArithmetic(FieldAccess access, Node* load_or_store) { | 1232 void CheckFieldAccessArithmetic(FieldAccess access, Node* load_or_store) { |
1234 IntPtrMatcher mindex(load_or_store->InputAt(1)); | 1233 IntPtrMatcher mindex(load_or_store->InputAt(1)); |
1235 CHECK(mindex.Is(access.offset - access.tag())); | 1234 CHECK(mindex.Is(access.offset - access.tag())); |
1236 } | 1235 } |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1902 t.Return(use); | 1901 t.Return(use); |
1903 t.Lower(); | 1902 t.Lower(); |
1904 | 1903 |
1905 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); | 1904 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); |
1906 } | 1905 } |
1907 } | 1906 } |
1908 | 1907 |
1909 } // namespace compiler | 1908 } // namespace compiler |
1910 } // namespace internal | 1909 } // namespace internal |
1911 } // namespace v8 | 1910 } // namespace v8 |
OLD | NEW |