Commit 1a23f031 authored by titzer's avatar titzer Committed by Commit bot

[turbofan] Tester improvements; use CSignature and simplify ReturnValueTraits.

R=bmeurer@chromium.org,mstarzinger@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#28733}
parent 6c6b425d
......@@ -11,76 +11,74 @@ namespace v8 {
namespace internal {
namespace compiler {
#define FOREACH_CTYPE_MACHINE_TYPE_MAPPING(V) \
V(void, kMachNone) \
V(bool, kMachBool) \
V(int8_t, kMachInt8) \
V(uint8_t, kMachUint8) \
V(int16_t, kMachInt16) \
V(uint16_t, kMachUint16) \
V(int32_t, kMachInt32) \
V(uint32_t, kMachUint32) \
V(int64_t, kMachInt64) \
V(uint64_t, kMachUint64) \
V(float, kMachFloat32) \
V(double, kMachFloat64) \
V(void*, kMachPtr) \
V(int*, kMachPtr)
template <typename T>
inline MachineType MachineTypeForC() {
CHECK(false); // Instantiated with invalid type.
return kMachNone;
}
template <>
inline MachineType MachineTypeForC<void>() {
return kMachNone;
}
template <>
inline MachineType MachineTypeForC<int8_t>() {
return kMachInt8;
}
template <>
inline MachineType MachineTypeForC<uint8_t>() {
return kMachUint8;
}
template <>
inline MachineType MachineTypeForC<int16_t>() {
return kMachInt16;
}
template <>
inline MachineType MachineTypeForC<uint16_t>() {
return kMachUint16;
}
template <>
inline MachineType MachineTypeForC<int32_t>() {
return kMachInt32;
}
template <>
inline MachineType MachineTypeForC<uint32_t>() {
return kMachUint32;
while (false) {
// All other types T must be assignable to Object*
*(static_cast<Object* volatile*>(0)) = static_cast<T>(0);
}
return kMachAnyTagged;
}
template <>
inline MachineType MachineTypeForC<int64_t>() {
return kMachInt64;
}
#define DECLARE_TEMPLATE_SPECIALIZATION(ctype, mtype) \
template <> \
inline MachineType MachineTypeForC<ctype>() { \
return mtype; \
}
FOREACH_CTYPE_MACHINE_TYPE_MAPPING(DECLARE_TEMPLATE_SPECIALIZATION)
#undef DECLARE_TEMPLATE_SPECIALIZATION
template <>
inline MachineType MachineTypeForC<uint64_t>() {
return kMachUint64;
}
// Helper for building machine signatures from C types.
class CSignature : public MachineSignature {
protected:
CSignature(size_t return_count, size_t parameter_count, MachineType* reps)
: MachineSignature(return_count, parameter_count, reps) {}
template <>
inline MachineType MachineTypeForC<double>() {
return kMachFloat64;
}
public:
template <typename P1 = void, typename P2 = void, typename P3 = void,
typename P4 = void, typename P5 = void>
void Verify() {
// Verifies the C signature against the machine types. Maximum {5} params.
CHECK_LT(parameter_count(), 6);
const int kMax = 5;
MachineType params[] = {MachineTypeForC<P1>(), MachineTypeForC<P2>(),
MachineTypeForC<P3>(), MachineTypeForC<P4>(),
MachineTypeForC<P5>()};
for (int p = kMax - 1; p >= 0; p--) {
if (p < parameter_count()) {
CHECK_EQ(GetParam(p), params[p]);
} else {
CHECK_EQ(kMachNone, params[p]);
}
}
}
};
template <>
inline MachineType MachineTypeForC<Object*>() {
return kMachAnyTagged;
}
template <typename Ret, uint16_t kParamCount>
class CSignatureOf : public MachineSignature {
class CSignatureOf : public CSignature {
protected:
MachineType storage_[1 + kParamCount];
CSignatureOf()
: MachineSignature(MachineTypeForC<Ret>() != kMachNone ? 1 : 0,
kParamCount,
reinterpret_cast<MachineType*>(&storage_)) {
: CSignature(MachineTypeForC<Ret>() != kMachNone ? 1 : 0, kParamCount,
reinterpret_cast<MachineType*>(&storage_)) {
if (return_count_ == 1) storage_[0] = MachineTypeForC<Ret>();
}
void Set(int index, MachineType type) {
......@@ -123,9 +121,11 @@ class CSignature3 : public CSignatureOf<Ret, 3> {
}
};
static const CSignature2<int32_t, int32_t, int32_t> int32_int32_to_int32;
static const CSignature2<uint32_t, uint32_t, uint32_t> uint32_uint32_to_uint32;
static const CSignature2<double, double, double> float64_float64_to_float64;
typedef CSignature2<int32_t, int32_t, int32_t> CSignature_i_ii;
typedef CSignature2<uint32_t, uint32_t, uint32_t> CSignature_u_uu;
typedef CSignature2<float, float, float> CSignature_f_ff;
typedef CSignature2<double, double, double> CSignature_d_dd;
typedef CSignature2<Object*, Object*, Object*> CSignature_o_oo;
}
}
} // namespace v8::internal::compiler
......
This diff is collapsed.
......@@ -30,14 +30,12 @@ class RawMachineAssemblerTester : public HandleAndZoneScope,
: HandleAndZoneScope(),
CallHelper<ReturnType>(
main_isolate(),
MakeMachineSignature(
main_zone(), ReturnValueTraits<ReturnType>::Representation(),
p0, p1, p2, p3, p4)),
MakeMachineSignature(main_zone(), MachineTypeForC<ReturnType>(), p0,
p1, p2, p3, p4)),
RawMachineAssembler(
main_isolate(), new (main_zone()) Graph(main_zone()),
MakeMachineSignature(
main_zone(), ReturnValueTraits<ReturnType>::Representation(),
p0, p1, p2, p3, p4),
MakeMachineSignature(main_zone(), MachineTypeForC<ReturnType>(), p0,
p1, p2, p3, p4),
kMachPtr, InstructionSelector::SupportedMachineOperatorFlags()) {}
void CheckNumber(double expected, Object* number) {
......
......@@ -52,9 +52,8 @@ class GraphBuilderTester : public HandleAndZoneScope,
: GraphAndBuilders(main_zone()),
CallHelper<ReturnType>(
main_isolate(),
MakeMachineSignature(
main_zone(), ReturnValueTraits<ReturnType>::Representation(),
p0, p1, p2, p3, p4)),
MakeMachineSignature(main_zone(), MachineTypeForC<ReturnType>(), p0,
p1, p2, p3, p4)),
SimplifiedGraphBuilder(main_isolate(), main_graph_, &main_common_,
&main_machine_, &main_simplified_),
parameters_(main_zone()->template NewArray<Node*>(parameter_count())) {
......
......@@ -4412,7 +4412,7 @@ TEST(RunTestIntPtrArithmetic) {
TEST(RunSpillLotsOfThings) {
static const int kInputSize = 1000;
RawMachineAssemblerTester<void> m;
RawMachineAssemblerTester<int32_t> m;
Node* accs[kInputSize];
int32_t outputs[kInputSize];
Node* one = m.Int32Constant(1);
......
......@@ -33,11 +33,8 @@ template <typename ReturnType>
class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> {
public:
SimplifiedLoweringTester(MachineType p0 = kMachNone,
MachineType p1 = kMachNone,
MachineType p2 = kMachNone,
MachineType p3 = kMachNone,
MachineType p4 = kMachNone)
: GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4),
MachineType p1 = kMachNone)
: GraphBuilderTester<ReturnType>(p0, p1),
typer(this->isolate(), this->graph(), MaybeHandle<Context>()),
javascript(this->zone()),
jsgraph(this->isolate(), this->graph(), this->common(), &javascript,
......
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