]> git.saurik.com Git - apple/objc4.git/blame - runtime/objc-rtp.h
objc4-371.2.tar.gz
[apple/objc4.git] / runtime / objc-rtp.h
CommitLineData
2bfd4448 1/*
b3962a83 2 * Copyright (c) 2004-2006 Apple Inc. All rights reserved.
2bfd4448
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
2bfd4448
A
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/*
2bfd4448
A
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.
b3962a83 76#if defined(__ppc__) || defined(__ppc64__)
2bfd4448
A
77# define kRTPagesLo OBJC_UINTPTR_T(-20 * 0x1000) // ppc 0xfffec000
78#elif defined(__i386__)
79# define kRTPagesLo OBJC_UINTPTR_T(-24 * 0x1000) // i386 0xfffe8000
b3962a83
A
80#elif defined(__x86_64__)
81# define kRTPagesLo OBJC_UINTPTR_T(-24 * 0x1000) // x86_64 0xfffffffffffe8000
2bfd4448
A
82#else
83 #error unknown architecture
84#endif
85#define kRTPagesHi OBJC_UINTPTR_T(kRTPagesLo + kRTPagesMaxSize) // ppc 0xffff0000
86
87// Sizes reserved for functions in the RTP area, in bytes
88#define kRTSize_objc_msgSend OBJC_SIZE_T(0x0100)
89#define kRTSize_objc_assign_ivar OBJC_SIZE_T(0x0040)
90#define kRTSize_objc_assign_global OBJC_SIZE_T(0x0010)
91#define kRTSize_objc_assign_strongCast OBJC_SIZE_T(0x0010)
92
93// Absolute address of functions in the RTP area
94// These count backwards from the hi end of the RTP area.
95// New additions are added to the low side.
96#define kRTAddress_objc_msgSend OBJC_UINTPTR_T(kRTPagesHi - kRTSize_objc_msgSend) // ppc 0xfffeff00
97#define kRTAddress_objc_assign_ivar OBJC_UINTPTR_T(kRTAddress_objc_msgSend - kRTSize_objc_assign_ivar) // ppc 0xfffefec0
98#define kRTAddress_objc_assign_global OBJC_UINTPTR_T(kRTAddress_objc_assign_ivar - kRTSize_objc_assign_global) // ppc 0xfffefeb0
99#define kRTAddress_objc_assign_strongCast OBJC_UINTPTR_T(kRTAddress_objc_assign_global - kRTSize_objc_assign_strongCast) // ppc 0xfffefea0
100
101// Sizes reserved for data in the RTP area, in bytes
b3962a83 102#define kRTSize_zero OBJC_SIZE_T(16) // 16 zero bytes
2bfd4448
A
103#define kRTSize_ignoredSelector OBJC_SIZE_T(19) // 1+strlen("<ignored selector>")
104
105// Absolute address of data in the RTP area
106// These count forwards from the lo end of the RTP area.
107// These are not locked down and can be moved if necessary.
b3962a83
A
108#define kRTAddress_zero OBJC_UINTPTR_T(kRTPagesHi-kRTPagesSize)
109#define kRTAddress_ignoredSelector OBJC_UINTPTR_T(kRTAddress_zero+kRTSize_zero)
2bfd4448 110
b3962a83 111#define kIgnore kRTAddress_ignoredSelector // ppc 0xfffef000
2bfd4448
A
112
113/*********************************************************************
114 End of runtime page layout.
115*********************************************************************/
116
117#endif