1.1 --- a/sourcepawn/jit/x86/jit_x86.cpp Mon Aug 12 00:23:54 2013 +0100
1.2 +++ b/sourcepawn/jit/x86/jit_x86.cpp Mon Aug 12 00:24:02 2013 +0100
1.3 @@ -208,7 +208,7 @@
1.4 }
1.5
1.6 static int
1.7 -GenerateArray(BaseRuntime *rt, InfoVars &vars, uint32_t argc, cell_t *argv, int autozero)
1.8 +GenerateArray(BaseRuntime *rt, uint32_t argc, cell_t *argv, int autozero)
1.9 {
1.10 sp_context_t *ctx = rt->GetBaseContext()->GetCtx();
1.11
1.12 @@ -1442,10 +1442,9 @@
1.13 __ push(autozero ? 1 : 0);
1.14 __ push(stk);
1.15 __ push(val);
1.16 - __ push(info);
1.17 __ push(intptr_t(rt_));
1.18 __ call(ExternalAddress((void *)GenerateArray));
1.19 - __ addl(esp, 5 * sizeof(void *));
1.20 + __ addl(esp, 4 * sizeof(void *));
1.21
1.22 // restore pri to tmp
1.23 __ pop(tmp);
1.24 @@ -1753,34 +1752,30 @@
1.25 }
1.26 }
1.27
1.28 -typedef int (*JIT_EXECUTE)(InfoVars *vars, void *addr, uint8_t *memory, sp_context_t *ctx);
1.29 +typedef int (*JIT_EXECUTE)(sp_context_t *ctx, uint8_t *memory, void *code);
1.30
1.31 static void *
1.32 GenerateEntry(void **retp)
1.33 {
1.34 AssemblerX86 masm;
1.35
1.36 - // Variables we're passed in:
1.37 - // InfoVars *vars, void *entry, uint8_t *memory, sp_context_t *
1.38 -
1.39 __ push(ebp);
1.40 __ movl(ebp, esp);
1.41
1.42 - __ push(esi);
1.43 - __ push(edi);
1.44 - __ push(ebx);
1.45 + __ push(esi); // ebp - 4
1.46 + __ push(edi); // ebp - 8
1.47 + __ push(ebx); // ebp - 12
1.48 + __ push(esp); // ebp - 16
1.49
1.50 - __ movl(esi, Operand(ebp, 8 + 4 * 0));
1.51 - __ movl(ecx, Operand(ebp, 8 + 4 * 1));
1.52 - __ movl(eax, Operand(ebp, 8 + 4 * 2));
1.53 + __ movl(ebx, Operand(ebp, 8 + 4 * 0));
1.54 + __ movl(eax, Operand(ebp, 8 + 4 * 1));
1.55 + __ movl(ecx, Operand(ebp, 8 + 4 * 2));
1.56
1.57 // Set up run-time registers.
1.58 - __ movl(ebx, Operand(ebp, 8 + 4 * 3));
1.59 __ movl(edi, Operand(ebx, offsetof(sp_context_t, sp)));
1.60 __ addl(edi, eax);
1.61 - __ movl(ebp, eax);
1.62 + __ movl(esi, eax);
1.63 __ movl(ebx, edi);
1.64 - __ movl(Operand(esi, AMX_INFO_NSTACK), esp);
1.65
1.66 // Align the stack.
1.67 __ andl(esp, 0xfffffff0);
1.68 @@ -1788,11 +1783,8 @@
1.69 // Call into plugin (align the stack first).
1.70 __ call(ecx);
1.71
1.72 - // Restore stack.
1.73 - __ movl(esp, Operand(info, AMX_INFO_NSTACK));
1.74 -
1.75 // Get input context, store rval.
1.76 - __ movl(ecx, Operand(esp, 32));
1.77 + __ movl(ecx, Operand(ebp, 8 + 4 * 0));
1.78 __ movl(Operand(ecx, offsetof(sp_context_t, rval)), pri);
1.79
1.80 // Set no error.
1.81 @@ -1805,6 +1797,9 @@
1.82 __ subl(stk, dat);
1.83 __ movl(Operand(ecx, offsetof(sp_context_t, sp)), stk);
1.84
1.85 + // Restore stack.
1.86 + __ movl(esp, Operand(ebp, -16));
1.87 +
1.88 // Restore registers and gtfo.
1.89 __ pop(ebx);
1.90 __ pop(edi);
1.91 @@ -1815,8 +1810,7 @@
1.92 // The universal emergency return will jump to here.
1.93 Label error;
1.94 __ bind(&error);
1.95 - __ movl(esp, Operand(info, AMX_INFO_NSTACK));
1.96 - __ movl(ecx, Operand(esp, 32)); // ret-path expects ecx = ctx
1.97 + __ movl(ecx, Operand(ebp, 8 + 4 * 0)); // ret-path expects ecx = ctx
1.98 __ jmp(&ret);
1.99
1.100 void *code = LinkCode(masm);
1.101 @@ -1975,11 +1969,8 @@
1.102 // Note that cip, hp, sp are saved and restored by Execute2().
1.103 ctx->cip = fn->GetPCodeAddress();
1.104
1.105 - InfoVars vars;
1.106 - /* vars.esp will be set in the entry code */
1.107 -
1.108 JIT_EXECUTE pfn = (JIT_EXECUTE)m_pJitEntry;
1.109 - int err = pfn(&vars, fn->GetEntryAddress(), runtime->plugin()->memory, ctx);
1.110 + int err = pfn(ctx, runtime->plugin()->memory, fn->GetEntryAddress());
1.111
1.112 *result = ctx->rval;
1.113 return err;