[Turbofan] Fix GapResolver tests.

Fixes bug in test-gap-resolver.cc that didn't test different move reps.
Fixes test canonicalization so all slots have the same type (non-float).
Improve test failure text output.

LOG=N
BUG=v8:5187

Review-Url: https://codereview.chromium.org/2169493002
Cr-Commit-Position: refs/heads/master@{#37915}
This commit is contained in:
bbudge 2016-07-20 12:05:48 -07:00 committed by Commit bot
parent f1cf71aa4d
commit 8730875b2b

View File

@ -33,7 +33,7 @@ class InterpreterState {
private:
struct Key {
bool is_constant;
bool is_float;
MachineRepresentation rep;
LocationOperand::LocationKind kind;
int index;
@ -41,8 +41,8 @@ class InterpreterState {
if (this->is_constant != other.is_constant) {
return this->is_constant;
}
if (this->is_float != other.is_float) {
return this->is_float;
if (this->rep != other.rep) {
return static_cast<int>(this->rep) < static_cast<int>(other.rep);
}
if (this->kind != other.kind) {
return this->kind < other.kind;
@ -51,7 +51,7 @@ class InterpreterState {
}
bool operator==(const Key& other) const {
return this->is_constant == other.is_constant &&
return this->is_constant == other.is_constant && this->rep == other.rep &&
this->kind == other.kind && this->index == other.index;
}
};
@ -75,24 +75,27 @@ class InterpreterState {
static Key KeyFor(const InstructionOperand& op) {
bool is_constant = op.IsConstant();
bool is_float = false;
MachineRepresentation rep =
v8::internal::compiler::InstructionSequence::DefaultRepresentation();
LocationOperand::LocationKind kind;
int index;
if (!is_constant) {
if (op.IsRegister()) {
index = LocationOperand::cast(op).GetRegister().code();
} else if (op.IsFPRegister()) {
index = LocationOperand::cast(op).GetDoubleRegister().code();
const LocationOperand& loc_op = LocationOperand::cast(op);
if (loc_op.IsAnyRegister()) {
if (loc_op.IsFPRegister()) {
rep = kSimpleFPAliasing ? MachineRepresentation::kFloat64
: loc_op.representation();
}
index = loc_op.register_code();
} else {
index = LocationOperand::cast(op).index();
index = loc_op.index();
}
is_float = IsFloatingPoint(LocationOperand::cast(op).representation());
kind = LocationOperand::cast(op).location_kind();
kind = loc_op.location_kind();
} else {
index = ConstantOperand::cast(op).virtual_register();
kind = LocationOperand::REGISTER;
}
Key key = {is_constant, is_float, kind, index};
Key key = {is_constant, rep, kind, index};
return key;
}
@ -102,10 +105,7 @@ class InterpreterState {
if (key.is_constant) {
return ConstantOperand(key.index);
}
return AllocatedOperand(
key.kind,
v8::internal::compiler::InstructionSequence::DefaultRepresentation(),
key.index);
return AllocatedOperand(key.kind, key.rep, key.index);
}
friend std::ostream& operator<<(std::ostream& os,
@ -113,8 +113,8 @@ class InterpreterState {
for (OperandMap::const_iterator it = is.values_.begin();
it != is.values_.end(); ++it) {
if (it != is.values_.begin()) os << " ";
InstructionOperand source = FromKey(it->first);
InstructionOperand destination = FromKey(it->second);
InstructionOperand source = FromKey(it->second);
InstructionOperand destination = FromKey(it->first);
MoveOperands mo(source, destination);
PrintableMoveOperands pmo = {RegisterConfiguration::Turbofan(), &mo};
os << pmo;
@ -165,8 +165,8 @@ class ParallelMoveCreator : public HandleAndZoneScope {
ParallelMove* Create(int size) {
ParallelMove* parallel_move = new (main_zone()) ParallelMove(main_zone());
std::set<InstructionOperand, CompareOperandModuloType> seen;
MachineRepresentation rep = RandomRepresentation();
for (int i = 0; i < size; ++i) {
MachineRepresentation rep = RandomRepresentation();
MoveOperands mo(CreateRandomOperand(true, rep),
CreateRandomOperand(false, rep));
if (!mo.IsRedundant() && seen.find(mo.destination()) == seen.end()) {
@ -186,7 +186,10 @@ class ParallelMoveCreator : public HandleAndZoneScope {
case 1:
return MachineRepresentation::kWord64;
case 2:
return MachineRepresentation::kFloat32;
// TODO(bbudge) Re-enable float operands when GapResolver correctly
// handles FP aliasing.
return kSimpleFPAliasing ? MachineRepresentation::kFloat32
: MachineRepresentation::kFloat64;
case 3:
return MachineRepresentation::kFloat64;
case 4:
@ -252,7 +255,7 @@ TEST(FuzzResolver) {
GapResolver resolver(&mi2);
resolver.Resolve(pm);
CHECK(mi1.state() == mi2.state());
CHECK_EQ(mi1.state(), mi2.state());
}
}
}