From 949469677e517d68c3c460a9494938d4fc5aa91e Mon Sep 17 00:00:00 2001 From: theraven Date: Tue, 25 Oct 2011 12:18:58 +0000 Subject: [PATCH] Fpret stuff (not very tested). --- Test/objc_msgSend.m | 11 +++++++++++ objc_msgSend.x86-32.S | 6 +++++- objc_msgSend.x86-64.S | 9 ++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Test/objc_msgSend.m b/Test/objc_msgSend.m index db5da2d..cd81e43 100644 --- a/Test/objc_msgSend.m +++ b/Test/objc_msgSend.m @@ -10,6 +10,12 @@ id objc_msgSend(id, SEL, ...); typedef struct { int a,b,c,d,e; } s; s objc_msgSend_stret(id, SEL, ...); +@interface Fake +- (int)izero; +- (float)fzero; +- (double)dzero; +- (long double)ldzero; +@end Class TestCls; @interface Test { id isa; }@end @@ -70,6 +76,11 @@ int main(void) assert(ret.c == 3); assert(ret.d == 4); assert(ret.e == 5); + Fake *f = nil; + assert(0 == [f izero]); + assert(0 == [f dzero]); + assert(0 == [f ldzero]); + assert(0 == [f fzero]); #ifdef BENCHMARK clock_t c1, c2; c1 = clock(); diff --git a/objc_msgSend.x86-32.S b/objc_msgSend.x86-32.S index d0ac7fc..ed7f207 100644 --- a/objc_msgSend.x86-32.S +++ b/objc_msgSend.x86-32.S @@ -56,7 +56,8 @@ mov SLOT_OFFSET(%eax), %eax jmp *%eax 4: # returnNil: - xor %eax, %eax + xor %eax, %eax # return 0 (int) + fldz # return 0 (float) ret 5: # slowSend: mov \sel(%esp), %ecx @@ -82,6 +83,9 @@ .endm .globl objc_msgSend .type objc_msgSend, @function +.globl objc_msgSend_fpret + .type objc_msgSend_fpret, @function +objc_msgSend_fpret: objc_msgSend: MSGSEND 4, 8 .globl objc_msgSend_stret diff --git a/objc_msgSend.x86-64.S b/objc_msgSend.x86-64.S index 5318247..545a8cd 100644 --- a/objc_msgSend.x86-64.S +++ b/objc_msgSend.x86-64.S @@ -60,7 +60,11 @@ mov SLOT_OFFSET(%r10), %r10 jmp *%r10 4: # returnNil: - xor %rax, %rax + # Both of the return registers are + # callee-save on x86-64, so we can + # return 0 in both in the same code: + xor %rax, %rax # Return 0 as an integer + pxor %xmm0, %xmm0 # Return 0 as a floating point value ret 5: # slowSend: push %rax # We need to preserve all registers that may contain arguments: @@ -131,6 +135,9 @@ .endm .globl objc_msgSend .type objc_msgSend, @function +.globl objc_msgSend_fpret + .type objc_msgSend_fpret, @function +objc_msgSend_fpret: objc_msgSend: MSGSEND %rdi, %rsi .globl objc_msgSend_stret