Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
invoke_test.cpp File Reference
#include <stdio.h>

Go to the source code of this file.

Classes

class  base
class  foo
class  bar

Defines

#define NS_IMETHOD   virtual nsresult
#define NS_IMETHODIMP   nsresult

Typedefs

typedef unsigned nsresult
typedef unsigned PRUint32
typedef unsigned nsXPCVariant

Functions

void docall (foo *f, int i, int j)
static PRUint32 invoke_count_words (PRUint32 paramCount, nsXPCVariant *s)
static void invoke_copy_to_stack (PRUint32 *d, PRUint32 paramCount, nsXPCVariant *s)
static nsresult DoInvoke (void *that, PRUint32 index, PRUint32 paramCount, nsXPCVariant *params)
int main ()
 main()

Define Documentation

#define NS_IMETHOD   virtual nsresult

Definition at line 49 of file invoke_test.cpp.

Definition at line 50 of file invoke_test.cpp.


Typedef Documentation

typedef unsigned nsresult

Definition at line 40 of file invoke_test.cpp.

typedef unsigned nsXPCVariant

Definition at line 42 of file invoke_test.cpp.

typedef unsigned PRUint32

Definition at line 41 of file invoke_test.cpp.


Function Documentation

void docall ( foo f,
int  i,
int  j 
)

Definition at line 108 of file invoke_test.cpp.

                                 {
  f->callme1(i, j); 
}

Here is the call graph for this function:

static nsresult DoInvoke ( void that,
PRUint32  index,
PRUint32  paramCount,
nsXPCVariant params 
) [static]

Definition at line 175 of file invoke_test.cpp.

{
    PRUint32 result;
    void* fn_count = invoke_count_words;
    void* fn_copy = invoke_copy_to_stack;

 __asm__ __volatile__(
    "pushl %4\n\t"
    "pushl %3\n\t"
    "movl  %5, %%eax\n\t"
    "call  *%%eax\n\t"       /* count words */
    "addl  $0x8, %%esp\n\t"
    "shl   $2, %%eax\n\t"    /* *= 4 */
    "subl  %%eax, %%esp\n\t" /* make room for params */
    "movl  %%esp, %%edx\n\t"
    "pushl %4\n\t"
    "pushl %3\n\t"
    "pushl %%edx\n\t"
    "movl  %6, %%eax\n\t"
    "call  *%%eax\n\t"       /* copy params */
    "addl  $0xc, %%esp\n\t"
    "movl  %1, %%ecx\n\t"
    "pushl %%ecx\n\t"
    "movl  (%%ecx), %%edx\n\t"
    "movl  %2, %%eax\n\t"   /* function index */
    "shl   $2, %%eax\n\t"   /* *= 4 */
    "addl  $8, %%eax\n\t"   /* += 8 */
    "addl  %%eax, %%edx\n\t"
    "call  *(%%edx)\n\t"    /* safe to not cleanup esp */
    "movl  %%eax, %0"
    : "=g" (result)         /* %0 */
    : "g" (that),           /* %1 */
      "g" (index),          /* %2 */
      "g" (paramCount),     /* %3 */
      "g" (params),         /* %4 */
      "g" (fn_count),       /* %5 */
      "g" (fn_copy)         /* %6 */
    : "ax", "cx", "dx", "memory" 
    );
  
  return result;
}    

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 166 of file invoke_test.cpp.

{
    for(PRUint32 i = 0; i < paramCount; i++, d++, s++)
    {
        *((PRUint32*)d) = *((PRUint32*)s);
    }
}
static PRUint32 invoke_count_words ( PRUint32  paramCount,
nsXPCVariant s 
) [static]

Definition at line 160 of file invoke_test.cpp.

{
    return paramCount;
}    
int main ( void  )

main()

Definition at line 222 of file invoke_test.cpp.

{
  nsXPCVariant params1[2] = {1,2};
  nsXPCVariant params2[2] = {2,4};
  nsXPCVariant params3[2] = {3,6};

  foo* a = new bar();

//  printf("calling via C++...\n");
//  docall(a, 12, 24);

  printf("calling via ASM...\n");
  DoInvoke(a, 1, 2, params1);
  DoInvoke(a, 2, 2, params2);
  DoInvoke(a, 3, 2, params3);

  return 0;
}

Here is the call graph for this function: