Fixed crash when using self in imp_implementationWithBlock on armv7a

main
Rupert Daniel 6 years ago committed by David Chisnall
parent 7166a41999
commit 710b2368cc

@ -26,6 +26,7 @@ int main(void)
{ {
__block int b = 0; __block int b = 0;
void* blk = ^(id self, int a) { void* blk = ^(id self, int a) {
assert([self class] == [Foo class]);
b += a; b += a;
return b; }; return b; };
blk = Block_copy(blk); blk = Block_copy(blk);
@ -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 class] == [Foo class]);
struct big b = {1, 2, 3, 4, 5}; struct big b = {1, 2, 3, 4, 5};
return b; return b;
}; };

@ -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

Loading…
Cancel
Save