OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2812 static inline int SmiToInt(internal::Object* value) { | 2812 static inline int SmiToInt(internal::Object* value) { |
2813 int shift_bits = kSmiTagSize + kSmiShiftSize; | 2813 int shift_bits = kSmiTagSize + kSmiShiftSize; |
2814 // Shift down and throw away top 32 bits. | 2814 // Shift down and throw away top 32 bits. |
2815 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits); | 2815 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits); |
2816 } | 2816 } |
2817 }; | 2817 }; |
2818 | 2818 |
2819 const int kSmiShiftSize = SmiConstants<sizeof(void*)>::kSmiShiftSize; | 2819 const int kSmiShiftSize = SmiConstants<sizeof(void*)>::kSmiShiftSize; |
2820 const int kSmiValueSize = SmiConstants<sizeof(void*)>::kSmiValueSize; | 2820 const int kSmiValueSize = SmiConstants<sizeof(void*)>::kSmiValueSize; |
2821 | 2821 |
| 2822 template <size_t ptr_size> struct InternalConstants; |
| 2823 |
| 2824 // Internal constants for 32-bit systems. |
| 2825 template <> struct InternalConstants<4> { |
| 2826 static const int kStringResourceOffset = 3 * sizeof(void*); |
| 2827 }; |
| 2828 |
| 2829 // Internal constants for 64-bit systems. |
| 2830 template <> struct InternalConstants<8> { |
| 2831 static const int kStringResourceOffset = 2 * sizeof(void*); |
| 2832 }; |
| 2833 |
2822 /** | 2834 /** |
2823 * This class exports constants and functionality from within v8 that | 2835 * This class exports constants and functionality from within v8 that |
2824 * is necessary to implement inline functions in the v8 api. Don't | 2836 * is necessary to implement inline functions in the v8 api. Don't |
2825 * depend on functions and constants defined here. | 2837 * depend on functions and constants defined here. |
2826 */ | 2838 */ |
2827 class Internals { | 2839 class Internals { |
2828 public: | 2840 public: |
2829 | 2841 |
2830 // These values match non-compiler-dependent values defined within | 2842 // These values match non-compiler-dependent values defined within |
2831 // the implementation of v8. | 2843 // the implementation of v8. |
2832 static const int kHeapObjectMapOffset = 0; | 2844 static const int kHeapObjectMapOffset = 0; |
2833 static const int kMapInstanceTypeOffset = sizeof(void*) + sizeof(int); | 2845 static const int kMapInstanceTypeOffset = sizeof(void*) + sizeof(int); |
2834 static const int kStringResourceOffset = 2 * sizeof(void*); | 2846 static const int kStringResourceOffset = |
| 2847 InternalConstants<sizeof(void*)>::kStringResourceOffset; |
| 2848 |
2835 static const int kProxyProxyOffset = sizeof(void*); | 2849 static const int kProxyProxyOffset = sizeof(void*); |
2836 static const int kJSObjectHeaderSize = 3 * sizeof(void*); | 2850 static const int kJSObjectHeaderSize = 3 * sizeof(void*); |
2837 static const int kFullStringRepresentationMask = 0x07; | 2851 static const int kFullStringRepresentationMask = 0x07; |
2838 static const int kExternalTwoByteRepresentationTag = 0x03; | 2852 static const int kExternalTwoByteRepresentationTag = 0x03; |
2839 | 2853 |
2840 // These constants are compiler dependent so their values must be | 2854 // These constants are compiler dependent so their values must be |
2841 // defined within the implementation. | 2855 // defined within the implementation. |
2842 V8EXPORT static int kJSObjectType; | 2856 V8EXPORT static int kJSObjectType; |
2843 V8EXPORT static int kFirstNonstringType; | 2857 V8EXPORT static int kFirstNonstringType; |
2844 V8EXPORT static int kProxyType; | 2858 V8EXPORT static int kProxyType; |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3206 | 3220 |
3207 } // namespace v8 | 3221 } // namespace v8 |
3208 | 3222 |
3209 | 3223 |
3210 #undef V8EXPORT | 3224 #undef V8EXPORT |
3211 #undef V8EXPORT_INLINE | 3225 #undef V8EXPORT_INLINE |
3212 #undef TYPE_CHECK | 3226 #undef TYPE_CHECK |
3213 | 3227 |
3214 | 3228 |
3215 #endif // V8_H_ | 3229 #endif // V8_H_ |
OLD | NEW |