return false;
}
+bool header_info::isPreoptimized() const
+{
+ return false;
+}
+
objc_selopt_t *preoptimizedSelectors(void)
{
return nil;
}
+Protocol *getPreoptimizedProtocol(const char *name)
+{
+ return nil;
+}
+
Class getPreoptimizedClass(const char *name)
{
return nil;
#include <objc-shared-cache.h>
+using objc_opt::objc_stringhash_offset_t;
+using objc_opt::objc_protocolopt_t;
using objc_opt::objc_clsopt_t;
using objc_opt::objc_headeropt_t;
using objc_opt::objc_opt_t;
return preoptimized;
}
+
+/***********************************************************************
+* Return YES if this image's dyld shared cache optimizations are valid.
+**********************************************************************/
+bool header_info::isPreoptimized() const
+{
+ // preoptimization disabled for some reason
+ if (!preoptimized) return NO;
+
+ // image not from shared cache, or not fixed inside shared cache
+ if (!_objcHeaderOptimizedByDyld(this)) return NO;
+
+ return YES;
+}
+
+
objc_selopt_t *preoptimizedSelectors(void)
{
return opt ? opt->selopt() : nil;
}
+
+Protocol *getPreoptimizedProtocol(const char *name)
+{
+ objc_protocolopt_t *protocols = opt ? opt->protocolopt() : nil;
+ if (!protocols) return nil;
+
+ return (Protocol *)protocols->getProtocol(name);
+}
+
+
Class getPreoptimizedClass(const char *name)
{
objc_clsopt_t *classes = opt ? opt->clsopt() : nil;
void *cls;
void *hi;
uint32_t count = classes->getClassAndHeader(name, cls, hi);
- if (count == 1 && ((header_info *)hi)->loaded) {
+ if (count == 1 && ((header_info *)hi)->isLoaded()) {
// exactly one matching class, and its image is loaded
return (Class)cls;
}
void *hilist[count];
classes->getClassesAndHeaders(name, clslist, hilist);
for (uint32_t i = 0; i < count; i++) {
- if (((header_info *)hilist[i])->loaded) {
+ if (((header_info *)hilist[i])->isLoaded()) {
return (Class)clslist[i];
}
}
uint32_t count = classes->getClassAndHeader(name, cls, hi);
if (count == 0) return nil;
- Class *result = (Class *)_calloc_internal(count, sizeof(Class));
- if (count == 1 && ((header_info *)hi)->loaded) {
+ Class *result = (Class *)calloc(count, sizeof(Class));
+ if (count == 1 && ((header_info *)hi)->isLoaded()) {
// exactly one matching class, and its image is loaded
result[(*outCount)++] = (Class)cls;
return result;
void *hilist[count];
classes->getClassesAndHeaders(name, clslist, hilist);
for (uint32_t i = 0; i < count; i++) {
- if (((header_info *)hilist[i])->loaded) {
+ if (((header_info *)hilist[i])->isLoaded()) {
result[(*outCount)++] = (Class)clslist[i];
}
}
else start = i+1;
}
-#if !NDEBUG
+#if DEBUG
for (uint32_t i = 0; i < count; i++) {
header_info *hi = headers+i;
if (mhdr == hi->mhdr) {