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 |
39 #define DECLARE_TEMPLATE_SPECIALIZATION(ctype, mtype) \ | 45 #define DECLARE_TEMPLATE_SPECIALIZATION(ctype, mtype) \ |
40 template <> \ | 46 template <> \ |
41 inline MachineType MachineTypeForC<ctype>() { \ | 47 inline MachineType MachineTypeForC<ctype>() { \ |
42 return mtype; \ | 48 return mtype; \ |
43 } | 49 } |
44 FOREACH_CTYPE_MACHINE_TYPE_MAPPING(DECLARE_TEMPLATE_SPECIALIZATION) | 50 FOREACH_CTYPE_MACHINE_TYPE_MAPPING(DECLARE_TEMPLATE_SPECIALIZATION) |
45 #undef DECLARE_TEMPLATE_SPECIALIZATION | 51 #undef DECLARE_TEMPLATE_SPECIALIZATION |
46 | 52 |
47 // Helper for building machine signatures from C types. | 53 // Helper for building machine signatures from C types. |
48 class CSignature : public MachineSignature { | 54 class CSignature : public MachineSignature { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 typedef CSignature2<int32_t, int32_t, int32_t> CSignature_i_ii; | 163 typedef CSignature2<int32_t, int32_t, int32_t> CSignature_i_ii; |
158 typedef CSignature2<uint32_t, uint32_t, uint32_t> CSignature_u_uu; | 164 typedef CSignature2<uint32_t, uint32_t, uint32_t> CSignature_u_uu; |
159 typedef CSignature2<float, float, float> CSignature_f_ff; | 165 typedef CSignature2<float, float, float> CSignature_f_ff; |
160 typedef CSignature2<double, double, double> CSignature_d_dd; | 166 typedef CSignature2<double, double, double> CSignature_d_dd; |
161 typedef CSignature2<Object*, Object*, Object*> CSignature_o_oo; | 167 typedef CSignature2<Object*, Object*, Object*> CSignature_o_oo; |
162 } // namespace compiler | 168 } // namespace compiler |
163 } // namespace internal | 169 } // namespace internal |
164 } // namespace v8 | 170 } // namespace v8 |
165 | 171 |
166 #endif // V8_COMPILER_C_SIGNATURE_H_ | 172 #endif // V8_COMPILER_C_SIGNATURE_H_ |
OLD | NEW |