Bug 574650 Fix xpcom/reflect/xptcall for gcc on Solaris r=jst
authorGinn Chen <ginn.chen@sun.com>
Sun, 27 Jun 2010 00:56:47 +0800
changeset 46280 bf75b2c8ff45f02b36787659bc7d0a7c0f6bc488
parent 46279 5b2b66e6c7616c631372321d8dd3b24b660a208b
child 46281 f892729bce41f3990d59f068fab48d5347ed01b3
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs574650
milestone1.9.3a6pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 574650 Fix xpcom/reflect/xptcall for gcc on Solaris r=jst
xpcom/reflect/xptcall/src/md/unix/Makefile.in
xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_solaris.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_solaris.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_solaris.cpp
--- a/xpcom/reflect/xptcall/src/md/unix/Makefile.in
+++ b/xpcom/reflect/xptcall/src/md/unix/Makefile.in
@@ -142,29 +142,30 @@ endif
 ######################################################################
 # Solaris/Intel
 ######################################################################
 #
 # Solaris/Intel
 #
 ifeq ($(OS_ARCH),SunOS)
 ifeq (x86_64,$(OS_TEST))
-CPPSRCS		:= xptcstubs_x86_64_solaris.cpp
 ifndef GNU_CC
-CPPSRCS		+= xptcinvoke_x86_64_solaris.cpp
+CPPSRCS		:= xptcstubs_x86_64_solaris.cpp xptcinvoke_x86_64_solaris.cpp
 ASFILES		:= xptcstubs_asm_x86_64_solaris_SUNW.s
 else
-CPPSRCS		+= xptcinvoke_x86_64_unix.cpp
+CPPSRCS		:= xptcstubs_x86_64_linux.cpp xptcinvoke_x86_64_unix.cpp
 endif
 else
 ifeq (86,$(findstring 86,$(OS_TEST)))
-CPPSRCS		:= xptcinvoke_x86_solaris.cpp xptcstubs_x86_solaris.cpp
 # 28817: if Solaris Intel OS, and native compiler, always build optimised.
 ifndef GNU_CC
+CPPSRCS		:= xptcinvoke_x86_solaris.cpp xptcstubs_x86_solaris.cpp
 ASFILES		:= xptcinvoke_asm_x86_solaris_SUNW.s xptcstubs_asm_x86_solaris_SUNW.s
