Some bug fixes.

main
theraven 14 years ago
parent 224de356cb
commit 27452f82f0

@ -653,8 +653,6 @@ PRIVATE void objc_send_initialize(id object)
} }
Class meta = class->isa; Class meta = class->isa;
// If this class is already initialized (e.g. in another thread), give up.
if (objc_test_class_flag(class, objc_class_flag_initialized)) { return; }
// Make sure that the class is resolved. // Make sure that the class is resolved.
objc_resolve_class(class); objc_resolve_class(class);
@ -673,9 +671,17 @@ PRIVATE void objc_send_initialize(id object)
if (objc_test_class_flag(class, objc_class_flag_initialized)) if (objc_test_class_flag(class, objc_class_flag_initialized))
{ {
UNLOCK(&initialize_lock); UNLOCK(&initialize_lock);
// We know that initialization has started because the flag is set.
// Check that it's finished by grabbing the class lock. This will be
// released once the class has been fully initialized
objc_sync_enter((id)meta);
objc_sync_exit((id)meta);
assert(dtable_for_class(class) != uninstalled_dtable);
return; return;
} }
LOCK_OBJECT_FOR_SCOPE((id)meta);
// Set the initialized flag on both this class and its metaclass, to make // Set the initialized flag on both this class and its metaclass, to make
// sure that +initialize is only ever sent once. // sure that +initialize is only ever sent once.
objc_set_class_flag(class, objc_class_flag_initialized); objc_set_class_flag(class, objc_class_flag_initialized);
@ -704,7 +710,6 @@ PRIVATE void objc_send_initialize(id object)
return; return;
} }
LOCK_OBJECT_FOR_SCOPE((id)meta);
// Create an entry in the dtable look-aside buffer for this. When sending // Create an entry in the dtable look-aside buffer for this. When sending

@ -4,6 +4,7 @@
#define DATA_OFFSET 12 #define DATA_OFFSET 12
#define SLOT_OFFSET 16 #define SLOT_OFFSET 16
.macro MSGSEND receiver, sel .macro MSGSEND receiver, sel
.cfi_startproc
movl \receiver(%esp), %eax movl \receiver(%esp), %eax
test %eax, %eax # If the receiver is nil test %eax, %eax # If the receiver is nil
jz 4f # return nil jz 4f # return nil
@ -61,14 +62,11 @@
mov \sel(%esp), %ecx mov \sel(%esp), %ecx
lea \receiver(%esp), %eax lea \receiver(%esp), %eax
push %ebx # Save old %ebx
push %ecx # _cmd push %ecx # _cmd
push %eax # &self push %eax # &self
call __i686.get_pc_thunk.bx .cfi_def_cfa_offset 12
addl $_GLOBAL_OFFSET_TABLE_, %ebx
call slowMsgLookup@PLT call slowMsgLookup@PLT
add $8, %esp add $8, %esp # restore the stack
popl %ebx
jmp *%eax jmp *%eax
@ -80,6 +78,7 @@
mov (%eax), %eax mov (%eax), %eax
popl %ebx popl %ebx
jmp 1b jmp 1b
.cfi_endproc
.endm .endm
.globl objc_msgSend .globl objc_msgSend
.type objc_msgSend, @function .type objc_msgSend, @function

Loading…
Cancel
Save