isa.h 5.2 KB

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