diff --git a/sourcepawn/jit/x86/jit_x86.cpp b/sourcepawn/jit/x86/jit_x86.cpp index 98091e71..67becf86 100644 --- a/sourcepawn/jit/x86/jit_x86.cpp +++ b/sourcepawn/jit/x86/jit_x86.cpp @@ -1956,31 +1956,31 @@ bool CompData::SetOption(const char *key, const char *val) return false; } -typedef int (*JIT_EXECUTE)(cell_t *vars, void *addr); +typedef int (*JIT_EXECUTE)(InfoVars *vars, void *addr); int JITX86::InvokeFunction(BaseRuntime *runtime, JitFunction *fn, cell_t *result) { int err; JIT_EXECUTE pfn; sp_context_t *ctx; - cell_t vars[AMX_NUM_INFO_VARS]; + InfoVars vars; ctx = runtime->GetBaseContext()->GetCtx(); - vars[0] = ctx->sp; - vars[1] = ctx->hp; - vars[2] = (cell_t)result; - vars[3] = (cell_t)ctx; - vars[4] = (cell_t)(runtime->plugin()->memory + runtime->plugin()->mem_size); - vars[5] = fn->GetPCodeAddress(); - vars[6] = runtime->plugin()->data_size; - vars[7] = (cell_t)(runtime->plugin()->memory); - /* vars[8] will be set to ESP */ + vars.frm = ctx->sp; + vars.hp = ctx->hp; + vars.rval = result; + vars.ctx = ctx; + vars.stp = runtime->plugin()->memory + runtime->plugin()->mem_size; + vars.cip = fn->GetPCodeAddress(); + vars.data_size = runtime->plugin()->data_size; + vars.memory = runtime->plugin()->memory; + /* vars.esp will be set in the entry code */ pfn = (JIT_EXECUTE)m_pJitEntry; - err = pfn(vars, fn->GetEntryAddress()); + err = pfn(&vars, fn->GetEntryAddress()); - ctx->hp = vars[1]; - ctx->err_cip = vars[5]; + ctx->hp = vars.hp; + ctx->err_cip = vars.cip; return err; } diff --git a/sourcepawn/jit/x86/jit_x86.h b/sourcepawn/jit/x86/jit_x86.h index 4b408e4f..f70e945c 100644 --- a/sourcepawn/jit/x86/jit_x86.h +++ b/sourcepawn/jit/x86/jit_x86.h @@ -206,17 +206,15 @@ struct InfoVars { void *esp; }; -#define AMX_NUM_INFO_VARS 9 - -#define AMX_INFO_FRAME 0 //(same thing as above) -#define AMX_INFO_HEAP 4 //not relocated -#define AMX_INFO_RETVAL 8 //physical -#define AMX_INFO_CONTEXT 12 //physical -#define AMX_INFO_STACKTOP 16 //relocated -#define AMX_INFO_CIP 20 //pcode CIP -#define AMX_INFO_DATASIZE 24 //plugin->data_size -#define AMX_INFO_MEMORY 28 //plugin->memory -#define AMX_INFO_NSTACK 32 //native stack +#define AMX_INFO_FRAME offsetof(InfoVars, frm) +#define AMX_INFO_HEAP offsetof(InfoVars, hp) +#define AMX_INFO_RETVAL offsetof(InfoVars, rval) +#define AMX_INFO_CONTEXT offsetof(InfoVars, ctx) +#define AMX_INFO_STACKTOP offsetof(InfoVars, stp) +#define AMX_INFO_CIP offsetof(InfoVars, cip) +#define AMX_INFO_DATASIZE offsetof(InfoVars, data_size) +#define AMX_INFO_MEMORY offsetof(InfoVars, memory) +#define AMX_INFO_NSTACK offsetof(InfoVars, esp) extern Knight::KeCodeCache *g_pCodeCache; extern JITX86 g_Jit;