From b0cf41de08216a5d91c4de6ec69f794e52dc8583 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Sat, 29 May 2010 00:22:21 -0500 Subject: [PATCH] Fixed potential problem when using bintools to call functions that return objects by value on OS X (bug 4392, r=dvander). Objects are only returned in memory when their sizes are greater than 8 or are not a power of 2. --- extensions/bintools/jit_call.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/extensions/bintools/jit_call.cpp b/extensions/bintools/jit_call.cpp index 576b3b67..3e2b8489 100644 --- a/extensions/bintools/jit_call.cpp +++ b/extensions/bintools/jit_call.cpp @@ -566,8 +566,19 @@ jit_rewind: if ((pRet->type == PassType_Object) && (pRet->flags & PASSFLAG_BYVAL)) { -#ifdef PLATFORM_POSIX +#ifdef PLATFORM_LINUX Needs_Retbuf = true; +#elif defined PLATFORM_APPLE + /* + * On OS X, need retbuf if size > 8 or not power of 2. + * + * See Mac OS X ABI Function Call Guide: + * http://developer.apple.com/mac/library/DOCUMENTATION/DeveloperTools/Conceptual/LowLevelABI/130-IA-32_Function_Calling_Conventions/IA32.html#//apple_ref/doc/uid/TP40002492-SW5 + */ + if (pRet->size > 8 || (pRet->size & (pRet->size - 1)) != 0) + { + Needs_Retbuf = true; + } #elif defined PLATFORM_WINDOWS if ((Convention == CallConv_ThisCall) || ((Convention == CallConv_Cdecl) &&