+/* dyld_shared_cache_builder and obj-C agree on these definitions */
+enum {
+ OBJC_OPT_METHODNAME_START = 0,
+ OBJC_OPT_METHODNAME_END = 1,
+ OBJC_OPT_INLINED_METHODS_START = 2,
+ OBJC_OPT_INLINED_METHODS_END = 3,
+
+ __OBJC_OPT_OFFSETS_COUNT,
+};
+
+#if CONFIG_USE_PREOPT_CACHES
+extern uintptr_t objc_opt_offsets[__OBJC_OPT_OFFSETS_COUNT];
+#endif
+
+/* dyld_shared_cache_builder and obj-C agree on these definitions */
+struct preopt_cache_entry_t {
+ uint32_t sel_offs;
+ uint32_t imp_offs;
+};
+
+/* dyld_shared_cache_builder and obj-C agree on these definitions */
+struct preopt_cache_t {
+ int32_t fallback_class_offset;
+ union {
+ struct {
+ uint16_t shift : 5;
+ uint16_t mask : 11;
+ };
+ uint16_t hash_params;
+ };
+ uint16_t occupied : 14;
+ uint16_t has_inlines : 1;
+ uint16_t bit_one : 1;
+ preopt_cache_entry_t entries[];
+
+ inline int capacity() const {
+ return mask + 1;
+ }
+};
+
+// returns:
+// - the cached IMP when one is found
+// - nil if there's no cached value and the cache is dynamic
+// - `value_on_constant_cache_miss` if there's no cached value and the cache is preoptimized
+extern "C" IMP cache_getImp(Class cls, SEL sel, IMP value_on_constant_cache_miss = nil);