]> git.saurik.com Git - apple/objc4.git/blob - runtime/isa.h
objc4-750.tar.gz
[apple/objc4.git] / runtime / isa.h
1 /*
2 * @APPLE_LICENSE_HEADER_START@
3 *
4 * Copyright (c) 2018 Apple Inc. All Rights Reserved.
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 *
25 * isa.h - Definitions of isa fields for C and assembly code.
26 *
27 ********************************************************************/
28
29 #ifndef _OBJC_ISA_H_
30 #define _OBJC_ISA_H_
31
32 #include "objc-config.h"
33
34
35 #if (!SUPPORT_NONPOINTER_ISA && !SUPPORT_PACKED_ISA && !SUPPORT_INDEXED_ISA) ||\
36 ( SUPPORT_NONPOINTER_ISA && SUPPORT_PACKED_ISA && !SUPPORT_INDEXED_ISA) ||\
37 ( SUPPORT_NONPOINTER_ISA && !SUPPORT_PACKED_ISA && SUPPORT_INDEXED_ISA)
38 // good config
39 #else
40 # error bad config
41 #endif
42
43
44 #if SUPPORT_PACKED_ISA
45
46 // extra_rc must be the MSB-most field (so it matches carry/overflow flags)
47 // nonpointer must be the LSB (fixme or get rid of it)
48 // shiftcls must occupy the same bits that a real class pointer would
49 // bits + RC_ONE is equivalent to extra_rc + 1
50 // RC_HALF is the high bit of extra_rc (i.e. half of its range)
51
52 // future expansion:
53 // uintptr_t fast_rr : 1; // no r/r overrides
54 // uintptr_t lock : 2; // lock for atomic property, @synch
55 // uintptr_t extraBytes : 1; // allocated with extra bytes
56
57 # if __arm64__
58 # define ISA_MASK 0x0000000ffffffff8ULL
59 # define ISA_MAGIC_MASK 0x000003f000000001ULL
60 # define ISA_MAGIC_VALUE 0x000001a000000001ULL
61 # define ISA_BITFIELD \
62 uintptr_t nonpointer : 1; \
63 uintptr_t has_assoc : 1; \
64 uintptr_t has_cxx_dtor : 1; \
65 uintptr_t shiftcls : 33; /*MACH_VM_MAX_ADDRESS 0x1000000000*/ \
66 uintptr_t magic : 6; \
67 uintptr_t weakly_referenced : 1; \
68 uintptr_t deallocating : 1; \
69 uintptr_t has_sidetable_rc : 1; \
70 uintptr_t extra_rc : 19
71 # define RC_ONE (1ULL<<45)
72 # define RC_HALF (1ULL<<18)
73
74 # elif __x86_64__
75 # define ISA_MASK 0x00007ffffffffff8ULL
76 # define ISA_MAGIC_MASK 0x001f800000000001ULL
77 # define ISA_MAGIC_VALUE 0x001d800000000001ULL
78 # define ISA_BITFIELD \
79 uintptr_t nonpointer : 1; \
80 uintptr_t has_assoc : 1; \
81 uintptr_t has_cxx_dtor : 1; \
82 uintptr_t shiftcls : 44; /*MACH_VM_MAX_ADDRESS 0x7fffffe00000*/ \
83 uintptr_t magic : 6; \
84 uintptr_t weakly_referenced : 1; \
85 uintptr_t deallocating : 1; \
86 uintptr_t has_sidetable_rc : 1; \
87 uintptr_t extra_rc : 8
88 # define RC_ONE (1ULL<<56)
89 # define RC_HALF (1ULL<<7)
90
91 # else
92 # error unknown architecture for packed isa
93 # endif
94
95 // SUPPORT_PACKED_ISA
96 #endif
97
98
99 #if SUPPORT_INDEXED_ISA
100
101 # if __ARM_ARCH_7K__ >= 2 || (__arm64__ && !__LP64__)
102 // armv7k or arm64_32
103
104 # define ISA_INDEX_IS_NPI_BIT 0
105 # define ISA_INDEX_IS_NPI_MASK 0x00000001
106 # define ISA_INDEX_MASK 0x0001FFFC
107 # define ISA_INDEX_SHIFT 2
108 # define ISA_INDEX_BITS 15
109 # define ISA_INDEX_COUNT (1 << ISA_INDEX_BITS)
110 # define ISA_INDEX_MAGIC_MASK 0x001E0001
111 # define ISA_INDEX_MAGIC_VALUE 0x001C0001
112 # define ISA_BITFIELD \
113 uintptr_t nonpointer : 1; \
114 uintptr_t has_assoc : 1; \
115 uintptr_t indexcls : 15; \
116 uintptr_t magic : 4; \
117 uintptr_t has_cxx_dtor : 1; \
118 uintptr_t weakly_referenced : 1; \
119 uintptr_t deallocating : 1; \
120 uintptr_t has_sidetable_rc : 1; \
121 uintptr_t extra_rc : 7
122 # define RC_ONE (1ULL<<25)
123 # define RC_HALF (1ULL<<6)
124
125 # else
126 # error unknown architecture for indexed isa
127 # endif
128
129 // SUPPORT_INDEXED_ISA
130 #endif
131
132
133 // _OBJC_ISA_H_
134 #endif