changeset 26:9abe1ac89aca test_without_inline

Update assembler code to 64bit
author Nina Engelhardt
date Mon, 29 Aug 2011 13:42:28 +0200
parents cd2d0a81e3f7
children 2c146b6b3890
files SSR.s SSR_PluginFns.c SSR_lib.c
diffstat 3 files changed, 36 insertions(+), 28 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/SSR.s	Mon Aug 29 13:42:28 2011 +0200
     1.3 @@ -0,0 +1,21 @@
     1.4 +
     1.5 +//Assembly code takes the return addr off the stack and saves
     1.6 +// into the singleton.  The first field in the singleton is the
     1.7 +// "endInstrAddr" field, and the return addr is at 0x4(%ebp)
     1.8 +.globl asm_save_ret_to_singleton
     1.9 +asm_save_ret_to_singleton:
    1.10 +    movq 0x8(%rbp),     %rax   #get ret address, ebp is the same as in the calling function
    1.11 +    movq     %rax,     (%rdi) #write ret addr to endInstrAddr field
    1.12 +    ret
    1.13 +
    1.14 +
    1.15 +//Assembly code changes the return addr on the stack to the one
    1.16 +// saved into the singleton by the end-singleton-fn
    1.17 +//The stack's return addr is at 0x4(%%ebp)
    1.18 +.globl asm_write_ret_from_singleton
    1.19 +asm_write_ret_from_singleton:
    1.20 +    movq    (%rdi),    %rax  #get endInstrAddr field
    1.21 +    movq      %rax,    0x8(%rbp) #write return addr to the stack of the caller
    1.22 +    ret
    1.23 +
    1.24 +
     2.1 --- a/SSR_PluginFns.c	Thu Jun 02 14:35:03 2011 +0200
     2.2 +++ b/SSR_PluginFns.c	Mon Aug 29 13:42:28 2011 +0200
     2.3 @@ -33,6 +33,8 @@
     2.4   * to the slave -- return FALSE to let Master loop know scheduling that
     2.5   * slave failed.
     2.6   */
     2.7 +char __Scheduler[] = "FIFO Scheduler"; //Gobal variable for name in saved histogram
     2.8 +
     2.9  VirtProcr *
    2.10  SSR__schedule_virt_procr( void *_semEnv, int coreNum )
    2.11   { VirtProcr   *schedPr;
     3.1 --- a/SSR_lib.c	Thu Jun 02 14:35:03 2011 +0200
     3.2 +++ b/SSR_lib.c	Mon Aug 29 13:42:28 2011 +0200
     3.3 @@ -494,6 +494,10 @@
     3.4   * trying to get the data through from different cores.
     3.5   */
     3.6  
     3.7 +/*asm function declarations*/
     3.8 +void asm_save_ret_to_singleton(SSRSingleton *singletonPtrAddr);
     3.9 +void asm_write_ret_from_singleton(SSRSingleton *singletonPtrAddr);
    3.10 +
    3.11  /*Fn singleton uses ID as index into array of singleton structs held in the
    3.12   * semantic environment.
    3.13   */
    3.14 @@ -509,12 +513,8 @@
    3.15     VMS__send_sem_request( &reqData, animPr );
    3.16     if( animPr->dataRetFromReq ) //will be 0 or addr of label in end singleton
    3.17      {
    3.18 -      asm volatile("movl         %0,      %%eax;  \
    3.19 -                    jmp                  *%%eax"  \
    3.20 -      /* outputs */ :                             \
    3.21 -      /* inputs  */ : "g"(animPr->dataRetFromReq) \
    3.22 -      /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx","%edi","%esi"\
    3.23 -                   );
    3.24 +       SSRSemEnv *semEnv = VMS__give_sem_env_for( animPr );
    3.25 +       asm_write_ret_from_singleton(&(semEnv->fnSingletons[ singletonID]));
    3.26      }
    3.27   }
    3.28  
    3.29 @@ -527,7 +527,8 @@
    3.30   {
    3.31     SSRSemReq  reqData;
    3.32  
    3.33 -   if( *singletonAddr && (*singletonAddr)->hasFinished ) goto JmpToEndSingleton;
    3.34 +   if( *singletonAddr && (*singletonAddr)->hasFinished )
    3.35 +       goto JmpToEndSingleton;
    3.36     
    3.37     reqData.reqType          = singleton_data_start;
    3.38     reqData.singletonPtrAddr = singletonAddr;
    3.39 @@ -537,15 +538,8 @@
    3.40      {    //Assembly code changes the return addr on the stack to the one
    3.41           // saved into the singleton by the end-singleton-fn
    3.42           //The return addr is at 0x4(%%ebp)
    3.43 -      JmpToEndSingleton:
    3.44 -      asm volatile("movl        %0,      %%eax;   \
    3.45 -                    movl    (%%eax),     %%ebx;   \
    3.46 -                    movl    (%%ebx),     %%eax;   \
    3.47 -                    movl     %%eax,  0x4(%%ebp);" \
    3.48 -      /* outputs */ :                             \
    3.49 -      /* inputs  */ : "m"(singletonAddr) \
    3.50 -      /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx","%edi","%esi"\
    3.51 -                   );
    3.52 +        JmpToEndSingleton:
    3.53 +          asm_write_ret_from_singleton(*singletonAddr);
    3.54      }
    3.55     //now, simply return
    3.56     //will exit either from the start singleton call or the end-singleton call
    3.57 @@ -565,7 +559,7 @@
    3.58        //don't need this addr until after at least one singleton has reached
    3.59        // this function
    3.60     SSRSemEnv *semEnv = VMS__give_sem_env_for( animPr );
    3.61 -   semEnv->fnSingletons[ singletonID].endInstrAddr = &&EndSingletonInstrAddr;
    3.62 +   asm_write_ret_from_singleton(&(semEnv->fnSingletons[ singletonID]));
    3.63  
    3.64     reqData.reqType     = singleton_fn_end;
    3.65     reqData.singletonID = singletonID;
    3.66 @@ -589,17 +583,8 @@
    3.67        // function in different places for different data-singletons.
    3.68  //   (*(singletonAddr))->endInstrAddr =  &&EndDataSingletonInstrAddr;
    3.69  
    3.70 -         //Assembly code takes the return addr off the stack and saves
    3.71 -         // into the singleton.  The first field in the singleton is the
    3.72 -         // "endInstrAddr" field, and the return addr is at 0x4(%%ebp)
    3.73 -      asm volatile("movl 0x4(%%ebp),     %%eax;   \
    3.74 -                    movl        %0,      %%ebx;   \
    3.75 -                    movl    (%%ebx),     %%ecx;   \
    3.76 -                    movl     %%eax,     (%%ecx);" \
    3.77 -      /* outputs */ :                             \
    3.78 -      /* inputs  */ : "m"(singletonPtrAddr) \
    3.79 -      /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx","%edi","%esi"\
    3.80 -                   );
    3.81 +
    3.82 +   asm_save_ret_to_singleton(*singletonPtrAddr);
    3.83  
    3.84     reqData.reqType          = singleton_data_end;
    3.85     reqData.singletonPtrAddr = singletonPtrAddr;