| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef RUNTIME_VM_GLOBALS_H_ | 5 #ifndef RUNTIME_VM_GLOBALS_H_ |
| 6 #define RUNTIME_VM_GLOBALS_H_ | 6 #define RUNTIME_VM_GLOBALS_H_ |
| 7 | 7 |
| 8 // This file contains global definitions for the VM library only. Anything that | 8 // This file contains global definitions for the VM library only. Anything that |
| 9 // is more globally useful should be added to 'vm/globals.h'. | 9 // is more globally useful should be added to 'vm/globals.h'. |
| 10 | 10 |
| 11 #include "platform/globals.h" | 11 #include "platform/globals.h" |
| 12 | 12 |
| 13 #if defined(_WIN32) | 13 #if defined(_WIN32) |
| 14 // Undef conflicting defines. | 14 // Undef conflicting defines. |
| 15 #undef PARITY_EVEN | 15 #undef PARITY_EVEN |
| 16 #undef PARITY_ODD | 16 #undef PARITY_ODD |
| 17 #undef near | 17 #undef near |
| 18 #endif // defined(_WIN32) | 18 #endif // defined(_WIN32) |
| 19 | 19 |
| 20 // The following #defines are invalidated. | 20 // The following #defines are invalidated. |
| 21 #undef OVERFLOW // From math.h conflicts in constants_ia32.h | 21 #undef OVERFLOW // From math.h conflicts in constants_ia32.h |
| 22 | 22 |
| 23 namespace dart { | 23 namespace dart { |
| 24 // Smi value range is from -(2^N) to (2^N)-1. | 24 // Smi value range is from -(2^N) to (2^N)-1. |
| 25 // N=30 (32-bit build) or N=62 (64-bit build). | 25 // N=30 (32-bit build) or N=62 (64-bit build). |
| 26 const intptr_t kSmiBits = kBitsPerWord - 2; | 26 const intptr_t kSmiBits = kBitsPerWord - 2; |
| 27 const intptr_t kSmiMax = (static_cast<intptr_t>(1) << kSmiBits) - 1; | 27 const intptr_t kSmiMax = (static_cast<intptr_t>(1) << kSmiBits) - 1; |
| 28 const intptr_t kSmiMin = -(static_cast<intptr_t>(1) << kSmiBits); | 28 const intptr_t kSmiMin = -(static_cast<intptr_t>(1) << kSmiBits); |
| 29 | 29 |
| 30 // Hard coded from above but for 32-bit architectures. | 30 // Hard coded from above but for 32-bit architectures. |
| 31 const intptr_t kSmiBits32 = kBitsPerInt32 - 2; | 31 const intptr_t kSmiBits32 = kBitsPerInt32 - 2; |
| 32 const intptr_t kSmiMax32 = (static_cast<intptr_t>(1) << kSmiBits32) - 1; | 32 const intptr_t kSmiMax32 = (static_cast<intptr_t>(1) << kSmiBits32) - 1; |
| 33 const intptr_t kSmiMin32 = -(static_cast<intptr_t>(1) << kSmiBits32); | 33 const intptr_t kSmiMin32 = -(static_cast<intptr_t>(1) << kSmiBits32); |
| 34 | 34 |
| 35 #define kPosInfinity bit_cast<double>(DART_UINT64_C(0x7ff0000000000000)) | 35 #define kPosInfinity bit_cast<double>(DART_UINT64_C(0x7ff0000000000000)) |
| 36 #define kNegInfinity bit_cast<double>(DART_UINT64_C(0xfff0000000000000)) | 36 #define kNegInfinity bit_cast<double>(DART_UINT64_C(0xfff0000000000000)) |
| 37 | 37 |
| 38 // The expression ARRAY_SIZE(array) is a compile-time constant of type | 38 // The expression ARRAY_SIZE(array) is a compile-time constant of type |
| 39 // size_t which represents the number of elements of the given | 39 // size_t which represents the number of elements of the given |
| 40 // array. You should only use ARRAY_SIZE on statically allocated | 40 // array. You should only use ARRAY_SIZE on statically allocated |
| 41 // arrays. | 41 // arrays. |
| 42 #define ARRAY_SIZE(array) \ | 42 #define ARRAY_SIZE(array) \ |
| 43 ((sizeof(array) / sizeof(*(array))) / \ | 43 ((sizeof(array) / sizeof(*(array))) / \ |
| 44 static_cast<intptr_t>(!(sizeof(array) % sizeof(*(array))))) | 44 static_cast<intptr_t>(!(sizeof(array) % sizeof(*(array))))) // NOLINT |
| 45 | 45 |
| 46 | 46 |
| 47 // The expression OFFSET_OF(type, field) computes the byte-offset of | 47 // The expression OFFSET_OF(type, field) computes the byte-offset of |
| 48 // the specified field relative to the containing type. | 48 // the specified field relative to the containing type. |
| 49 // | 49 // |
| 50 // The expression OFFSET_OF_RETURNED_VALUE(type, accessor) computes the | 50 // The expression OFFSET_OF_RETURNED_VALUE(type, accessor) computes the |
| 51 // byte-offset of the return value of the accessor to the containing type. | 51 // byte-offset of the return value of the accessor to the containing type. |
| 52 // | 52 // |
| 53 // None of these use 0 or NULL, which causes a problem with the compiler | 53 // None of these use 0 or NULL, which causes a problem with the compiler |
| 54 // warnings we have enabled (which is also why 'offsetof' doesn't seem to work). | 54 // warnings we have enabled (which is also why 'offsetof' doesn't seem to work). |
| 55 // The workaround is to use the non-zero value kOffsetOfPtr. | 55 // The workaround is to use the non-zero value kOffsetOfPtr. |
| 56 const intptr_t kOffsetOfPtr = 32; | 56 const intptr_t kOffsetOfPtr = 32; |
| 57 | 57 |
| 58 #define OFFSET_OF(type, field) \ | 58 #define OFFSET_OF(type, field) \ |
| 59 (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(kOffsetOfPtr)->field)) \ | 59 (reinterpret_cast<intptr_t>( \ |
| 60 - kOffsetOfPtr) | 60 &(reinterpret_cast<type*>(kOffsetOfPtr)->field)) - \ |
| 61 kOffsetOfPtr) // NOLINT |
| 61 | 62 |
| 62 #define OFFSET_OF_RETURNED_VALUE(type, accessor) \ | 63 #define OFFSET_OF_RETURNED_VALUE(type, accessor) \ |
| 63 (reinterpret_cast<intptr_t>( \ | 64 (reinterpret_cast<intptr_t>( \ |
| 64 (reinterpret_cast<type*>(kOffsetOfPtr)->accessor())) - kOffsetOfPtr) | 65 (reinterpret_cast<type*>(kOffsetOfPtr)->accessor())) - \ |
| 66 kOffsetOfPtr) // NOLINT |
| 65 | 67 |
| 66 #define OPEN_ARRAY_START(type, align) \ | 68 #define OPEN_ARRAY_START(type, align) \ |
| 67 do { \ | 69 do { \ |
| 68 const uword result = reinterpret_cast<uword>(this) + sizeof(*this); \ | 70 const uword result = reinterpret_cast<uword>(this) + sizeof(*this); \ |
| 69 ASSERT(Utils::IsAligned(result, sizeof(align))); \ | 71 ASSERT(Utils::IsAligned(result, sizeof(align))); \ |
| 70 return reinterpret_cast<type*>(result); \ | 72 return reinterpret_cast<type*>(result); \ |
| 71 } while (0) | 73 } while (0) |
| 72 | 74 |
| 73 | 75 |
| 74 // A type large enough to contain the value of the C++ vtable. This is needed | 76 // A type large enough to contain the value of the C++ vtable. This is needed |
| (...skipping 16 matching lines...) Expand all Loading... |
| 91 #if defined(ARCH_IS_32_BIT) | 93 #if defined(ARCH_IS_32_BIT) |
| 92 static const uword kZapUninitializedWord = 0xabababab; | 94 static const uword kZapUninitializedWord = 0xabababab; |
| 93 #else | 95 #else |
| 94 static const uword kZapUninitializedWord = 0xabababababababab; | 96 static const uword kZapUninitializedWord = 0xabababababababab; |
| 95 #endif | 97 #endif |
| 96 | 98 |
| 97 | 99 |
| 98 // Macros to get the contents of the fp register. | 100 // Macros to get the contents of the fp register. |
| 99 #if defined(TARGET_OS_WINDOWS) | 101 #if defined(TARGET_OS_WINDOWS) |
| 100 | 102 |
| 103 // clang-format off |
| 101 #if defined(HOST_ARCH_IA32) | 104 #if defined(HOST_ARCH_IA32) |
| 102 #define COPY_FP_REGISTER(fp) __asm { mov fp, ebp }; // NOLINT | 105 #define COPY_FP_REGISTER(fp) \ |
| 106 __asm { mov fp, ebp} \ |
| 107 ; // NOLINT |
| 108 // clang-format on |
| 103 #elif defined(HOST_ARCH_X64) | 109 #elif defined(HOST_ARCH_X64) |
| 104 #define COPY_FP_REGISTER(fp) UNIMPLEMENTED(); | 110 #define COPY_FP_REGISTER(fp) UNIMPLEMENTED(); |
| 105 #else | 111 #else |
| 106 #error Unknown host architecture. | 112 #error Unknown host architecture. |
| 107 #endif | 113 #endif |
| 108 | 114 |
| 109 #else // !defined(TARGET_OS_WINDOWS)) | 115 #else // !defined(TARGET_OS_WINDOWS)) |
| 110 | 116 |
| 111 // Assume GCC-like inline syntax is valid. | 117 // Assume GCC-like inline syntax is valid. |
| 112 #if defined(HOST_ARCH_IA32) | 118 #if defined(HOST_ARCH_IA32) |
| 113 #define COPY_FP_REGISTER(fp) asm volatile ("movl %%ebp, %0" : "=r" (fp) ); | 119 #define COPY_FP_REGISTER(fp) asm volatile("movl %%ebp, %0" : "=r"(fp)); |
| 114 #elif defined(HOST_ARCH_X64) | 120 #elif defined(HOST_ARCH_X64) |
| 115 #define COPY_FP_REGISTER(fp) asm volatile ("movq %%rbp, %0" : "=r" (fp) ); | 121 #define COPY_FP_REGISTER(fp) asm volatile("movq %%rbp, %0" : "=r"(fp)); |
| 116 #elif defined(HOST_ARCH_ARM) | 122 #elif defined(HOST_ARCH_ARM) |
| 117 # if defined(TARGET_OS_MAC) | 123 #if defined(TARGET_OS_MAC) |
| 118 #define COPY_FP_REGISTER(fp) asm volatile ("mov %0, r7" : "=r" (fp) ); | 124 #define COPY_FP_REGISTER(fp) asm volatile("mov %0, r7" : "=r"(fp)); |
| 119 # else | 125 #else |
| 120 #define COPY_FP_REGISTER(fp) asm volatile ("mov %0, r11" : "=r" (fp) ); | 126 #define COPY_FP_REGISTER(fp) asm volatile("mov %0, r11" : "=r"(fp)); |
| 121 # endif | 127 #endif |
| 122 #elif defined(HOST_ARCH_ARM64) | 128 #elif defined(HOST_ARCH_ARM64) |
| 123 #define COPY_FP_REGISTER(fp) asm volatile ("mov %0, x29" : "=r" (fp) ); | 129 #define COPY_FP_REGISTER(fp) asm volatile("mov %0, x29" : "=r"(fp)); |
| 124 #elif defined(HOST_ARCH_MIPS) | 130 #elif defined(HOST_ARCH_MIPS) |
| 125 #define COPY_FP_REGISTER(fp) asm volatile ("move %0, $fp" : "=r" (fp) ); | 131 #define COPY_FP_REGISTER(fp) asm volatile("move %0, $fp" : "=r"(fp)); |
| 126 #else | 132 #else |
| 127 #error Unknown host architecture. | 133 #error Unknown host architecture. |
| 128 #endif | 134 #endif |
| 129 | 135 |
| 130 | 136 |
| 131 #endif // !defined(TARGET_OS_WINDOWS)) | 137 #endif // !defined(TARGET_OS_WINDOWS)) |
| 132 | 138 |
| 133 } // namespace dart | 139 } // namespace dart |
| 134 | 140 |
| 135 #endif // RUNTIME_VM_GLOBALS_H_ | 141 #endif // RUNTIME_VM_GLOBALS_H_ |
| OLD | NEW |