| 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 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 CheckChangeInsertion(IrOpcode::kChangeTaggedToUint32, | 1165 CheckChangeInsertion(IrOpcode::kChangeTaggedToUint32, |
| 1166 MachineType::AnyTagged(), MachineType::Uint32(), | 1166 MachineType::AnyTagged(), MachineType::Uint32(), |
| 1167 Type::Unsigned32()); | 1167 Type::Unsigned32()); |
| 1168 | 1168 |
| 1169 CheckChangeInsertion(IrOpcode::kChangeFloat64ToTagged, MachineType::Float64(), | 1169 CheckChangeInsertion(IrOpcode::kChangeFloat64ToTagged, MachineType::Float64(), |
| 1170 MachineType::AnyTagged()); | 1170 MachineType::AnyTagged()); |
| 1171 CheckChangeInsertion(IrOpcode::kChangeTaggedToFloat64, | 1171 CheckChangeInsertion(IrOpcode::kChangeTaggedToFloat64, |
| 1172 MachineType::AnyTagged(), MachineType::Float64()); | 1172 MachineType::AnyTagged(), MachineType::Float64()); |
| 1173 | 1173 |
| 1174 CheckChangeInsertion(IrOpcode::kChangeInt32ToFloat64, MachineType::Int32(), | 1174 CheckChangeInsertion(IrOpcode::kChangeInt32ToFloat64, MachineType::Int32(), |
| 1175 MachineType::Float64()); | 1175 MachineType::Float64(), Type::Signed32()); |
| 1176 CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, MachineType::Int32(), | 1176 CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, MachineType::Int32(), |
| 1177 MachineType::AnyTagged()); | 1177 MachineType::AnyTagged(), Type::Signed32()); |
| 1178 | 1178 |
| 1179 CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, MachineType::Uint32(), | 1179 CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, MachineType::Uint32(), |
| 1180 MachineType::Float64()); | 1180 MachineType::Float64(), Type::Unsigned32()); |
| 1181 CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, MachineType::Uint32(), | 1181 CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, MachineType::Uint32(), |
| 1182 MachineType::AnyTagged()); | 1182 MachineType::AnyTagged(), Type::Unsigned32()); |
| 1183 } | 1183 } |
| 1184 | 1184 |
| 1185 | |
| 1186 static void CheckChangesAroundBinop(TestingGraph* t, const Operator* op, | 1185 static void CheckChangesAroundBinop(TestingGraph* t, const Operator* op, |
| 1187 IrOpcode::Value input_change, | 1186 IrOpcode::Value input_change, |
| 1188 IrOpcode::Value output_change) { | 1187 IrOpcode::Value output_change, |
| 1188 Type* type = Type::Any()) { |
| 1189 Node* binop = | 1189 Node* binop = |
| 1190 op->ControlInputCount() == 0 | 1190 op->ControlInputCount() == 0 |
| 1191 ? t->graph()->NewNode(op, t->p0, t->p1) | 1191 ? t->graph()->NewNode(op, t->p0, t->p1) |
| 1192 : t->graph()->NewNode(op, t->p0, t->p1, t->graph()->start()); | 1192 : t->graph()->NewNode(op, t->p0, t->p1, t->graph()->start()); |
| 1193 NodeProperties::SetType(binop, type); |
| 1193 t->Return(binop); | 1194 t->Return(binop); |
| 1194 t->Lower(); | 1195 t->Lower(); |
| 1195 CHECK_EQ(input_change, binop->InputAt(0)->opcode()); | 1196 CHECK_EQ(input_change, binop->InputAt(0)->opcode()); |
| 1196 CHECK_EQ(input_change, binop->InputAt(1)->opcode()); | 1197 CHECK_EQ(input_change, binop->InputAt(1)->opcode()); |
| 1197 CHECK_EQ(t->p0, binop->InputAt(0)->InputAt(0)); | 1198 CHECK_EQ(t->p0, binop->InputAt(0)->InputAt(0)); |
| 1198 CHECK_EQ(t->p1, binop->InputAt(1)->InputAt(0)); | 1199 CHECK_EQ(t->p1, binop->InputAt(1)->InputAt(0)); |
| 1199 CHECK_EQ(output_change, t->ret->InputAt(0)->opcode()); | 1200 CHECK_EQ(output_change, t->ret->InputAt(0)->opcode()); |
| 1200 CHECK_EQ(binop, t->ret->InputAt(0)->InputAt(0)); | 1201 CHECK_EQ(binop, t->ret->InputAt(0)->InputAt(0)); |
| 1201 } | 1202 } |
| 1202 | 1203 |
| 1203 | 1204 |
| 1204 TEST(InsertChangesAroundInt32Binops) { | 1205 TEST(InsertChangesAroundInt32Binops) { |
| 1205 TestingGraph t(Type::Signed32(), Type::Signed32()); | 1206 TestingGraph t(Type::Signed32(), Type::Signed32()); |
| 1206 | 1207 |
| 1207 const Operator* ops[] = {t.machine()->Int32Add(), t.machine()->Int32Sub(), | 1208 const Operator* ops[] = {t.machine()->Int32Add(), t.machine()->Int32Sub(), |
| 1208 t.machine()->Int32Mul(), t.machine()->Int32Div(), | 1209 t.machine()->Int32Mul(), t.machine()->Int32Div(), |
| 1209 t.machine()->Int32Mod(), t.machine()->Word32And(), | 1210 t.machine()->Int32Mod(), t.machine()->Word32And(), |
| 1210 t.machine()->Word32Or(), t.machine()->Word32Xor(), | 1211 t.machine()->Word32Or(), t.machine()->Word32Xor(), |
| 1211 t.machine()->Word32Shl(), t.machine()->Word32Sar()}; | 1212 t.machine()->Word32Shl(), t.machine()->Word32Sar()}; |
| 1212 | 1213 |
| 1213 for (size_t i = 0; i < arraysize(ops); i++) { | 1214 for (size_t i = 0; i < arraysize(ops); i++) { |
| 1214 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, | 1215 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, |
| 1215 IrOpcode::kChangeInt32ToTagged); | 1216 IrOpcode::kChangeInt32ToTagged, Type::Signed32()); |
| 1217 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, |
| 1218 IrOpcode::kChangeInt32ToTagged, Type::Signed32()); |
| 1216 } | 1219 } |
| 1217 } | 1220 } |
| 1218 | 1221 |
| 1219 | 1222 |
| 1220 TEST(InsertChangesAroundInt32Cmp) { | 1223 TEST(InsertChangesAroundInt32Cmp) { |
| 1221 TestingGraph t(Type::Signed32(), Type::Signed32()); | 1224 TestingGraph t(Type::Signed32(), Type::Signed32()); |
| 1222 | 1225 |
| 1223 const Operator* ops[] = {t.machine()->Int32LessThan(), | 1226 const Operator* ops[] = {t.machine()->Int32LessThan(), |
| 1224 t.machine()->Int32LessThanOrEqual()}; | 1227 t.machine()->Int32LessThanOrEqual()}; |
| 1225 | 1228 |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1945 t.Return(use); | 1948 t.Return(use); |
| 1946 t.Lower(); | 1949 t.Lower(); |
| 1947 | 1950 |
| 1948 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); | 1951 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); |
| 1949 } | 1952 } |
| 1950 } | 1953 } |
| 1951 | 1954 |
| 1952 } // namespace compiler | 1955 } // namespace compiler |
| 1953 } // namespace internal | 1956 } // namespace internal |
| 1954 } // namespace v8 | 1957 } // namespace v8 |
| OLD | NEW |