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/compiler/machine-type.h" | 8 #include "src/compiler/machine-type.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 template <typename T> | 30 template <typename T> |
31 inline MachineType MachineTypeForC() { | 31 inline MachineType MachineTypeForC() { |
32 while (false) { | 32 while (false) { |
33 // All other types T must be assignable to Object* | 33 // All other types T must be assignable to Object* |
34 *(static_cast<Object* volatile*>(0)) = static_cast<T>(0); | 34 *(static_cast<Object* volatile*>(0)) = static_cast<T>(0); |
35 } | 35 } |
36 return kMachAnyTagged; | 36 return kMachAnyTagged; |
37 } | 37 } |
38 | 38 |
39 template <typename T> | |
40 inline StoreRepresentation StoreRepresentationForC( | |
41 WriteBarrierKind write_barrier_kind) { | |
42 return StoreRepresentation(MachineTypeForC<T>(), write_barrier_kind); | |
43 } | |
44 | |
45 #define DECLARE_TEMPLATE_SPECIALIZATION(ctype, mtype) \ | 39 #define DECLARE_TEMPLATE_SPECIALIZATION(ctype, mtype) \ |
46 template <> \ | 40 template <> \ |
47 inline MachineType MachineTypeForC<ctype>() { \ | 41 inline MachineType MachineTypeForC<ctype>() { \ |
48 return mtype; \ | 42 return mtype; \ |
49 } | 43 } |
50 FOREACH_CTYPE_MACHINE_TYPE_MAPPING(DECLARE_TEMPLATE_SPECIALIZATION) | 44 FOREACH_CTYPE_MACHINE_TYPE_MAPPING(DECLARE_TEMPLATE_SPECIALIZATION) |
51 #undef DECLARE_TEMPLATE_SPECIALIZATION | 45 #undef DECLARE_TEMPLATE_SPECIALIZATION |
52 | 46 |
53 // Helper for building machine signatures from C types. | 47 // Helper for building machine signatures from C types. |
54 class CSignature : public MachineSignature { | 48 class CSignature : public MachineSignature { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 typedef CSignature2<int32_t, int32_t, int32_t> CSignature_i_ii; | 157 typedef CSignature2<int32_t, int32_t, int32_t> CSignature_i_ii; |
164 typedef CSignature2<uint32_t, uint32_t, uint32_t> CSignature_u_uu; | 158 typedef CSignature2<uint32_t, uint32_t, uint32_t> CSignature_u_uu; |
165 typedef CSignature2<float, float, float> CSignature_f_ff; | 159 typedef CSignature2<float, float, float> CSignature_f_ff; |
166 typedef CSignature2<double, double, double> CSignature_d_dd; | 160 typedef CSignature2<double, double, double> CSignature_d_dd; |
167 typedef CSignature2<Object*, Object*, Object*> CSignature_o_oo; | 161 typedef CSignature2<Object*, Object*, Object*> CSignature_o_oo; |
168 } // namespace compiler | 162 } // namespace compiler |
169 } // namespace internal | 163 } // namespace internal |
170 } // namespace v8 | 164 } // namespace v8 |
171 | 165 |
172 #endif // V8_COMPILER_C_SIGNATURE_H_ | 166 #endif // V8_COMPILER_C_SIGNATURE_H_ |
OLD | NEW |