]> git.saurik.com Git - apple/objc4.git/blob - runtime/objc-rtp.h
objc4-437.1.tar.gz
[apple/objc4.git] / runtime / objc-rtp.h
1 /*
2 * Copyright (c) 2004-2006 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /*
24 Layout of the "objc runtime pages", an fixed area
25 in high memory that can be reached via an absolute branch.
26 Basic idea is that, on ppc, a single "bla" instruction
27 (branch & link to absolute address)
28 can be issued by the compiler to get to high-value routines
29 in the runtime, including the basic messenger and to the
30 assignment helper intrinsics issued under -fobjc-gc.
31 The implementation of the intrinsics is optimized based
32 on whether the application (process) is running with GC enabled
33 or not.
34 */
35
36 #ifndef _OBJC_RTP_H_
37 #define _OBJC_RTP_H_
38
39 /*********************************************************************
40 Layout of the runtime page.
41
42 Some of these values must NEVER BE CHANGED, including:
43 kRTPagesLo
44 kRTPagesHi
45 kRTPagesMaxSize
46 kRTSize_objc_msgSend
47 kRTSize_objc_assign_ivar
48 kRTAddress_objc_msgSend ppc 0xfffeff00
49 kRTAddress_objc_assign_ivar ppc 0xfffefec0
50
51 *********************************************************************/
52
53 #undef OBJC_SIZE_T
54 #undef OBJC_INTPTR_T
55 #undef OBJC_UINTPTR_T
56
57 #ifdef OBJC_ASM
58 #define OBJC_SIZE_T(x) (x)
59 #define OBJC_INTPTR_T(x) (x)
60 #define OBJC_UINTPTR_T(x) (x)
61 #else
62 #define OBJC_SIZE_T(x) ((size_t)(x))
63 #define OBJC_INTPTR_T(x) ((intptr_t)(x))
64 #define OBJC_UINTPTR_T(x) ((uintptr_t)(x))
65 #endif
66
67 // Size of RTP area, in bytes (0x1000 = 4k bytes = 1 page)
68 #define kRTPagesMaxSize OBJC_SIZE_T(4 * 0x1000) // size reserved for runtime
69 #define kRTPagesSize OBJC_SIZE_T(1 * 0x1000) // size actually used
70
71 // Address of RTP area: [kRTPagesLo..kRTPagesHi)
72 // These are defined in negative numbers to reflect an offset from the highest address,
73 // which is what the ppc "bla" instruction is defined to do with "negative" addresses.
74 // This definition will establish the correct entry points for 64-bit if this mechanism
75 // is adopted for that architecture as well.
76 #if defined(__ppc__) || defined(__ppc64__)
77 # define kRTPagesLo OBJC_UINTPTR_T(-20 * 0x1000) // ppc 0xfffec000
78 #elif defined(__i386__)
79 # define kRTPagesLo OBJC_UINTPTR_T(-24 * 0x1000) // i386 0xfffe8000
80 #elif defined(__x86_64__)
81 # define kRTPagesLo OBJC_UINTPTR_T(-24 * 0x1000) // x86_64 0xfffffffffffe8000
82 #elif defined(__arm__) || defined(TARGET_OS_WIN32)
83 # define kRTPagesLo OBJC_UINTPTR_T(0)
84 #else
85 #error unknown architecture
86 #endif
87 #define kRTPagesHi OBJC_UINTPTR_T(kRTPagesLo + kRTPagesMaxSize) // ppc 0xffff0000
88
89 // Sizes reserved for functions in the RTP area, in bytes
90 #define kRTSize_objc_msgSend OBJC_SIZE_T(0x0100)
91 #define kRTSize_objc_assign_ivar OBJC_SIZE_T(0x0040)
92 #define kRTSize_objc_assign_global OBJC_SIZE_T(0x0010)
93 #define kRTSize_objc_assign_strongCast OBJC_SIZE_T(0x0010)
94
95 // Absolute address of functions in the RTP area
96 // These count backwards from the hi end of the RTP area.
97 // New additions are added to the low side.
98 #define kRTAddress_objc_msgSend OBJC_UINTPTR_T(kRTPagesHi - kRTSize_objc_msgSend) // ppc 0xfffeff00
99 #define kRTAddress_objc_assign_ivar OBJC_UINTPTR_T(kRTAddress_objc_msgSend - kRTSize_objc_assign_ivar) // ppc 0xfffefec0
100 #define kRTAddress_objc_assign_global OBJC_UINTPTR_T(kRTAddress_objc_assign_ivar - kRTSize_objc_assign_global) // ppc 0xfffefeb0
101 #define kRTAddress_objc_assign_strongCast OBJC_UINTPTR_T(kRTAddress_objc_assign_global - kRTSize_objc_assign_strongCast) // ppc 0xfffefea0
102
103 // Sizes reserved for data in the RTP area, in bytes
104 #define kRTSize_zero OBJC_SIZE_T(16) // 16 zero bytes
105 #define kRTSize_ignoredSelector OBJC_SIZE_T(19) // 1+strlen("<ignored selector>")
106
107 // Absolute address of data in the RTP area
108 // These count forwards from the lo end of the RTP area.
109 // These are not locked down and can be moved if necessary.
110 #define kRTAddress_zero OBJC_UINTPTR_T(kRTPagesHi-kRTPagesSize)
111 #define kRTAddress_ignoredSelector OBJC_UINTPTR_T(kRTAddress_zero+kRTSize_zero)
112
113 #define kIgnore kRTAddress_ignoredSelector // ppc 0xfffef000
114
115 /*********************************************************************
116 End of runtime page layout.
117 *********************************************************************/
118
119 #endif