Back to index

lightning-sunbird  0.9+nobinonly
Functions
xptcinvoke_emx.cpp File Reference
#include "xptcprivate.h"

Go to the source code of this file.

Functions

static PRUint32 invoke_count_words (PRUint32 paramCount, nsXPTCVariant *s)
static void invoke_copy_to_stack (PRUint32 *d, uint32 paramCount, nsXPTCVariant *s)
 XPTC_InvokeByIndex (nsISupports *that, PRUint32 index, PRUint32 paramcount, nsXPTCVariant *params)

Function Documentation

static void invoke_copy_to_stack ( PRUint32 d,
uint32  paramCount,
nsXPTCVariant s 
) [static]

Definition at line 98 of file xptcinvoke_emx.cpp.

{
    for( PRUint32 i = 0; i < paramCount; i++, d++, s++)
    {
        if(s->IsPtrData())
            *((void**)d) = s->ptr;

        else {

            switch(s->type)
            {
             case nsXPTType::T_I8     : *((int8*)   d) = s->val.i8;          break;
             case nsXPTType::T_I16    : *((int16*)  d) = s->val.i16;         break;
             case nsXPTType::T_I32    : *((int32*)  d) = s->val.i32;         break;
             case nsXPTType::T_I64    : *((int64*)  d) = s->val.i64; d++;    break;
             case nsXPTType::T_U8     : *((uint8*)  d) = s->val.u8;          break;
             case nsXPTType::T_U16    : *((uint16*) d) = s->val.u16;         break;
             case nsXPTType::T_U32    : *((uint32*) d) = s->val.u32;         break;
             case nsXPTType::T_U64    : *((uint64*) d) = s->val.u64; d++;    break;
             case nsXPTType::T_FLOAT  : *((float*)  d) = s->val.f;           break;
             case nsXPTType::T_DOUBLE : *((double*) d) = s->val.d;   d++;    break;
             case nsXPTType::T_BOOL   : *((PRBool*) d) = s->val.b;           break;
             case nsXPTType::T_CHAR   : *((char*)   d) = s->val.c;           break;
             case nsXPTType::T_WCHAR  : *((wchar_t*)d) = s->val.wc;          break;
             default:
                // all the others are plain pointer types
                *((void**)d) = s->val.p;
                break;
            }
        }
    }
}

Here is the call graph for this function:

static PRUint32 invoke_count_words ( PRUint32  paramCount,
nsXPTCVariant s 
) [static]

Definition at line 66 of file xptcinvoke_emx.cpp.

{
    PRUint32 result = 0;

    for(PRUint32 i = 0; i < paramCount; i++, s++)
    {
        if(s->IsPtrData())
            result++;

        else {

            switch(s->type)
            { 
             // 64-bit types
             case nsXPTType::T_I64    :
             case nsXPTType::T_U64    :
             case nsXPTType::T_DOUBLE :
                 result+=2;
                 break;

             // all others are dwords
             default:
                 result++;
                 break;
            }
        }
    }
    return result;
}

Here is the call graph for this function:

XPTC_InvokeByIndex ( nsISupports *  that,
PRUint32  index,
PRUint32  paramcount,
nsXPTCVariant params 
)

Definition at line 133 of file xptcinvoke_emx.cpp.

{
   int   ibytes;
   void *pStack;
   int   result = NS_OK;

   // Find size in bytes necessary for call
   ibytes = 4 * invoke_count_words( paramcount, params);

   __asm__ __volatile__(
   "movl %1,    %%eax\n"                  /* load |ibytes| into eax */
   "subl %%eax, %%esp\n"                      /* make room on stack */
   "movl %%esp, %0"                       /* store base in |pStack| */
   : "=g" (pStack)   /* %0 */
   : "g" (ibytes)    /* %1 */
   : "ax", "memory", "sp"
   );

   // Fill in that gap in the stack with the params to the method
   invoke_copy_to_stack( (PRUint32*) pStack, paramcount, params);

   // push the hidden 'this' parameter, traverse the vtable,
   // and then call the method.

   __asm__ __volatile__(
   "movl  %2, %%eax\n"                         /* |that| ptr -> eax */
   "movl  (%%eax), %%edx\n"                          /* vptr -> edx */
   "movl  %3, %%ebx\n"
   "shl   $3, %%ebx\n"                      /* 8 bytes per method.. */
   "addl  $8, %%ebx\n"              /* ..plus 8 to skip over 1st 8 bytes of vtbl */

   "addl  %%ebx, %%edx\n"                 /* find appropriate vtbl entry */
   "movswl (%%edx),%%ecx\n"           /* get possible |that| ptr adjustment value */
   "addl  %%ecx, %%eax\n"                 /* adjust the |that| ptr (needed for multiple inheritance) */
   "pushl %%eax\n"                            /* enstack the possibly-adjusted |that| */

   "addl  $4, %%edx\n"              /* ..add 4 more to get to the method's entry point */

   "call  (%%edx)\n"                                 /* call method */
   "movl  %%eax, %0\n"                       /* save rc in |result| */
   "movl  %1, %%ebx\n"                            /* clear up stack */
   "addl  $4, %%ebx\n"
   "addl  %%ebx, %%esp"
   : "=g" (result)     /* %0 */
   : "g"  (ibytes),    /* %1 */
     "g"  (that),      /* %2 */
     "g"  (index)      /* %3 */
   : "ax", "bx", "dx", "memory", "sp"
   );

   return result;
}    

Here is the call graph for this function: