Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Unified Diff: test/cctest/compiler/test-simplified-lowering.cc

Issue 470593002: Unify MachineType and RepType. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Forgot a RepresentationOf() in arm64. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/cctest/compiler/test-simplified-lowering.cc
diff --git a/test/cctest/compiler/test-simplified-lowering.cc b/test/cctest/compiler/test-simplified-lowering.cc
index 18f4136b904de49f8d6906be929c3c8d260d0a2e..cc3d9d6ee053cb575092931a30e1876e0bbe44f6 100644
--- a/test/cctest/compiler/test-simplified-lowering.cc
+++ b/test/cctest/compiler/test-simplified-lowering.cc
@@ -29,11 +29,9 @@ using namespace v8::internal::compiler;
template <typename ReturnType>
class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> {
public:
- SimplifiedLoweringTester(MachineType p0 = kMachineLast,
- MachineType p1 = kMachineLast,
- MachineType p2 = kMachineLast,
- MachineType p3 = kMachineLast,
- MachineType p4 = kMachineLast)
+ SimplifiedLoweringTester(MachineType p0 = mNone, MachineType p1 = mNone,
+ MachineType p2 = mNone, MachineType p3 = mNone,
+ MachineType p4 = mNone)
: GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4),
typer(this->zone()),
source_positions(this->graph()),
@@ -60,14 +58,14 @@ namespace {
FieldAccess ForJSObjectMap() {
FieldAccess access = {kTaggedBase, JSObject::kMapOffset, Handle<Name>(),
- Type::Any(), kMachineTagged};
+ Type::Any(), mAnyTagged};
return access;
}
FieldAccess ForJSObjectProperties() {
FieldAccess access = {kTaggedBase, JSObject::kPropertiesOffset,
- Handle<Name>(), Type::Any(), kMachineTagged};
+ Handle<Name>(), Type::Any(), mAnyTagged};
return access;
}
@@ -84,7 +82,7 @@ FieldAccess ForArrayBufferBackingStore() {
ElementAccess ForFixedArrayElement() {
ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Any(),
- kMachineTagged};
+ mAnyTagged};
return access;
}
@@ -108,7 +106,7 @@ static Handle<JSObject> TestObject() {
TEST(RunLoadMap) {
- SimplifiedLoweringTester<Object*> t(kMachineTagged);
+ SimplifiedLoweringTester<Object*> t(mAnyTagged);
FieldAccess access = ForJSObjectMap();
Node* load = t.LoadField(access, t.Parameter(0));
t.Return(load);
@@ -126,7 +124,7 @@ TEST(RunLoadMap) {
TEST(RunStoreMap) {
- SimplifiedLoweringTester<int32_t> t(kMachineTagged, kMachineTagged);
+ SimplifiedLoweringTester<int32_t> t(mAnyTagged, mAnyTagged);
FieldAccess access = ForJSObjectMap();
t.StoreField(access, t.Parameter(1), t.Parameter(0));
t.Return(t.jsgraph.TrueConstant());
@@ -146,7 +144,7 @@ TEST(RunStoreMap) {
TEST(RunLoadProperties) {
- SimplifiedLoweringTester<Object*> t(kMachineTagged);
+ SimplifiedLoweringTester<Object*> t(mAnyTagged);
FieldAccess access = ForJSObjectProperties();
Node* load = t.LoadField(access, t.Parameter(0));
t.Return(load);
@@ -164,7 +162,7 @@ TEST(RunLoadProperties) {
TEST(RunLoadStoreMap) {
- SimplifiedLoweringTester<Object*> t(kMachineTagged, kMachineTagged);
+ SimplifiedLoweringTester<Object*> t(mAnyTagged, mAnyTagged);
FieldAccess access = ForJSObjectMap();
Node* load = t.LoadField(access, t.Parameter(0));
t.StoreField(access, t.Parameter(1), load);
@@ -187,7 +185,7 @@ TEST(RunLoadStoreMap) {
TEST(RunLoadStoreFixedArrayIndex) {
- SimplifiedLoweringTester<Object*> t(kMachineTagged);
+ SimplifiedLoweringTester<Object*> t(mAnyTagged);
ElementAccess access = ForFixedArrayElement();
Node* load = t.LoadElement(access, t.Parameter(0), t.Int32Constant(0));
t.StoreElement(access, t.Parameter(0), t.Int32Constant(1), load);
@@ -211,9 +209,9 @@ TEST(RunLoadStoreFixedArrayIndex) {
TEST(RunLoadStoreArrayBuffer) {
- SimplifiedLoweringTester<Object*> t(kMachineTagged);
+ SimplifiedLoweringTester<Object*> t(mAnyTagged);
const int index = 12;
- ElementAccess buffer_access = ForBackingStoreElement(kMachineWord8);
+ ElementAccess buffer_access = ForBackingStoreElement(mInt8);
Node* backing_store =
t.LoadField(ForArrayBufferBackingStore(), t.Parameter(0));
Node* load =
@@ -252,7 +250,7 @@ TEST(RunLoadFieldFromUntaggedBase) {
for (size_t i = 0; i < ARRAY_SIZE(smis); i++) {
int offset = static_cast<int>(i * sizeof(Smi*));
FieldAccess access = {kUntaggedBase, offset, Handle<Name>(),
- Type::Integral32(), kMachineTagged};
+ Type::Integral32(), mAnyTagged};
SimplifiedLoweringTester<Object*> t;
Node* load = t.LoadField(access, t.PointerConstant(smis));
@@ -276,9 +274,9 @@ TEST(RunStoreFieldToUntaggedBase) {
for (size_t i = 0; i < ARRAY_SIZE(smis); i++) {
int offset = static_cast<int>(i * sizeof(Smi*));
FieldAccess access = {kUntaggedBase, offset, Handle<Name>(),
- Type::Integral32(), kMachineTagged};
+ Type::Integral32(), mAnyTagged};
- SimplifiedLoweringTester<Object*> t(kMachineTagged);
+ SimplifiedLoweringTester<Object*> t(mAnyTagged);
Node* p0 = t.Parameter(0);
t.StoreField(access, t.PointerConstant(smis), p0);
t.Return(p0);
@@ -304,7 +302,7 @@ TEST(RunLoadElementFromUntaggedBase) {
for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) { // for element index
int offset = static_cast<int>(i * sizeof(Smi*));
ElementAccess access = {kUntaggedBase, offset, Type::Integral32(),
- kMachineTagged};
+ mAnyTagged};
SimplifiedLoweringTester<Object*> t;
Node* load = t.LoadElement(access, t.PointerConstant(smis),
@@ -332,9 +330,9 @@ TEST(RunStoreElementFromUntaggedBase) {
for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) { // for element index
int offset = static_cast<int>(i * sizeof(Smi*));
ElementAccess access = {kUntaggedBase, offset, Type::Integral32(),
- kMachineTagged};
+ mAnyTagged};
- SimplifiedLoweringTester<Object*> t(kMachineTagged);
+ SimplifiedLoweringTester<Object*> t(mAnyTagged);
Node* p0 = t.Parameter(0);
t.StoreElement(access, t.PointerConstant(smis),
t.Int32Constant(static_cast<int>(j)), p0);
@@ -559,19 +557,19 @@ static void RunAccessTest(MachineType rep, E* original_elements, size_t num) {
TEST(RunAccessTests_uint8) {
uint8_t data[] = {0x07, 0x16, 0x25, 0x34, 0x43, 0x99,
0xab, 0x78, 0x89, 0x19, 0x2b, 0x38};
- RunAccessTest<uint8_t>(kMachineWord8, data, ARRAY_SIZE(data));
+ RunAccessTest<uint8_t>(mInt8, data, ARRAY_SIZE(data));
}
TEST(RunAccessTests_uint16) {
uint16_t data[] = {0x071a, 0x162b, 0x253c, 0x344d, 0x435e, 0x7777};
- RunAccessTest<uint16_t>(kMachineWord16, data, ARRAY_SIZE(data));
+ RunAccessTest<uint16_t>(mInt16, data, ARRAY_SIZE(data));
}
TEST(RunAccessTests_int32) {
int32_t data[] = {-211, 211, 628347, 2000000000, -2000000000, -1, -100000034};
- RunAccessTest<int32_t>(kMachineWord32, data, ARRAY_SIZE(data));
+ RunAccessTest<int32_t>(mInt32, data, ARRAY_SIZE(data));
}
@@ -585,13 +583,13 @@ TEST(RunAccessTests_int64) {
V8_2PART_INT64(0x30313233, 34353637),
V8_2PART_INT64(0xa0a1a2a3, a4a5a6a7),
V8_2PART_INT64(0xf0f1f2f3, f4f5f6f7)};
- RunAccessTest<int64_t>(kMachineWord64, data, ARRAY_SIZE(data));
+ RunAccessTest<int64_t>(mInt64, data, ARRAY_SIZE(data));
}
TEST(RunAccessTests_float64) {
double data[] = {1.25, -1.25, 2.75, 11.0, 11100.8};
- RunAccessTest<double>(kMachineFloat64, data, ARRAY_SIZE(data));
+ RunAccessTest<double>(mFloat64, data, ARRAY_SIZE(data));
}
@@ -599,7 +597,7 @@ TEST(RunAccessTests_Smi) {
Smi* data[] = {Smi::FromInt(-1), Smi::FromInt(-9),
Smi::FromInt(0), Smi::FromInt(666),
Smi::FromInt(77777), Smi::FromInt(Smi::kMaxValue)};
- RunAccessTest<Smi*>(kMachineTagged, data, ARRAY_SIZE(data));
+ RunAccessTest<Smi*>(mAnyTagged, data, ARRAY_SIZE(data));
}
@@ -658,7 +656,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
// Inserts the node as the effect input to the return of the graph.
void Effect(Node* node) { ret->ReplaceInput(1, node); }
- Node* ExampleWithOutput(RepType type) {
+ Node* ExampleWithOutput(MachineType type) {
// TODO(titzer): use parameters with guaranteed representations.
if (type & tInt32) {
return graph()->NewNode(machine()->Int32Add(), jsgraph.Int32Constant(1),
@@ -683,7 +681,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
}
}
- Node* Use(Node* node, RepType type) {
+ Node* Use(Node* node, MachineType type) {
if (type & tInt32) {
return graph()->NewNode(machine()->Int32LessThan(), node,
jsgraph.Int32Constant(1));
@@ -994,7 +992,8 @@ TEST(LowerStringOps_to_rtcalls) {
}
-void CheckChangeInsertion(IrOpcode::Value expected, RepType from, RepType to) {
+void CheckChangeInsertion(IrOpcode::Value expected, MachineType from,
+ MachineType to) {
TestingGraph t(Type::Any());
Node* in = t.ExampleWithOutput(from);
Node* use = t.Use(in, to);
@@ -1123,28 +1122,7 @@ Node* CheckElementAccessArithmetic(ElementAccess access, Node* load_or_store) {
CHECK_EQ(IrOpcode::kInt32Add, index.node()->opcode());
CHECK(index.right().Is(access.header_size - access.tag()));
- int element_size = 0;
- switch (access.representation) {
- case kMachineTagged:
- element_size = kPointerSize;
- break;
- case kMachineWord8:
- element_size = 1;
- break;
- case kMachineWord16:
- element_size = 2;
- break;
- case kMachineWord32:
- element_size = 4;
- break;
- case kMachineWord64:
- case kMachineFloat64:
- element_size = 8;
- break;
- case kMachineLast:
- UNREACHABLE();
- break;
- }
+ int element_size = ElementSizeOf(access.machine_type);
if (element_size != 1) {
Int32BinopMatcher mul(index.left().node());
@@ -1157,18 +1135,8 @@ Node* CheckElementAccessArithmetic(ElementAccess access, Node* load_or_store) {
}
-static const MachineType machine_reps[] = {kMachineWord8, kMachineWord16,
- kMachineWord32, kMachineWord64,
- kMachineFloat64, kMachineTagged};
-
-
-// Representation types corresponding to those above.
-static const RepType rep_types[] = {static_cast<RepType>(rWord32 | tUint32),
- static_cast<RepType>(rWord32 | tUint32),
- static_cast<RepType>(rWord32 | tInt32),
- static_cast<RepType>(rWord64),
- static_cast<RepType>(rFloat64 | tNumber),
- static_cast<RepType>(rTagged | tAny)};
+static const MachineType machine_reps[] = {rBit, mInt8, mInt16, mInt32,
+ mInt64, mFloat64, mAnyTagged};
TEST(LowerLoadField_to_load) {
@@ -1180,7 +1148,7 @@ TEST(LowerLoadField_to_load) {
Node* load =
t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start);
- Node* use = t.Use(load, rep_types[i]);
+ Node* use = t.Use(load, machine_reps[i]);
t.Return(use);
t.Lower();
CHECK_EQ(IrOpcode::kLoad, load->opcode());
@@ -1201,7 +1169,7 @@ TEST(LowerStoreField_to_store) {
Handle<Name>::null(), Type::Any(), machine_reps[i]};
- Node* val = t.ExampleWithOutput(rep_types[i]);
+ Node* val = t.ExampleWithOutput(machine_reps[i]);
Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0,
val, t.start, t.start);
t.Effect(store);
@@ -1211,10 +1179,10 @@ TEST(LowerStoreField_to_store) {
CheckFieldAccessArithmetic(access, store);
StoreRepresentation rep = OpParameter<StoreRepresentation>(store);
- if (rep_types[i] & rTagged) {
+ if (machine_reps[i] & rTagged) {
CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind);
}
- CHECK_EQ(machine_reps[i], rep.rep);
+ CHECK_EQ(machine_reps[i], rep.machine_type);
}
}
@@ -1228,7 +1196,7 @@ TEST(LowerLoadElement_to_load) {
Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0,
t.p1, t.start);
- Node* use = t.Use(load, rep_types[i]);
+ Node* use = t.Use(load, machine_reps[i]);
t.Return(use);
t.Lower();
CHECK_EQ(IrOpcode::kLoad, load->opcode());
@@ -1248,7 +1216,7 @@ TEST(LowerStoreElement_to_store) {
ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
Type::Any(), machine_reps[i]};
- Node* val = t.ExampleWithOutput(rep_types[i]);
+ Node* val = t.ExampleWithOutput(machine_reps[i]);
Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0,
t.p1, val, t.start, t.start);
t.Effect(store);
@@ -1258,10 +1226,10 @@ TEST(LowerStoreElement_to_store) {
CheckElementAccessArithmetic(access, store);
StoreRepresentation rep = OpParameter<StoreRepresentation>(store);
- if (rep_types[i] & rTagged) {
+ if (machine_reps[i] & rTagged) {
CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind);
}
- CHECK_EQ(machine_reps[i], rep.rep);
+ CHECK_EQ(machine_reps[i], rep.machine_type);
}
}
@@ -1271,7 +1239,7 @@ TEST(InsertChangeForLoadElementIndex) {
// Load(obj, Int32Add(Int32Mul(ChangeTaggedToInt32(index), #k), #k))
TestingGraph t(Type::Any(), Type::Signed32());
ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
- kMachineTagged};
+ mAnyTagged};
Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0,
t.p1, t.start);
@@ -1290,7 +1258,7 @@ TEST(InsertChangeForStoreElementIndex) {
// Store(obj, Int32Add(Int32Mul(ChangeTaggedToInt32(index), #k), #k), val)
TestingGraph t(Type::Any(), Type::Signed32());
ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
- kMachineTagged};
+ mAnyTagged};
Node* store =
t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, t.p1,
@@ -1309,7 +1277,7 @@ TEST(InsertChangeForLoadElement) {
// TODO(titzer): test all load/store representation change insertions.
TestingGraph t(Type::Any(), Type::Signed32());
ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
- kMachineFloat64};
+ mFloat64};
Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0,
t.p1, t.start);
@@ -1325,7 +1293,7 @@ TEST(InsertChangeForLoadField) {
// TODO(titzer): test all load/store representation change insertions.
TestingGraph t(Type::Any(), Type::Signed32());
FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
- Handle<Name>::null(), Type::Any(), kMachineFloat64};
+ Handle<Name>::null(), Type::Any(), mFloat64};
Node* load =
t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start);
@@ -1341,7 +1309,7 @@ TEST(InsertChangeForStoreElement) {
// TODO(titzer): test all load/store representation change insertions.
TestingGraph t(Type::Any(), Type::Signed32());
ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
- kMachineFloat64};
+ mFloat64};
Node* store =
t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0,
@@ -1359,7 +1327,7 @@ TEST(InsertChangeForStoreField) {
// TODO(titzer): test all load/store representation change insertions.
TestingGraph t(Type::Any(), Type::Signed32());
FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
- Handle<Name>::null(), Type::Any(), kMachineFloat64};
+ Handle<Name>::null(), Type::Any(), mFloat64};
Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0,
t.p1, t.start, t.start);

Powered by Google App Engine
This is Rietveld 408576698