Clean up INFO register structure (bug 5844 part 1, r=ds).
authorDavid Anderson <dvander@alliedmods.net>
Sun Aug 11 11:30:27 2013 -0700 (2013-08-11)
changeset 3984d94a0d3bc008
parent 3983 46f4122981c2
child 3985 f1e2d9a7a276
Clean up INFO register structure (bug 5844 part 1, r=ds).
sourcepawn/jit/x86/jit_x86.cpp
sourcepawn/jit/x86/jit_x86.h
     1.1 --- a/sourcepawn/jit/x86/jit_x86.cpp	Sun Aug 11 11:27:19 2013 -0700
     1.2 +++ b/sourcepawn/jit/x86/jit_x86.cpp	Sun Aug 11 11:30:27 2013 -0700
     1.3 @@ -1956,31 +1956,31 @@
     1.4    return false;
     1.5  }
     1.6  
     1.7 -typedef int (*JIT_EXECUTE)(cell_t *vars, void *addr);
     1.8 +typedef int (*JIT_EXECUTE)(InfoVars *vars, void *addr);
     1.9  int JITX86::InvokeFunction(BaseRuntime *runtime, JitFunction *fn, cell_t *result)
    1.10  {
    1.11    int err;
    1.12    JIT_EXECUTE pfn;
    1.13    sp_context_t *ctx;
    1.14 -  cell_t vars[AMX_NUM_INFO_VARS];
    1.15 +  InfoVars vars;
    1.16  
    1.17    ctx = runtime->GetBaseContext()->GetCtx();
    1.18  
    1.19 -  vars[0] = ctx->sp;
    1.20 -  vars[1] = ctx->hp;
    1.21 -  vars[2] = (cell_t)result;
    1.22 -  vars[3] = (cell_t)ctx;
    1.23 -  vars[4] = (cell_t)(runtime->plugin()->memory + runtime->plugin()->mem_size);
    1.24 -  vars[5] = fn->GetPCodeAddress();
    1.25 -  vars[6] = runtime->plugin()->data_size;
    1.26 -  vars[7] = (cell_t)(runtime->plugin()->memory);
    1.27 -  /* vars[8] will be set to ESP */
    1.28 +  vars.frm = ctx->sp;
    1.29 +  vars.hp = ctx->hp;
    1.30 +  vars.rval = result;
    1.31 +  vars.ctx = ctx;
    1.32 +  vars.stp = runtime->plugin()->memory + runtime->plugin()->mem_size;
    1.33 +  vars.cip = fn->GetPCodeAddress();
    1.34 +  vars.data_size = runtime->plugin()->data_size;
    1.35 +  vars.memory = runtime->plugin()->memory;
    1.36 +  /* vars.esp will be set in the entry code */
    1.37  
    1.38    pfn = (JIT_EXECUTE)m_pJitEntry;
    1.39 -  err = pfn(vars, fn->GetEntryAddress());
    1.40 +  err = pfn(&vars, fn->GetEntryAddress());
    1.41  
    1.42 -  ctx->hp = vars[1];
    1.43 -  ctx->err_cip = vars[5];
    1.44 +  ctx->hp = vars.hp;
    1.45 +  ctx->err_cip = vars.cip;
    1.46  
    1.47    return err;
    1.48  }
     2.1 --- a/sourcepawn/jit/x86/jit_x86.h	Sun Aug 11 11:27:19 2013 -0700
     2.2 +++ b/sourcepawn/jit/x86/jit_x86.h	Sun Aug 11 11:30:27 2013 -0700
     2.3 @@ -206,17 +206,15 @@
     2.4      void *esp;
     2.5  };
     2.6  
     2.7 -#define AMX_NUM_INFO_VARS  9
     2.8 -
     2.9 -#define AMX_INFO_FRAME       0        //(same thing as above) 
    2.10 -#define AMX_INFO_HEAP        4        //not relocated
    2.11 -#define AMX_INFO_RETVAL      8        //physical
    2.12 -#define AMX_INFO_CONTEXT    12        //physical
    2.13 -#define AMX_INFO_STACKTOP   16        //relocated
    2.14 -#define AMX_INFO_CIP        20        //pcode CIP
    2.15 -#define AMX_INFO_DATASIZE   24        //plugin->data_size
    2.16 -#define AMX_INFO_MEMORY     28        //plugin->memory
    2.17 -#define AMX_INFO_NSTACK     32        //native stack
    2.18 +#define AMX_INFO_FRAME          offsetof(InfoVars, frm)
    2.19 +#define AMX_INFO_HEAP           offsetof(InfoVars, hp)
    2.20 +#define AMX_INFO_RETVAL         offsetof(InfoVars, rval)
    2.21 +#define AMX_INFO_CONTEXT        offsetof(InfoVars, ctx)
    2.22 +#define AMX_INFO_STACKTOP       offsetof(InfoVars, stp)
    2.23 +#define AMX_INFO_CIP            offsetof(InfoVars, cip)
    2.24 +#define AMX_INFO_DATASIZE       offsetof(InfoVars, data_size)
    2.25 +#define AMX_INFO_MEMORY         offsetof(InfoVars, memory)
    2.26 +#define AMX_INFO_NSTACK         offsetof(InfoVars, esp)
    2.27  
    2.28  extern Knight::KeCodeCache *g_pCodeCache;
    2.29  extern JITX86 g_Jit;