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 VM_GLOBALS_H_ | 5 #ifndef VM_GLOBALS_H_ |
6 #define VM_GLOBALS_H_ | 6 #define 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 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // | 44 // |
45 // None of these use 0 or NULL, which causes a problem with the compiler | 45 // None of these use 0 or NULL, which causes a problem with the compiler |
46 // warnings we have enabled (which is also why 'offsetof' doesn't seem to work). | 46 // warnings we have enabled (which is also why 'offsetof' doesn't seem to work). |
47 // The workaround is to use the non-zero value kOffsetOfPtr. | 47 // The workaround is to use the non-zero value kOffsetOfPtr. |
48 const intptr_t kOffsetOfPtr = 32; | 48 const intptr_t kOffsetOfPtr = 32; |
49 | 49 |
50 #define OFFSET_OF(type, field) \ | 50 #define OFFSET_OF(type, field) \ |
51 (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(kOffsetOfPtr)->field)) \ | 51 (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(kOffsetOfPtr)->field)) \ |
52 - kOffsetOfPtr) | 52 - kOffsetOfPtr) |
53 | 53 |
54 #define OFFSET_OF_RETURNED_VALUE(type, accessor) \ | 54 #define OFFSET_OF_RETURNED_VALUE(type, accessor) \ |
55 (reinterpret_cast<intptr_t>( \ | 55 (reinterpret_cast<intptr_t>( \ |
56 (reinterpret_cast<type*>(kOffsetOfPtr)->accessor())) - kOffsetOfPtr) | 56 (reinterpret_cast<type*>(kOffsetOfPtr)->accessor())) - kOffsetOfPtr) |
57 | 57 |
58 | 58 |
59 // A type large enough to contain the value of the C++ vtable. This is needed | 59 // A type large enough to contain the value of the C++ vtable. This is needed |
60 // to support the handle operations. | 60 // to support the handle operations. |
61 typedef uword cpp_vtable; | 61 typedef uword cpp_vtable; |
62 | 62 |
63 | 63 |
64 // When using GCC we can use GCC attributes to ensure that certain | 64 // When using GCC we can use GCC attributes to ensure that certain |
65 // contants are 16 byte aligned. | 65 // contants are 16 byte aligned. |
66 #if defined(TARGET_OS_WINDOWS) | 66 #if defined(TARGET_OS_WINDOWS) |
67 #define ALIGN16 __declspec(align(16)) | 67 #define ALIGN16 __declspec(align(16)) |
68 #else | 68 #else |
69 #define ALIGN16 __attribute__((aligned(16))) | 69 #define ALIGN16 __attribute__((aligned(16))) |
70 #endif | 70 #endif |
71 | 71 |
72 | 72 |
73 // Zap value used to indicate uninitialized handle area (debug purposes). | 73 // Zap value used to indicate uninitialized handle area (debug purposes). |
74 #if defined(ARCH_IS_32_BIT) | 74 #if defined(ARCH_IS_32_BIT) |
75 static const uword kZapUninitializedWord = 0xabababab; | 75 static const uword kZapUninitializedWord = 0xabababab; |
76 #else | 76 #else |
77 static const uword kZapUninitializedWord = 0xabababababababab; | 77 static const uword kZapUninitializedWord = 0xabababababababab; |
78 #endif | 78 #endif |
79 | 79 |
80 | 80 |
81 } // namespace dart | 81 } // namespace dart |
82 | 82 |
83 #endif // VM_GLOBALS_H_ | 83 #endif // VM_GLOBALS_H_ |
OLD | NEW |