Rename objc_slot and objc_slot_v1.

The objc_slot type was exposed via public interfaces and the renaming
broke things (including the GNUstep build).
main
David Chisnall 8 years ago
parent f569aeb42b
commit 4e9fd2ec8a

@ -166,8 +166,8 @@ IMP forward(id o, SEL s)
return (IMP)fwdMany;
}
static struct objc_slot_v1 slot;
struct objc_slot_v1 *forward_slot(id o, SEL s)
static struct objc_slot slot;
struct objc_slot *forward_slot(id o, SEL s)
{
slot.method = (IMP)fwd;
return &slot;

@ -22,7 +22,7 @@ _Static_assert(__builtin_offsetof(SparseArray, data) == DATA_OFFSET,
"Incorrect data offset for assembly");
// Slots are now a public interface to part of the method structure, so make
// sure that it's safe to use method and slot structures interchangeably.
_Static_assert(__builtin_offsetof(struct objc_slot, method) == SLOT_OFFSET,
_Static_assert(__builtin_offsetof(struct objc_slot2, method) == SLOT_OFFSET,
"Incorrect slot offset for assembly");
_Static_assert(__builtin_offsetof(struct objc_method, imp) == SLOT_OFFSET,
"Incorrect slot offset for assembly");
@ -49,7 +49,7 @@ static uint32_t dtable_depth = 8;
*/
static Class ownerForMethod(Class cls, SEL sel)
{
struct objc_slot *slot = objc_get_slot2(cls, sel, NULL);
struct objc_slot2 *slot = objc_get_slot2(cls, sel, NULL);
if (slot == NULL)
{
return Nil;

@ -39,7 +39,7 @@ extern id (*objc_proxy_lookup)(id receiver, SEL op);
* New runtime forwarding hook. This is no longer used, but is retained to
* prevent errors at link time.
*/
extern struct objc_slot_v1 *(*__objc_msg_forward3)(id, SEL) OBJC_DEPRECATED;
extern struct objc_slot *(*__objc_msg_forward3)(id, SEL) OBJC_DEPRECATED;
/**
* Forwarding hook. Takes an object and a selector and returns a method that
* handles the forwarding.
@ -67,13 +67,13 @@ OBJC_HOOK Class (*_objc_class_for_boxing_foreign_exception)(int64_t exceptionCla
* an exception or perform some other action.
*/
extern IMP (*_objc_selector_type_mismatch2)(Class cls,
SEL selector, struct objc_slot *result);
SEL selector, struct objc_slot2 *result);
/**
* Legacy hook for when selector types do not match. This is only called
* `_objc_selector_type_mismatch2` is not installed.
*/
OBJC_HOOK struct objc_slot_v1 *(*_objc_selector_type_mismatch)(Class cls,
SEL selector, struct objc_slot_v1 *result) OBJC_DEPRECATED;
OBJC_HOOK struct objc_slot *(*_objc_selector_type_mismatch)(Class cls,
SEL selector, struct objc_slot *result) OBJC_DEPRECATED;
/**
* Returns the object if it is not currently in the process of being

@ -855,14 +855,14 @@ unsigned sel_copyTypedSelectors_np(const char *selName, SEL *const sels, unsigne
* New ABI lookup function. Receiver may be modified during lookup or proxy
* forwarding and the sender may affect how lookup occurs.
*/
extern struct objc_slot_v1 *objc_msg_lookup_sender(id *receiver, SEL selector, id sender)
extern struct objc_slot *objc_msg_lookup_sender(id *receiver, SEL selector, id sender)
OBJC_NONPORTABLE OBJC_DEPRECATED;
/**
* Deprecated function for accessing a slot without going via any forwarding
* mechanisms.
*/
extern struct objc_slot_v1 *objc_get_slot(Class, SEL)
extern struct objc_slot *objc_get_slot(Class, SEL)
OBJC_NONPORTABLE OBJC_DEPRECATED;
/**
@ -871,7 +871,7 @@ extern struct objc_slot_v1 *objc_get_slot(Class, SEL)
* counter. If this value is equal to `objc_method_cache_version` then the
* slot is safe to reuse without performing another lookup.
*/
extern struct objc_slot *objc_get_slot2(Class, SEL, uint64_t*)
extern struct objc_slot2 *objc_get_slot2(Class, SEL, uint64_t*)
OBJC_NONPORTABLE;
/**
@ -880,7 +880,7 @@ extern struct objc_slot *objc_get_slot2(Class, SEL, uint64_t*)
* counter. If this value is equal to `objc_method_cache_version` then the
* slot is safe to reuse without performing another lookup.
*/
extern struct objc_slot *objc_slot_lookup_version(id *receiver, SEL selector, uint64_t*)
extern struct objc_slot2 *objc_slot_lookup_version(id *receiver, SEL selector, uint64_t*)
OBJC_NONPORTABLE;
/**

@ -25,14 +25,14 @@
* pointer of the receiver and the message and the version of the slot to your
* cached version.
*/
struct objc_slot
struct objc_slot2
{
IMP method;
} OBJC_NONPORTABLE;
_Atomic(uint64_t) objc_method_cache_version;
struct objc_slot_v1
struct objc_slot
{
/** The class to which this slot is attached (used internally). */
Class owner;

@ -368,7 +368,7 @@ Method class_getInstanceMethod(Class aClass, SEL aSelector)
if (classHasInstalledDtable(aClass))
{
// Do a dtable lookup to find out which class the method comes from.
struct objc_slot *slot = objc_get_slot2(aClass, aSelector, NULL);
struct objc_slot2 *slot = objc_get_slot2(aClass, aSelector, NULL);
if (NULL == slot)
{
slot = objc_get_slot2(aClass, sel_registerName(sel_getName(aSelector)), NULL);

@ -14,24 +14,24 @@ static long double nil_method_D(id self, SEL _cmd) { return 0; }
static double nil_method_d(id self, SEL _cmd) { return 0; }
static float nil_method_f(id self, SEL _cmd) { return 0; }
static struct objc_slot_v1 nil_slot_v1 = { Nil, Nil, 0, 1, (IMP)nil_method };
static struct objc_slot_v1 nil_slot_D_v1 = { Nil, Nil, 0, 1, (IMP)nil_method_D };
static struct objc_slot_v1 nil_slot_d_v1 = { Nil, Nil, 0, 1, (IMP)nil_method_d };
static struct objc_slot_v1 nil_slot_f_v1 = { Nil, Nil, 0, 1, (IMP)nil_method_f };
static struct objc_slot nil_slot_v1 = { Nil, Nil, 0, 1, (IMP)nil_method };
static struct objc_slot nil_slot_D_v1 = { Nil, Nil, 0, 1, (IMP)nil_method_D };
static struct objc_slot nil_slot_d_v1 = { Nil, Nil, 0, 1, (IMP)nil_method_d };
static struct objc_slot nil_slot_f_v1 = { Nil, Nil, 0, 1, (IMP)nil_method_f };
static struct objc_method nil_slot = { (IMP)nil_method, NULL, NULL };
static struct objc_method nil_slot_D = { (IMP)nil_method_D, NULL, NULL };
static struct objc_method nil_slot_d = { (IMP)nil_method_d, NULL, NULL };
static struct objc_method nil_slot_f = { (IMP)nil_method_f, NULL, NULL };
static struct objc_slot* objc_slot_lookup(id *receiver, SEL selector);
static struct objc_slot2* objc_slot_lookup(id *receiver, SEL selector);
// Default implementations of the two new hooks. Return NULL.
static id objc_proxy_lookup_null(id receiver, SEL op) { return nil; }
static struct objc_slot_v1 *objc_msg_forward3_null(id receiver, SEL op) { return &nil_slot_v1; }
static struct objc_slot *objc_msg_forward3_null(id receiver, SEL op) { return &nil_slot_v1; }
id (*objc_proxy_lookup)(id receiver, SEL op) = objc_proxy_lookup_null;
struct objc_slot_v1 *(*__objc_msg_forward3)(id receiver, SEL op) = objc_msg_forward3_null;
struct objc_slot *(*__objc_msg_forward3)(id receiver, SEL op) = objc_msg_forward3_null;
static IMP forward2(id self, SEL _cmd)
{
@ -40,11 +40,11 @@ static IMP forward2(id self, SEL _cmd)
IMP (*__objc_msg_forward2)(id, SEL) = forward2;
__thread struct objc_method uncacheable_slot = { (IMP)nil_method, NULL, NULL };
__thread struct objc_slot_v1 uncacheable_slot_v1 = { Nil, Nil, 0, 0, (IMP)nil_method };
__thread struct objc_slot uncacheable_slot_v1 = { Nil, Nil, 0, 0, (IMP)nil_method };
#ifndef NO_SELECTOR_MISMATCH_WARNINGS
static IMP objc_selector_type_mismatch(Class cls, SEL
selector, struct objc_slot *result)
selector, struct objc_slot2 *result)
{
fprintf(stderr, "Calling [%s %c%s] with incorrect signature. "
"Method has %s (%s), selector has %s\n",
@ -58,28 +58,28 @@ static IMP objc_selector_type_mismatch(Class cls, SEL
}
#else
static IMP objc_selector_type_mismatch(Class cls, SEL
selector, struct objc_slot *result)
selector, struct objc_slot2 *result)
{
return result->method;
}
#endif
IMP (*_objc_selector_type_mismatch2)(Class cls, SEL
selector, struct objc_slot *result) = objc_selector_type_mismatch;
struct objc_slot_v1 *(*_objc_selector_type_mismatch)(Class cls, SEL
selector, struct objc_slot_v1 *result);
selector, struct objc_slot2 *result) = objc_selector_type_mismatch;
struct objc_slot *(*_objc_selector_type_mismatch)(Class cls, SEL
selector, struct objc_slot *result);
static IMP call_mismatch_hook(Class cls, SEL sel, struct objc_slot *slot)
static IMP call_mismatch_hook(Class cls, SEL sel, struct objc_slot2 *slot)
{
if (_objc_selector_type_mismatch &&
(!_objc_selector_type_mismatch2 ||
(_objc_selector_type_mismatch2 == objc_selector_type_mismatch)))
{
struct objc_slot_v1 fwdslot;
struct objc_slot fwdslot;
fwdslot.types = ((struct objc_method*)slot)->types;
fwdslot.selector = sel;
fwdslot.method = slot->method;
struct objc_slot_v1 *slot_v1 = _objc_selector_type_mismatch(cls, sel, &uncacheable_slot_v1);
struct objc_slot *slot_v1 = _objc_selector_type_mismatch(cls, sel, &uncacheable_slot_v1);
return slot_v1->method;
}
return _objc_selector_type_mismatch2(cls, sel, slot);
@ -89,7 +89,7 @@ static
// Uncomment for debugging
//__attribute__((noinline))
__attribute__((always_inline))
struct objc_slot *objc_msg_lookup_internal(id *receiver, SEL selector, uint64_t *version)
struct objc_slot2 *objc_msg_lookup_internal(id *receiver, SEL selector, uint64_t *version)
{
if (version)
{
@ -97,7 +97,7 @@ struct objc_slot *objc_msg_lookup_internal(id *receiver, SEL selector, uint64_t
}
Class class = classForObject((*receiver));
retry:;
struct objc_slot * result = objc_dtable_lookup(class->dtable, selector->index);
struct objc_slot2 * result = objc_dtable_lookup(class->dtable, selector->index);
if (UNLIKELY(0 == result))
{
dtable_t dtable = dtable_for_class(class);
@ -130,7 +130,7 @@ retry:;
*version = 0;
}
uncacheable_slot.imp = call_mismatch_hook(class, selector, result);
result = (struct objc_slot*)&uncacheable_slot;
result = (struct objc_slot2*)&uncacheable_slot;
}
id newReceiver = objc_proxy_lookup(*receiver, selector);
// If some other library wants us to play forwarding games, try
@ -147,7 +147,7 @@ retry:;
*version = 0;
}
uncacheable_slot.imp = __objc_msg_forward2(*receiver, selector);
result = (struct objc_slot*)&uncacheable_slot;
result = (struct objc_slot2*)&uncacheable_slot;
}
}
}
@ -170,7 +170,7 @@ PRIVATE void logInt(void *a)
* New Objective-C lookup function. This permits the lookup to modify the
* receiver and also supports multi-dimensional dispatch based on the sender.
*/
struct objc_slot_v1 *objc_msg_lookup_sender(id *receiver, SEL selector, id sender)
struct objc_slot *objc_msg_lookup_sender(id *receiver, SEL selector, id sender)
{
// Returning a nil slot allows the caller to cache the lookup for nil too,
// although this is not particularly useful because the nil method can be
@ -197,7 +197,7 @@ struct objc_slot_v1 *objc_msg_lookup_sender(id *receiver, SEL selector, id sende
return &nil_slot_v1;
}
struct objc_slot *slot = objc_msg_lookup_internal(receiver, selector, NULL);
struct objc_slot2 *slot = objc_msg_lookup_internal(receiver, selector, NULL);
uncacheable_slot_v1.owner = Nil;
uncacheable_slot_v1.types = sel_getType_np(((struct objc_method*)slot)->selector);
uncacheable_slot_v1.selector = selector;
@ -206,7 +206,7 @@ struct objc_slot_v1 *objc_msg_lookup_sender(id *receiver, SEL selector, id sende
}
static struct objc_slot* objc_slot_lookup(id *receiver, SEL selector)
static struct objc_slot2* objc_slot_lookup(id *receiver, SEL selector)
{
// Returning a nil slot allows the caller to cache the lookup for nil too,
// although this is not particularly useful because the nil method can be
@ -225,18 +225,18 @@ static struct objc_slot* objc_slot_lookup(id *receiver, SEL selector)
}
switch (selector->types[0])
{
case 'D': return (struct objc_slot*)&nil_slot_D;
case 'd': return (struct objc_slot*)&nil_slot_d;
case 'f': return (struct objc_slot*)&nil_slot_f;
case 'D': return (struct objc_slot2*)&nil_slot_D;
case 'd': return (struct objc_slot2*)&nil_slot_d;
case 'f': return (struct objc_slot2*)&nil_slot_f;
}
}
return (struct objc_slot*)&nil_slot;
return (struct objc_slot2*)&nil_slot;
}
return objc_msg_lookup_internal(receiver, selector, NULL);
}
struct objc_slot *objc_slot_lookup_version(id *receiver, SEL selector, uint64_t *version)
struct objc_slot2 *objc_slot_lookup_version(id *receiver, SEL selector, uint64_t *version)
{
// Returning a nil slot allows the caller to cache the lookup for nil too,
// although this is not particularly useful because the nil method can be
@ -259,12 +259,12 @@ struct objc_slot *objc_slot_lookup_version(id *receiver, SEL selector, uint64_t
}
switch (selector->types[0])
{
case 'D': return (struct objc_slot*)&nil_slot_D;
case 'd': return (struct objc_slot*)&nil_slot_d;
case 'f': return (struct objc_slot*)&nil_slot_f;
case 'D': return (struct objc_slot2*)&nil_slot_D;
case 'd': return (struct objc_slot2*)&nil_slot_d;
case 'f': return (struct objc_slot2*)&nil_slot_f;
}
}
return (struct objc_slot*)&nil_slot;
return (struct objc_slot2*)&nil_slot;
}
return objc_msg_lookup_internal(receiver, selector, version);
@ -276,13 +276,13 @@ IMP objc_msg_lookup2(id *receiver, SEL selector)
}
struct objc_slot *objc_slot_lookup_super2(struct objc_super *super, SEL selector)
struct objc_slot2 *objc_slot_lookup_super2(struct objc_super *super, SEL selector)
{
id receiver = super->receiver;
if (receiver)
{
Class class = super->class;
struct objc_slot * result = objc_dtable_lookup(dtable_for_class(class),
struct objc_slot2 * result = objc_dtable_lookup(dtable_for_class(class),
selector->index);
if (0 == result)
{
@ -302,20 +302,20 @@ struct objc_slot *objc_slot_lookup_super2(struct objc_super *super, SEL selector
objc_send_initialize((id)class);
return objc_slot_lookup_super2(super, selector);
}
return (struct objc_slot*)&nil_slot;
return (struct objc_slot2*)&nil_slot;
}
return result;
}
return (struct objc_slot*)&nil_slot;
return (struct objc_slot2*)&nil_slot;
}
struct objc_slot_v1 *objc_slot_lookup_super(struct objc_super *super, SEL selector)
struct objc_slot *objc_slot_lookup_super(struct objc_super *super, SEL selector)
{
id receiver = super->receiver;
if (receiver)
{
Class class = super->class;
struct objc_slot * result = objc_dtable_lookup(dtable_for_class(class),
struct objc_slot2 * result = objc_dtable_lookup(dtable_for_class(class),
selector->index);
if (0 == result)
{
@ -349,13 +349,13 @@ struct objc_slot_v1 *objc_slot_lookup_super(struct objc_super *super, SEL select
/**
* looks up a slot without invoking any forwarding mechanisms
*/
struct objc_slot *objc_get_slot2(Class cls, SEL selector, uint64_t *version)
struct objc_slot2 *objc_get_slot2(Class cls, SEL selector, uint64_t *version)
{
if (version)
{
*version = objc_method_cache_version;
}
struct objc_slot * result = objc_dtable_lookup(cls->dtable, selector->index);
struct objc_slot2 * result = objc_dtable_lookup(cls->dtable, selector->index);
if (0 == result)
{
void *dtable = dtable_for_class(cls);
@ -385,16 +385,16 @@ struct objc_slot *objc_get_slot2(Class cls, SEL selector, uint64_t *version)
*version = 0;
}
uncacheable_slot.imp = call_mismatch_hook(cls, selector, result);
result = (struct objc_slot*)&uncacheable_slot;
result = (struct objc_slot2*)&uncacheable_slot;
}
}
}
return result;
}
struct objc_slot_v1 *objc_get_slot(Class cls, SEL selector)
struct objc_slot *objc_get_slot(Class cls, SEL selector)
{
struct objc_slot *result = objc_get_slot2(cls, selector, NULL);
struct objc_slot2 *result = objc_get_slot2(cls, selector, NULL);
if (result == NULL)
{
return NULL;
@ -421,7 +421,7 @@ BOOL class_respondsToSelector(Class cls, SEL selector)
IMP class_getMethodImplementation(Class cls, SEL name)
{
if ((Nil == cls) || (NULL == name)) { return (IMP)0; }
struct objc_slot * slot = objc_get_slot2(cls, name, NULL);
struct objc_slot2 * slot = objc_get_slot2(cls, name, NULL);
return NULL != slot ? slot->method : __objc_msg_forward2(nil, name);
}
@ -468,7 +468,7 @@ IMP objc_msg_lookup(id receiver, SEL selector)
if (nil == receiver) { return (IMP)nil_method; }
id self = receiver;
struct objc_slot * slot = objc_msg_lookup_internal(&self, selector, NULL);
struct objc_slot2 * slot = objc_msg_lookup_internal(&self, selector, NULL);
// If the receiver is changed by the lookup mechanism then we have to fall
// back to old-style forwarding.
if (self != receiver)

Loading…
Cancel
Save