Index: test/cctest/compiler/codegen-tester.h |
diff --git a/test/cctest/compiler/codegen-tester.h b/test/cctest/compiler/codegen-tester.h |
index f2fc48a4799536f1774c2df968f22c1fe5837187..9272e506475baf9f60df2d9427a93b905aa2d05c 100644 |
--- a/test/cctest/compiler/codegen-tester.h |
+++ b/test/cctest/compiler/codegen-tester.h |
@@ -17,38 +17,28 @@ namespace v8 { |
namespace internal { |
namespace compiler { |
-template <typename MachineAssembler> |
-class MachineAssemblerTester : public HandleAndZoneScope, |
- public CallHelper, |
- public MachineAssembler { |
+template <typename ReturnType> |
+class RawMachineAssemblerTester : public HandleAndZoneScope, |
+ public CallHelper<ReturnType>, |
+ public RawMachineAssembler { |
public: |
- MachineAssemblerTester(MachineType return_type, MachineType p0, |
- MachineType p1, MachineType p2, MachineType p3, |
- MachineType p4, |
- MachineOperatorBuilder::Flags flags = |
- MachineOperatorBuilder::Flag::kNoFlags) |
+ RawMachineAssemblerTester(MachineType p0 = kMachNone, |
+ MachineType p1 = kMachNone, |
+ MachineType p2 = kMachNone, |
+ MachineType p3 = kMachNone, |
+ MachineType p4 = kMachNone) |
: HandleAndZoneScope(), |
- CallHelper( |
+ CallHelper<ReturnType>( |
main_isolate(), |
- MakeMachineSignature(main_zone(), return_type, p0, p1, p2, p3, p4)), |
- MachineAssembler( |
+ MakeMachineSignature( |
+ main_zone(), ReturnValueTraits<ReturnType>::Representation(), |
+ p0, p1, p2, p3, p4)), |
+ RawMachineAssembler( |
main_isolate(), new (main_zone()) Graph(main_zone()), |
- MakeMachineSignature(main_zone(), return_type, p0, p1, p2, p3, p4), |
- kMachPtr, flags) {} |
- |
- Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) { |
- return this->Load(rep, this->PointerConstant(address), |
- this->Int32Constant(offset)); |
- } |
- |
- void StoreToPointer(void* address, MachineType rep, Node* node) { |
- this->Store(rep, this->PointerConstant(address), node); |
- } |
- |
- Node* StringConstant(const char* string) { |
- return this->HeapConstant( |
- this->isolate()->factory()->InternalizeUtf8String(string)); |
- } |
+ MakeMachineSignature( |
+ main_zone(), ReturnValueTraits<ReturnType>::Representation(), |
+ p0, p1, p2, p3, p4), |
+ kMachPtr, InstructionSelector::SupportedMachineOperatorFlags()) {} |
void CheckNumber(double expected, Object* number) { |
CHECK(this->isolate()->factory()->NewNumber(expected)->SameValue(number)); |
@@ -76,40 +66,26 @@ class MachineAssemblerTester : public HandleAndZoneScope, |
private: |
MaybeHandle<Code> code_; |
-}; |
- |
- |
-template <typename ReturnType> |
-class RawMachineAssemblerTester |
- : public MachineAssemblerTester<RawMachineAssembler>, |
- public CallHelper2<ReturnType, RawMachineAssemblerTester<ReturnType> > { |
- public: |
- RawMachineAssemblerTester(MachineType p0 = kMachNone, |
- MachineType p1 = kMachNone, |
- MachineType p2 = kMachNone, |
- MachineType p3 = kMachNone, |
- MachineType p4 = kMachNone) |
- : MachineAssemblerTester<RawMachineAssembler>( |
- ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, p4, |
- InstructionSelector::SupportedMachineOperatorFlags()) {} |
- template <typename Ci, typename Fn> |
- void Run(const Ci& ci, const Fn& fn) { |
- typename Ci::const_iterator i; |
- for (i = ci.begin(); i != ci.end(); ++i) { |
- CHECK_EQ(fn(*i), this->Call(*i)); |
- } |
- } |
- |
- template <typename Ci, typename Cj, typename Fn> |
- void Run(const Ci& ci, const Cj& cj, const Fn& fn) { |
- typename Ci::const_iterator i; |
- typename Cj::const_iterator j; |
- for (i = ci.begin(); i != ci.end(); ++i) { |
- for (j = cj.begin(); j != cj.end(); ++j) { |
- CHECK_EQ(fn(*i, *j), this->Call(*i, *j)); |
- } |
+ // TODO(titzer): factor me elsewhere. |
+ static MachineSignature* MakeMachineSignature( |
+ Zone* zone, MachineType return_type, MachineType p0 = kMachNone, |
+ MachineType p1 = kMachNone, MachineType p2 = kMachNone, |
+ MachineType p3 = kMachNone, MachineType p4 = kMachNone) { |
+ // Count the number of parameters. |
+ size_t param_count = 5; |
+ MachineType types[] = {p0, p1, p2, p3, p4}; |
+ while (param_count > 0 && types[param_count - 1] == kMachNone) |
+ param_count--; |
+ size_t return_count = return_type == kMachNone ? 0 : 1; |
+ |
+ // Build the machine signature. |
+ MachineSignature::Builder builder(zone, return_count, param_count); |
+ if (return_count > 0) builder.AddReturn(return_type); |
+ for (size_t i = 0; i < param_count; i++) { |
+ builder.AddParam(types[i]); |
} |
+ return builder.Build(); |
} |
}; |