+else
+CPPSRCS		:= xptcinvoke_gcc_x86_unix.cpp xptcstubs_gcc_x86_unix.cpp
 endif
 endif
 endif
 endif
 
 ######################################################################
 # Alpha
 ######################################################################
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_solaris.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_solaris.cpp
@@ -40,19 +40,16 @@
 
 #include "xptcprivate.h"
 #include "xptc_platforms_unixish_x86.h"
 
 extern "C" {
 
 // Remember that these 'words' are 32bit DWORDS
 
-#if !defined(__SUNPRO_CC)               /* Sun Workshop Compiler. */
-static
-#endif
 PRUint32
 invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
 {
     PRUint32 result = 0;
     for(PRUint32 i = 0; i < paramCount; i++, s++)
     {
         if(s->IsPtrData())
         {
@@ -67,19 +64,16 @@ invoke_count_words(PRUint32 paramCount, 
         case nsXPTType::T_DOUBLE :
             result++;
             break;
         }
     }
     return result;
 }
 
-#if !defined(__SUNPRO_CC)               /* Sun Workshop Compiler. */
-static
-#endif
 void
 invoke_copy_to_stack(PRUint32 paramCount, nsXPTCVariant* s, PRUint32* d)
 {
     for(PRUint32 i = 0; i < paramCount; i++, d++, s++)
     {
         if(s->IsPtrData())
         {
             *((void**)d) = s->ptr;
@@ -99,71 +93,8 @@ invoke_copy_to_stack(PRUint32 paramCount
         case nsXPTType::T_I64    : *((PRInt64*) d) = s->val.i64; d++;    break;
         case nsXPTType::T_U64    : *((PRUint64*)d) = s->val.u64; d++;    break;
         case nsXPTType::T_DOUBLE : *((double*)  d) = s->val.d;   d++;    break;
         }
     }
 }
 
 }
-
-#if !defined(__SUNPRO_CC)               /* Sun Workshop Compiler. */
-EXPORT_XPCOM_API(nsresult)
-NS_InvokeByIndex_P(nsISupports* that, PRUint32 methodIndex,
-                 PRUint32 paramCount, nsXPTCVariant* params)
-{
-#ifdef __GNUC__            /* Gnu compiler. */
-  PRUint32 result;
-  PRUint32 n = invoke_count_words (paramCount, params) * 4;
-  void (*fn_copy) (unsigned int, nsXPTCVariant *, PRUint32 *) = invoke_copy_to_stack;
-  int temp1, temp2, temp3;
- 
- __asm__ __volatile__(
-    "subl  %8, %%esp\n\t" /* make room for params */
-    "pushl %%esp\n\t"
-    "pushl %7\n\t"
-    "pushl %6\n\t"
-    "call  *%0\n\t"       /* copy params */
-    "addl  $0xc, %%esp\n\t"
-    "movl  %4, %%ecx\n\t"
-#ifdef CFRONT_STYLE_THIS_ADJUST
-    "movl  (%%ecx), %%edx\n\t"
-    "movl  %5, %%eax\n\t"   /* function index */
-    "shl   $3, %%eax\n\t"   /* *= 8 */
-    "addl  $8, %%eax\n\t"   /* += 8 skip first entry */
-    "addl  %%eax, %%edx\n\t"
-    "movswl (%%edx), %%eax\n\t" /* 'this' offset */
-    "addl  %%eax, %%ecx\n\t"
-    "pushl %%ecx\n\t"
-    "addl  $4, %%edx\n\t"   /* += 4, method pointer */
-#else /* THUNK_BASED_THIS_ADJUST */
-    "pushl %%ecx\n\t"
-    "movl  (%%ecx), %%edx\n\t"
-    "movl  %5, %%eax\n\t"   /* function index */
-#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */
-    "leal  (%%edx,%%eax,4), %%edx\n\t"
-#else /* not G++ V3 ABI  */
-    "leal  8(%%edx,%%eax,4), %%edx\n\t"
-#endif /* G++ V3 ABI */
-#endif
-    "call  *(%%edx)\n\t"    /* safe to not cleanup esp */
-    "addl  $4, %%esp\n\t"
-    "addl  %8, %%esp"
-    : "=a" (result),        /* %0 */
-      "=c" (temp1),         /* %1 */
-      "=d" (temp2),         /* %2 */
-      "=g" (temp3)          /* %3 */
-    : "g" (that),           /* %4 */
-      "g" (methodIndex),    /* %5 */
-      "1" (paramCount),     /* %6 */
-      "2" (params),         /* %7 */
-      "g" (n),              /* %8 */
-      "0" (fn_copy)         /* %3 */
-    : "memory"
-    );
-    
-  return result;
-#else
-#error "can't find a compiler to use"
-#endif /* __GNUC__ */
-
-}
-#endif
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_solaris.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_solaris.cpp
@@ -153,90 +153,17 @@ PrepareAndDispatch(nsXPTCStubBase * self
     result = self->mOuter->CallMethod((PRUint16) methodIndex, info, dispatchParams);
 
     if (dispatchParams != paramBuffer)
         delete [] dispatchParams;
 
     return result;
 }
 
-#ifdef __SUNPRO_CC
 #define STUB_ENTRY(n)
-#else
-#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */
-// Linux/x86-64 uses gcc >= 3.1
-#define STUB_ENTRY(n) \
-asm(".section	\".text\"\n\t" \
-    ".align	2\n\t" \
-    ".if	" #n " < 10\n\t" \
-    ".globl	_ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
-    ".hidden	_ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
-    ".type	_ZN14nsXPTCStubBase5Stub" #n "Ev,@function\n" \
-    "_ZN14nsXPTCStubBase5Stub" #n "Ev:\n\t" \
-    ".elseif	" #n " < 100\n\t" \
-    ".globl	_ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
-    ".hidden	_ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
-    ".type	_ZN14nsXPTCStubBase6Stub" #n "Ev,@function\n" \
-    "_ZN14nsXPTCStubBase6Stub" #n "Ev:\n\t" \
-    ".elseif    " #n " < 1000\n\t" \
-    ".globl     _ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
-    ".hidden    _ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
-    ".type      _ZN14nsXPTCStubBase7Stub" #n "Ev,@function\n" \
-    "_ZN14nsXPTCStubBase7Stub" #n "Ev:\n\t" \
-    ".else\n\t" \
-    ".err	\"stub number " #n " >= 1000 not yet supported\"\n\t" \
-    ".endif\n\t" \
-    "movl	$" #n ", %eax\n\t" \
-    "jmp	SharedStub\n\t" \
-    ".if	" #n " < 10\n\t" \
-    ".size	_ZN14nsXPTCStubBase5Stub" #n "Ev,.-_ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
-    ".elseif	" #n " < 100\n\t" \
-    ".size	_ZN14nsXPTCStubBase6Stub" #n "Ev,.-_ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
-    ".else\n\t" \
-    ".size	_ZN14nsXPTCStubBase7Stub" #n "Ev,.-_ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
-    ".endif");
-
-// static nsresult SharedStub(PRUint32 methodIndex)
-asm(".section   \".text\"\n\t"
-    ".align     2\n\t"
-    ".type      SharedStub,@function\n\t"
-    "SharedStub:\n\t"
-    // make room for gpregs (48), fpregs (64)
-    "pushq      %rbp\n\t"
-    "movq       %rsp,%rbp\n\t"
-    "subq       $112,%rsp\n\t"
-    // save GP registers
-    "movq       %rdi,-112(%rbp)\n\t"
-    "movq       %rsi,-104(%rbp)\n\t"
-    "movq       %rdx, -96(%rbp)\n\t"
-    "movq       %rcx, -88(%rbp)\n\t"
-    "movq       %r8 , -80(%rbp)\n\t"
-    "movq       %r9 , -72(%rbp)\n\t"
-    "leaq       -112(%rbp),%rcx\n\t"
-    // save FP registers
-    "movsd      %xmm0,-64(%rbp)\n\t"
-    "movsd      %xmm1,-56(%rbp)\n\t"
-    "movsd      %xmm2,-48(%rbp)\n\t"
-    "movsd      %xmm3,-40(%rbp)\n\t"
-    "movsd      %xmm4,-32(%rbp)\n\t"
-    "movsd      %xmm5,-24(%rbp)\n\t"
-    "movsd      %xmm6,-16(%rbp)\n\t"
-    "movsd      %xmm7, -8(%rbp)\n\t"
-    "leaq       -64(%rbp),%r8\n\t"
-    // rdi has the 'self' pointer already
-    "movl       %eax,%esi\n\t"
-    "leaq       16(%rbp),%rdx\n\t"
-    "call       PrepareAndDispatch@plt\n\t"
-    "leave\n\t"
-    "ret\n\t"
-    ".size      SharedStub,.-SharedStub");
-#else
-#error "Unsupported compiler. Use gcc >= 3.1 for Linux/x86-64."
-#endif /* GNUC */
-#endif /* Sun Studio */
 
 #define SENTINEL_ENTRY(n) \
 nsresult nsXPTCStubBase::Sentinel##n() \
 { \
     NS_ERROR("nsXPTCStubBase::Sentinel called"); \
     return NS_ERROR_NOT_IMPLEMENTED; \
 }
 
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_solaris.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_solaris.cpp
@@ -37,19 +37,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 #include "xptiprivate.h"
 #include "xptc_platforms_unixish_x86.h"
 
-#if !defined(__SUNPRO_CC)               /* Sun Workshop Compiler. */
-static
-#endif
 nsresult
 PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
 {
 #define PARAM_BUFFER_COUNT     16
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = NULL;
     const nsXPTMethodInfo* info;
@@ -96,47 +93,18 @@ PrepareAndDispatch(nsXPTCStubBase* self,
     result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
 
     if(dispatchParams != paramBuffer)
         delete [] dispatchParams;
 
     return result;
 }
 
-#ifdef __GNUC__         /* Gnu Compiler. */
-#define STUB_ENTRY(n) \
-nsresult nsXPTCStubBase::Stub##n() \
-{ \
-  register nsresult (*method) (nsXPTCStubBase *, uint32, PRUint32 *) = PrepareAndDispatch; \
-  int temp0, temp1; \
-  register nsresult result; \
-  __asm__ __volatile__( \
-    "leal   0x0c(%%ebp), %%ecx\n\t"    /* args */ \
-    "pushl  %%ecx\n\t" \
-    "pushl  $"#n"\n\t"                 /* method index */ \
-    "movl   0x08(%%ebp), %%ecx\n\t"    /* this */ \
-    "pushl  %%ecx\n\t" \
-    "call   *%%edx\n\t"                /* PrepareAndDispatch */ \
-    "addl   $12, %%esp" \
-    : "=a" (result),    /* %0 */ \
-      "=&c" (temp0),    /* %1 */ \
-      "=d" (temp1)      /* %2 */ \
-    : "2" (method)      /* %2 */ \
-    : "memory" ); \
-    return result; \
-}
-
-#elif defined(__SUNPRO_CC)           /* Sun Workshop Compiler. */
-
 #define STUB_ENTRY(n)
 
-#else
-#error "can't find a compiler to use"
-#endif /* __GNUC__ */
-
 #define SENTINEL_ENTRY(n) \
 nsresult nsXPTCStubBase::Sentinel##n() \
 { \
     NS_ERROR("nsXPTCStubBase::Sentinel called"); \
     return NS_ERROR_NOT_IMPLEMENTED; \
 }
 
 #include "xptcstubsdef.inc"