Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: test/cctest/compiler/c-signature.h

Issue 1146173005: [test] Refactor call-tester to use c-signature.h. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/compiler/call-tester.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COMPILER_C_SIGNATURE_H_ 5 #ifndef V8_COMPILER_C_SIGNATURE_H_
6 #define V8_COMPILER_C_SIGNATURE_H_ 6 #define V8_COMPILER_C_SIGNATURE_H_
7 7
8 #include "src/compiler/machine-type.h" 8 #include "src/compiler/machine-type.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // Helper for building machine signatures from C types. 47 // Helper for building machine signatures from C types.
48 class CSignature : public MachineSignature { 48 class CSignature : public MachineSignature {
49 protected: 49 protected:
50 CSignature(size_t return_count, size_t parameter_count, MachineType* reps) 50 CSignature(size_t return_count, size_t parameter_count, MachineType* reps)
51 : MachineSignature(return_count, parameter_count, reps) {} 51 : MachineSignature(return_count, parameter_count, reps) {}
52 52
53 public: 53 public:
54 template <typename P1 = void, typename P2 = void, typename P3 = void, 54 template <typename P1 = void, typename P2 = void, typename P3 = void,
55 typename P4 = void, typename P5 = void> 55 typename P4 = void, typename P5 = void>
56 void Verify() { 56 void VerifyParams() {
57 // Verifies the C signature against the machine types. Maximum {5} params. 57 // Verifies the C signature against the machine types. Maximum {5} params.
58 CHECK_LT(parameter_count(), 6); 58 CHECK_LT(parameter_count(), 6u);
59 const int kMax = 5; 59 const int kMax = 5;
60 MachineType params[] = {MachineTypeForC<P1>(), MachineTypeForC<P2>(), 60 MachineType params[] = {MachineTypeForC<P1>(), MachineTypeForC<P2>(),
61 MachineTypeForC<P3>(), MachineTypeForC<P4>(), 61 MachineTypeForC<P3>(), MachineTypeForC<P4>(),
62 MachineTypeForC<P5>()}; 62 MachineTypeForC<P5>()};
63 for (int p = kMax - 1; p >= 0; p--) { 63 for (int p = kMax - 1; p >= 0; p--) {
64 if (p < parameter_count()) { 64 if (p < static_cast<int>(parameter_count())) {
65 CHECK_EQ(GetParam(p), params[p]); 65 CHECK_EQ(GetParam(p), params[p]);
66 } else { 66 } else {
67 CHECK_EQ(kMachNone, params[p]); 67 CHECK_EQ(kMachNone, params[p]);
68 } 68 }
69 } 69 }
70 } 70 }
71
72 static CSignature* New(Zone* zone, MachineType ret,
73 MachineType p1 = kMachNone, MachineType p2 = kMachNone,
74 MachineType p3 = kMachNone, MachineType p4 = kMachNone,
75 MachineType p5 = kMachNone) {
76 MachineType* buffer = zone->NewArray<MachineType>(6);
77 int pos = 0;
78 size_t return_count = 0;
79 if (ret != kMachNone) {
80 buffer[pos++] = ret;
81 return_count++;
82 }
83 buffer[pos++] = p1;
84 buffer[pos++] = p2;
85 buffer[pos++] = p3;
86 buffer[pos++] = p4;
87 buffer[pos++] = p5;
88 size_t param_count = 5;
89 if (p5 == kMachNone) param_count--;
90 if (p4 == kMachNone) param_count--;
91 if (p3 == kMachNone) param_count--;
92 if (p2 == kMachNone) param_count--;
93 if (p1 == kMachNone) param_count--;
94 for (size_t i = 0; i < param_count; i++) {
95 // Check that there are no kMachNone's in the middle of parameters.
96 CHECK_NE(kMachNone, buffer[return_count + i]);
97 }
98 return new (zone) CSignature(return_count, param_count, buffer);
99 }
71 }; 100 };
72 101
73 102
74 template <typename Ret, uint16_t kParamCount> 103 template <typename Ret, uint16_t kParamCount>
75 class CSignatureOf : public CSignature { 104 class CSignatureOf : public CSignature {
76 protected: 105 protected:
77 MachineType storage_[1 + kParamCount]; 106 MachineType storage_[1 + kParamCount];
78 107
79 CSignatureOf() 108 CSignatureOf()
80 : CSignature(MachineTypeForC<Ret>() != kMachNone ? 1 : 0, kParamCount, 109 : CSignature(MachineTypeForC<Ret>() != kMachNone ? 1 : 0, kParamCount,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 typedef CSignature2<int32_t, int32_t, int32_t> CSignature_i_ii; 153 typedef CSignature2<int32_t, int32_t, int32_t> CSignature_i_ii;
125 typedef CSignature2<uint32_t, uint32_t, uint32_t> CSignature_u_uu; 154 typedef CSignature2<uint32_t, uint32_t, uint32_t> CSignature_u_uu;
126 typedef CSignature2<float, float, float> CSignature_f_ff; 155 typedef CSignature2<float, float, float> CSignature_f_ff;
127 typedef CSignature2<double, double, double> CSignature_d_dd; 156 typedef CSignature2<double, double, double> CSignature_d_dd;
128 typedef CSignature2<Object*, Object*, Object*> CSignature_o_oo; 157 typedef CSignature2<Object*, Object*, Object*> CSignature_o_oo;
129 } 158 }
130 } 159 }
131 } // namespace v8::internal::compiler 160 } // namespace v8::internal::compiler
132 161
133 #endif // V8_COMPILER_C_SIGNATURE_H_ 162 #endif // V8_COMPILER_C_SIGNATURE_H_
OLDNEW
« no previous file with comments | « no previous file | test/cctest/compiler/call-tester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698