Commit a86db19e authored by jarin's avatar jarin Committed by Commit bot

[turbofan] Limit the load/store machine types to the ones we actually use.

Review URL: https://codereview.chromium.org/1333353005

Cr-Commit-Position: refs/heads/master@{#30725}
parent 3ee9a0e1
......@@ -183,15 +183,8 @@ CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) {
V(MachUint32) \
V(MachInt64) \
V(MachUint64) \
V(MachAnyTagged) \
V(RepBit) \
V(RepWord8) \
V(RepWord16) \
V(RepWord32) \
V(RepWord64) \
V(RepFloat32) \
V(RepFloat64) \
V(RepTagged)
V(MachPtr) \
V(MachAnyTagged)
struct MachineOperatorGlobalCache {
......@@ -279,7 +272,7 @@ static base::LazyInstance<MachineOperatorGlobalCache>::type kCache =
MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, MachineType word,
Flags flags)
: zone_(zone), cache_(kCache.Get()), word_(word), flags_(flags) {
: cache_(kCache.Get()), word_(word), flags_(flags) {
DCHECK(word == kRepWord32 || word == kRepWord64);
}
......@@ -322,10 +315,8 @@ const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) {
default:
break;
}
// Uncached.
return new (zone_) Operator1<LoadRepresentation>( // --
IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, "Load", 2, 1, 1,
1, 1, 0, rep);
UNREACHABLE();
return nullptr;
}
......@@ -346,10 +337,8 @@ const Operator* MachineOperatorBuilder::Store(StoreRepresentation rep) {
default:
break;
}
// Uncached.
return new (zone_) Operator1<StoreRepresentation>( // --
IrOpcode::kStore, Operator::kNoRead | Operator::kNoThrow, "Store", 3, 1,
1, 0, 1, 0, rep);
UNREACHABLE();
return nullptr;
}
......@@ -364,10 +353,8 @@ const Operator* MachineOperatorBuilder::CheckedLoad(
default:
break;
}
// Uncached.
return new (zone_) Operator1<CheckedLoadRepresentation>(
IrOpcode::kCheckedLoad, Operator::kNoThrow | Operator::kNoWrite,
"CheckedLoad", 3, 1, 1, 1, 1, 0, rep);
UNREACHABLE();
return nullptr;
}
......@@ -382,10 +369,8 @@ const Operator* MachineOperatorBuilder::CheckedStore(
default:
break;
}
// Uncached.
return new (zone_) Operator1<CheckedStoreRepresentation>(
IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow,
"CheckedStore", 4, 1, 1, 0, 1, 0, rep);
UNREACHABLE();
return nullptr;
}
} // namespace compiler
......
......@@ -297,7 +297,6 @@ class MachineOperatorBuilder final : public ZoneObject {
#undef PSEUDO_OP_LIST
private:
Zone* const zone_;
MachineOperatorGlobalCache const& cache_;
MachineType const word_;
Flags const flags_;
......
......@@ -745,17 +745,6 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
}
}
Node* ExampleWithTypeAndRep(Type* type, MachineType mach_type) {
FieldAccess access = {kUntaggedBase, 0, Handle<Name>::null(), type,
mach_type};
// TODO(titzer): using loads here just to force the representation is ugly.
Node* node = graph()->NewNode(simplified()->LoadField(access),
jsgraph.IntPtrConstant(0), graph()->start(),
graph()->start());
NodeProperties::SetBounds(node, Bounds(type));
return node;
}
Node* Use(Node* node, MachineType type) {
if (type & kTypeInt32) {
return graph()->NewNode(machine()->Int32LessThan(), node,
......@@ -1069,7 +1058,7 @@ TEST(LowerNumberToInt32_to_ChangeTaggedToInt32) {
TEST(LowerNumberToInt32_to_TruncateFloat64ToInt32) {
// NumberToInt32(x: kRepFloat64) used as kMachInt32
TestingGraph t(Type::Number());
Node* p0 = t.ExampleWithTypeAndRep(Type::Number(), kMachFloat64);
Node* p0 = t.ExampleWithOutput(kMachFloat64);
Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), p0);
Node* use = t.Use(trunc, kMachInt32);
t.Return(use);
......@@ -1158,7 +1147,7 @@ TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32_with_change) {
TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32_uint32) {
// NumberToUint32(x: kRepFloat64) used as kRepWord32
TestingGraph t(Type::Unsigned32());
Node* input = t.ExampleWithTypeAndRep(Type::Number(), kMachFloat64);
Node* input = t.ExampleWithOutput(kMachFloat64);
Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), input);
Node* use = t.Use(trunc, kRepWord32);
t.Return(use);
......@@ -1167,58 +1156,6 @@ TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32_uint32) {
}
TEST(LowerNumberToUI32_of_Float64_used_as_word32) {
// NumberTo(Int,Uint)32(x: kRepFloat64 | kType(Int,Uint)32) used as
// kType(Int,Uint)32 | kRepWord32
Type* types[] = {Type::Signed32(), Type::Unsigned32()};
MachineType mach[] = {kTypeInt32, kTypeUint32, kMachNone};
for (int i = 0; i < 2; i++) {
for (int u = 0; u < 3; u++) {
TestingGraph t(types[i]);
Node* input = t.ExampleWithTypeAndRep(
types[i], static_cast<MachineType>(kRepFloat64 | mach[i]));
const Operator* op = i == 0 ? t.simplified()->NumberToInt32()
: t.simplified()->NumberToUint32();
Node* trunc = t.graph()->NewNode(op, input);
Node* use = t.Use(trunc, static_cast<MachineType>(kRepWord32 | mach[u]));
t.Return(use);
t.Lower();
IrOpcode::Value opcode = i == 0 ? IrOpcode::kChangeFloat64ToInt32
: IrOpcode::kChangeFloat64ToUint32;
CheckChangeOf(opcode, input, use->InputAt(0));
}
}
}
TEST(LowerNumberToUI32_of_Float64_used_as_tagged) {
// NumberTo(Int,Uint)32(x: kRepFloat64 | kType(Int,Uint)32) used as
// kType(Int,Uint)32 | kRepTagged
Type* types[] = {Type::Signed32(), Type::Unsigned32(), Type::Any()};
MachineType mach[] = {kTypeInt32, kTypeUint32, kMachNone};
for (int i = 0; i < 2; i++) {
for (int u = 0; u < 3; u++) {
TestingGraph t(types[i]);
Node* input = t.ExampleWithTypeAndRep(
types[i], static_cast<MachineType>(kRepFloat64 | mach[i]));
const Operator* op = i == 0 ? t.simplified()->NumberToInt32()
: t.simplified()->NumberToUint32();
Node* trunc = t.graph()->NewNode(op, input);
// TODO(titzer): we use the store here to force the representation.
FieldAccess access = {kTaggedBase, 0, Handle<Name>(), types[u],
static_cast<MachineType>(mach[u] | kRepTagged)};
Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0,
trunc, t.start, t.start);
t.Effect(store);
t.Lower();
CheckChangeOf(IrOpcode::kChangeFloat64ToTagged, input, store->InputAt(2));
}
}
}
TEST(LowerReferenceEqual_to_wordeq) {
TestingGraph t(Type::Any(), Type::Any());
IrOpcode::Value opcode =
......@@ -1397,8 +1334,8 @@ Node* CheckElementAccessArithmetic(ElementAccess access, Node* load_or_store) {
}
const MachineType kMachineReps[] = {kRepBit, kMachInt8, kMachInt16,
kMachInt32, kMachInt64, kMachFloat64,
const MachineType kMachineReps[] = {kMachInt8, kMachInt16, kMachInt32,
kMachUint32, kMachInt64, kMachFloat64,
kMachAnyTagged};
} // namespace
......
......@@ -1492,7 +1492,7 @@ TEST_F(MachineOperatorReducerTest,
TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32And) {
const StoreRepresentation rep(kRepWord8, kNoWriteBarrier);
const StoreRepresentation rep(kMachUint8, kNoWriteBarrier);
Node* const base = Parameter(0);
Node* const index = Parameter(1);
Node* const value = Parameter(2);
......@@ -1514,7 +1514,7 @@ TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32And) {
TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32SarAndWord32Shl) {
const StoreRepresentation rep(kRepWord8, kNoWriteBarrier);
const StoreRepresentation rep(kMachUint8, kNoWriteBarrier);
Node* const base = Parameter(0);
Node* const index = Parameter(1);
Node* const value = Parameter(2);
......@@ -1538,7 +1538,7 @@ TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32SarAndWord32Shl) {
TEST_F(MachineOperatorReducerTest, StoreRepWord16WithWord32And) {
const StoreRepresentation rep(kRepWord16, kNoWriteBarrier);
const StoreRepresentation rep(kMachUint16, kNoWriteBarrier);
Node* const base = Parameter(0);
Node* const index = Parameter(1);
Node* const value = Parameter(2);
......@@ -1560,7 +1560,7 @@ TEST_F(MachineOperatorReducerTest, StoreRepWord16WithWord32And) {
TEST_F(MachineOperatorReducerTest, StoreRepWord16WithWord32SarAndWord32Shl) {
const StoreRepresentation rep(kRepWord16, kNoWriteBarrier);
const StoreRepresentation rep(kMachUint16, kNoWriteBarrier);
Node* const base = Parameter(0);
Node* const index = Parameter(1);
Node* const value = Parameter(2);
......
......@@ -32,11 +32,10 @@ namespace {
const MachineType kMachineReps[] = {kRepWord32, kRepWord64};
const MachineType kMachineTypes[] = {
kMachFloat32, kMachFloat64, kMachInt8, kMachUint8, kMachInt16,
kMachUint16, kMachInt32, kMachUint32, kMachInt64, kMachUint64,
kMachPtr, kMachAnyTagged, kRepBit, kRepWord8, kRepWord16,
kRepWord32, kRepWord64, kRepFloat32, kRepFloat64, kRepTagged};
const MachineType kMachineTypesForAccess[] = {
kMachFloat32, kMachFloat64, kMachInt8, kMachUint8, kMachInt16,
kMachUint16, kMachInt32, kMachUint32, kMachInt64, kMachUint64,
kMachPtr, kMachAnyTagged, kMachPtr};
} // namespace
......@@ -84,9 +83,10 @@ TEST_P(MachineLoadOperatorTest, ParameterIsCorrect) {
}
INSTANTIATE_TEST_CASE_P(MachineOperatorTest, MachineLoadOperatorTest,
::testing::Combine(::testing::ValuesIn(kMachineReps),
::testing::ValuesIn(kMachineTypes)));
INSTANTIATE_TEST_CASE_P(
MachineOperatorTest, MachineLoadOperatorTest,
::testing::Combine(::testing::ValuesIn(kMachineReps),
::testing::ValuesIn(kMachineTypesForAccess)));
// -----------------------------------------------------------------------------
......@@ -146,7 +146,7 @@ INSTANTIATE_TEST_CASE_P(
MachineOperatorTest, MachineStoreOperatorTest,
::testing::Combine(
::testing::ValuesIn(kMachineReps),
::testing::Combine(::testing::ValuesIn(kMachineTypes),
::testing::Combine(::testing::ValuesIn(kMachineTypesForAccess),
::testing::Values(kNoWriteBarrier,
kFullWriteBarrier))));
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment