Merge remote-tracking branch 'origin/master' into arc-cxx

main
David Chisnall 6 years ago
commit 457361354c

@ -24,8 +24,10 @@ __attribute__((objc_root_class))
int main(void) int main(void)
{ {
__block Class cls = objc_getClass("Foo");
__block int b = 0; __block int b = 0;
void* blk = ^(id self, int a) { void* blk = ^(id self, int a) {
assert(self == cls);
b += a; b += a;
return b; }; return b; };
blk = Block_copy(blk); blk = Block_copy(blk);
@ -33,7 +35,6 @@ int main(void)
char *type = block_copyIMPTypeEncoding_np(blk); char *type = block_copyIMPTypeEncoding_np(blk);
assert(NULL != type); assert(NULL != type);
class_addMethod((objc_getMetaClass("Foo")), @selector(count:), imp, type); class_addMethod((objc_getMetaClass("Foo")), @selector(count:), imp, type);
Class cls = objc_getClass("Foo");
assert(2 == ((int(*)(id,SEL,int))imp)(cls, @selector(count:), 2)); assert(2 == ((int(*)(id,SEL,int))imp)(cls, @selector(count:), 2));
free(type); free(type);
assert(4 == [Foo count: 2]); assert(4 == [Foo count: 2]);
@ -45,6 +46,7 @@ int main(void)
assert(imp_getBlock(imp) != (blk)); assert(imp_getBlock(imp) != (blk));
blk = ^(id self) { blk = ^(id self) {
assert(self == cls);
struct big b = {1, 2, 3, 4, 5}; struct big b = {1, 2, 3, 4, 5};
return b; return b;
}; };

@ -37,6 +37,7 @@ set(TESTS
ResurrectInDealloc_arc.m ResurrectInDealloc_arc.m
RuntimeTest.m RuntimeTest.m
WeakBlock_arc.m WeakBlock_arc.m
WeakRefLoad.m
WeakReferences_arc.m WeakReferences_arc.m
WeakImportClass.m WeakImportClass.m
ivar_arc.m ivar_arc.m

@ -0,0 +1,22 @@
#include "Test.h"
#define SIZE 5000
int main(int argc, const char * argv[])
{
id t = [Test new];
id w1;
id w2;
objc_initWeak(&w1, t);
objc_initWeak(&w2, t);
[t release];
assert(objc_loadWeakRetained(&w1) == nil);
assert(objc_loadWeakRetained(&w2) == nil);
assert(w1 == nil);
assert(w2 == nil);
assert(objc_loadWeakRetained(&w1) == nil);
assert(objc_loadWeakRetained(&w2) == nil);
assert(w1 == nil);
assert(w2 == nil);
return 0;
}

@ -897,9 +897,11 @@ extern "C" OBJC_PUBLIC id objc_loadWeakRetained(id* addr)
// will acquire the lock before attempting to deallocate) // will acquire the lock before attempting to deallocate)
if (obj == nil) if (obj == nil)
{ {
// If we've destroyed this weak ref, then make sure that we also deallocate the object. // If the object is destroyed, drop this reference to the WeakRef
if (weakRefRelease(ref)) // struct.
if (ref != NULL)
{ {
weakRefRelease(ref);
*addr = nil; *addr = nil;
} }
return nil; return nil;

@ -126,7 +126,7 @@
.thumb .thumb
.macro trampoline arg0, arg1 .macro trampoline arg0, arg1
sub r12, pc, #4095 sub r12, pc, #4095
mov \arg0, \arg1 // Move self over _cmd mov \arg1, \arg0 // Move self over _cmd
ldr \arg0, [r12, #-5] // Load the block pointer over self ldr \arg0, [r12, #-5] // Load the block pointer over self
ldr r12, [r12, #-1] // Jump to the block function ldr r12, [r12, #-1] // Jump to the block function
bx r12 bx r12
@ -134,7 +134,7 @@
# else # else
.macro trampoline arg0, arg1 .macro trampoline arg0, arg1
sub r12, pc, #4096 sub r12, pc, #4096
mov \arg0, \arg1 // Move self over _cmd mov \arg1, \arg0 // Move self over _cmd
ldr \arg0, [r12, #-8] // Load the block pointer over self ldr \arg0, [r12, #-8] // Load the block pointer over self
ldr pc, [r12, #-4] // Jump to the block function ldr pc, [r12, #-4] // Jump to the block function
.endm .endm

@ -54,9 +54,9 @@
stp fp, lr, [sp, #192] stp fp, lr, [sp, #192]
add fp, sp, 192 add fp, sp, 192
stp \receiver, x8, [sp, #-16]! stp \receiver, x8, [sp, #-16]!
.cfi_def_cfa fp, 0 .cfi_def_cfa fp, 16
.cfi_offset fp, 0 .cfi_offset fp, -16
.cfi_offset lr, 8 .cfi_offset lr, -8
// We now have all argument registers, the link // We now have all argument registers, the link
// register and the receiver spilled on the // register and the receiver spilled on the
// stack, with sp containing // stack, with sp containing
@ -76,10 +76,11 @@
ldp q4, q5, [sp, #144] ldp q4, q5, [sp, #144]
ldp q6, q7, [sp, #176] ldp q6, q7, [sp, #176]
ldp fp, lr, [sp, #208] ldp fp, lr, [sp, #208]
ldp \receiver, x8, [sp], #16 ldp \receiver, x8, [sp], #(ARGUMENT_SPILL_SIZE + 16)
br x9 br x9
6: 6:
adr x10, SmallObjectClasses adrp x10, :got:SmallObjectClasses
ldr x10, [x10, :got_lo12:SmallObjectClasses]
ldr x9, [x10, x9, lsl #3] ldr x9, [x10, x9, lsl #3]
b 1b b 1b
.cfi_endproc .cfi_endproc

@ -302,7 +302,7 @@ objc_property_t* class_copyPropertyList(Class cls, unsigned int *outCount)
unsigned int out = 0; unsigned int out = 0;
for (struct objc_property_list *l=properties ; NULL!=l ; l=l->next) for (struct objc_property_list *l=properties ; NULL!=l ; l=l->next)
{ {
for (int i=0 ; i<properties->count ; i++) for (int i=0 ; i<l->count ; i++)
{ {
list[out++] = property_at_index(l, i); list[out++] = property_at_index(l, i);
} }

@ -421,7 +421,7 @@ objc_property_t *protocol_copyPropertyList2(Protocol *p, unsigned int *outCount,
unsigned int count = 0; unsigned int count = 0;
for (struct objc_property_list *l=properties ; l!=NULL ; l=l->next) for (struct objc_property_list *l=properties ; l!=NULL ; l=l->next)
{ {
count += properties->count; count += l->count;
} }
if (0 == count) if (0 == count)
{ {

Loading…
Cancel
Save