Index: test/cctest/compiler/call-tester.h |
diff --git a/test/cctest/compiler/call-tester.h b/test/cctest/compiler/call-tester.h |
index 72fafa23476e1c6e6026a6327c6397aa15ff28e0..e86416028bc124161924531c9ea5f5cf147081a0 100644 |
--- a/test/cctest/compiler/call-tester.h |
+++ b/test/cctest/compiler/call-tester.h |
@@ -23,7 +23,7 @@ namespace v8 { |
namespace internal { |
namespace compiler { |
-// TODO(titzer): move MachineType selection for C types into machine-type.h |
+// TODO(titzer): use c-signature.h instead of ReturnValueTraits |
template <typename R> |
struct ReturnValueTraits { |
static R Cast(uintptr_t r) { return reinterpret_cast<R>(r); } |
@@ -130,34 +130,40 @@ struct ParameterTraits<T*> { |
class CallHelper { |
public: |
- explicit CallHelper(Isolate* isolate) : isolate_(isolate) { USE(isolate_); } |
+ explicit CallHelper(Isolate* isolate, MachineSignature* machine_sig) |
+ : machine_sig_(machine_sig), isolate_(isolate) { |
+ USE(isolate_); |
+ } |
virtual ~CallHelper() {} |
- static MachineCallDescriptorBuilder* ToCallDescriptorBuilder( |
+ static MachineSignature* MakeMachineSignature( |
Zone* zone, MachineType return_type, MachineType p0 = kMachNone, |
MachineType p1 = kMachNone, MachineType p2 = kMachNone, |
MachineType p3 = kMachNone, MachineType p4 = kMachNone) { |
- const int kSize = 5; |
- MachineType* params = zone->NewArray<MachineType>(kSize); |
- params[0] = p0; |
- params[1] = p1; |
- params[2] = p2; |
- params[3] = p3; |
- params[4] = p4; |
- int parameter_count = 0; |
- for (int i = 0; i < kSize; ++i) { |
- if (params[i] == kMachNone) { |
- break; |
- } |
- parameter_count++; |
+ // 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 new (zone) |
- MachineCallDescriptorBuilder(return_type, parameter_count, params); |
+ return builder.Build(); |
} |
protected: |
- virtual void VerifyParameters(int parameter_count, |
- MachineType* parameters) = 0; |
+ MachineSignature* machine_sig_; |
+ void VerifyParameters(size_t parameter_count, MachineType* parameter_types) { |
+ CHECK(machine_sig_->parameter_count() == parameter_count); |
+ for (size_t i = 0; i < parameter_count; i++) { |
+ CHECK_EQ(machine_sig_->GetParam(i), parameter_types[i]); |
+ } |
+ } |
virtual byte* Generate() = 0; |
private: |