Bug fixes in libobjc2:

- nil_method now returns 0, not receiver.

- Metaclasses actually get their dtables installed with the new ABI.  For some reason this wasn't being done, so class messages didn't work with the new ABI.  Now they do and (at least some) nontrivial programs work.

- Undid commenting out of the code setting the fast ivar access pointers.  I can't remember why this was commented out, but it seems not to break anything.  I have an LLVM pass that makes compiled code access these pointers, but it's not committed yet.
main
theraven 16 years ago
parent 29790da51c
commit f8b98a73a2

@ -745,7 +745,7 @@ __objc_compute_ivar_offsets (Class class)
*/ */
if (CLS_ISNEW_ABI(class)) if (CLS_ISNEW_ABI(class))
{ {
//*(class->ivar_offsets[i]) = ivar->ivar_offset; *(class->ivar_offsets[i]) = ivar->ivar_offset;
} }
} }
} }

@ -50,5 +50,5 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
id id
nil_method (id receiver, SEL op __attribute__ ((__unused__))) nil_method (id receiver, SEL op __attribute__ ((__unused__)))
{ {
return receiver; return 0;
} }

@ -12,7 +12,7 @@ Slot_t objc_msg_lookup_sender(id *receiver, SEL selector, id sender);
// Default implementations of the two new hooks. Return NULL. // Default implementations of the two new hooks. Return NULL.
static id objc_proxy_lookup_null(id receiver, SEL op) { return nil; } static id objc_proxy_lookup_null(id receiver, SEL op) { return nil; }
static Slot_t objc_msg_forward3_null(id receiver, SEL op) { return NULL; } static Slot_t objc_msg_forward3_null(id receiver, SEL op) { return &nil_slot; }
id (*objc_proxy_lookup)(id receiver, SEL op) = objc_proxy_lookup_null; id (*objc_proxy_lookup)(id receiver, SEL op) = objc_proxy_lookup_null;
Slot_t (*objc_msg_forward3)(id receiver, SEL op) = objc_msg_forward3_null; Slot_t (*objc_msg_forward3)(id receiver, SEL op) = objc_msg_forward3_null;
@ -24,14 +24,24 @@ Slot_t objc_msg_lookup_internal(id *receiver, SEL selector, id sender)
(sidx)selector->sel_id); (sidx)selector->sel_id);
if (0 == result) if (0 == result)
{ {
Class class = (*receiver)->class_pointer;
/* Install the dtable if it hasn't already been initialized. */ /* Install the dtable if it hasn't already been initialized. */
if ((*receiver)->class_pointer->dtable == __objc_uninstalled_dtable) if (dtable_for_class(class) == __objc_uninstalled_dtable)
{ {
objc_mutex_lock(__objc_runtime_mutex);
__objc_init_install_dtable (*receiver, selector); __objc_init_install_dtable (*receiver, selector);
objc_mutex_unlock(__objc_runtime_mutex); struct sarray *dtable = dtable_for_class(class);
struct sarray *dtable = dtable_for_class((*receiver)->class_pointer);
result = sarray_get_safe(dtable, (sidx)selector->sel_id); result = sarray_get_safe(dtable, (sidx)selector->sel_id);
if (0 == result)
{
objc_mutex_lock(__objc_runtime_mutex);
if (dtable_for_class(class) == __objc_uninstalled_dtable)
{
__objc_install_dispatch_table_for_class(class);
dtable = dtable_for_class(class);
}
objc_mutex_unlock(__objc_runtime_mutex);
result = sarray_get_safe(class->dtable, (sidx)selector->sel_id);
}
} }
else else
{ {

Loading…
Cancel
Save