OLD | NEW |
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/machine-type.h" | 8 #include "src/machine-type.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 VerifyParams() { | 56 static void VerifyParams(MachineSignature* sig) { |
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(), 6u); | 58 CHECK_LT(sig->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 < static_cast<int>(parameter_count())) { | 64 if (p < static_cast<int>(sig->parameter_count())) { |
65 CHECK_EQ(GetParam(p), params[p]); | 65 CHECK_EQ(sig->GetParam(p), params[p]); |
66 } else { | 66 } else { |
67 CHECK_EQ(MachineType::None(), params[p]); | 67 CHECK_EQ(MachineType::None(), params[p]); |
68 } | 68 } |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 static CSignature* FromMachine(Zone* zone, MachineSignature* msig) { | 72 static CSignature* FromMachine(Zone* zone, MachineSignature* msig) { |
73 return reinterpret_cast<CSignature*>(msig); | 73 return reinterpret_cast<CSignature*>(msig); |
74 } | 74 } |
75 | 75 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 typedef CSignature2<int32_t, int32_t, int32_t> CSignature_i_ii; | 161 typedef CSignature2<int32_t, int32_t, int32_t> CSignature_i_ii; |
162 typedef CSignature2<uint32_t, uint32_t, uint32_t> CSignature_u_uu; | 162 typedef CSignature2<uint32_t, uint32_t, uint32_t> CSignature_u_uu; |
163 typedef CSignature2<float, float, float> CSignature_f_ff; | 163 typedef CSignature2<float, float, float> CSignature_f_ff; |
164 typedef CSignature2<double, double, double> CSignature_d_dd; | 164 typedef CSignature2<double, double, double> CSignature_d_dd; |
165 typedef CSignature2<Object*, Object*, Object*> CSignature_o_oo; | 165 typedef CSignature2<Object*, Object*, Object*> CSignature_o_oo; |
166 } // namespace compiler | 166 } // namespace compiler |
167 } // namespace internal | 167 } // namespace internal |
168 } // namespace v8 | 168 } // namespace v8 |
169 | 169 |
170 #endif // V8_COMPILER_C_SIGNATURE_H_ | 170 #endif // V8_COMPILER_C_SIGNATURE_H_ |
OLD | NEW |