Remove InfoVars::frm (bug 5844 part 9, r=ds).
authorDavid Anderson <dvander@alliedmods.net>
Mon Aug 12 00:23:54 2013 +0100 (2013-08-12)
changeset 3992f1e8cad30a64
parent 3991 a93a52306572
child 3993 d06d6dacfa18
Remove InfoVars::frm (bug 5844 part 9, r=ds).
sourcepawn/jit/x86/jit_x86.cpp
sourcepawn/jit/x86/jit_x86.h
     1.1 --- a/sourcepawn/jit/x86/jit_x86.cpp	Mon Aug 12 00:23:00 2013 +0100
     1.2 +++ b/sourcepawn/jit/x86/jit_x86.cpp	Mon Aug 12 00:23:54 2013 +0100
     1.3 @@ -608,7 +608,7 @@
     1.4  
     1.5      case OP_PROC:
     1.6        // Push the old frame onto the stack.
     1.7 -      __ movl(tmp, Operand(info, AMX_INFO_FRAME));
     1.8 +      __ movl(tmp, Operand(frmAddr()));
     1.9        __ movl(Operand(stk, -4), tmp);
    1.10        __ subl(stk, 8);    // extra unused slot for non-existant CIP
    1.11  
    1.12 @@ -616,7 +616,7 @@
    1.13        __ movl(tmp, stk);
    1.14        __ movl(frm, stk);
    1.15        __ subl(tmp, dat);
    1.16 -      __ movl(Operand(info, AMX_INFO_FRAME), tmp);
    1.17 +      __ movl(Operand(frmAddr()), tmp);
    1.18  
    1.19        // Align the stack to 16-bytes (each call adds 4 bytes).
    1.20        __ subl(esp, 12);
    1.21 @@ -834,7 +834,7 @@
    1.22      {
    1.23        Register reg = (op == OP_ADDR_PRI) ? pri : alt;
    1.24        cell_t offset = readCell();
    1.25 -      __ movl(reg, Operand(info, AMX_INFO_FRAME));
    1.26 +      __ movl(reg, Operand(frmAddr()));
    1.27        __ addl(reg, offset);
    1.28        break;
    1.29      }
    1.30 @@ -988,7 +988,7 @@
    1.31        // Restore the old frame pointer.
    1.32        __ movl(frm, Operand(stk, 4));              // get the old frm
    1.33        __ addl(stk, 8);                            // pop stack
    1.34 -      __ movl(Operand(info, AMX_INFO_FRAME), frm);  // store back old frm
    1.35 +      __ movl(Operand(frmAddr()), frm);           // store back old frm
    1.36        __ addl(frm, dat);                          // relocate
    1.37  
    1.38        // Remove parameters.
    1.39 @@ -1594,13 +1594,11 @@
    1.40    __ push(stk);
    1.41    __ push(native_index);
    1.42  
    1.43 -  // Relocate all our absolute junk to be dat-relative, and store it all back
    1.44 -  // into the context.
    1.45 +  // Relocate our absolute stk to be dat-relative, and update the context's
    1.46 +  // view.
    1.47    __ movl(eax, intptr_t(rt_->GetBaseContext()->GetCtx()));
    1.48    __ subl(stk, dat);
    1.49    __ movl(Operand(eax, offsetof(sp_context_t, sp)), stk);
    1.50 -  __ movl(ecx, Operand(info, AMX_INFO_FRAME));
    1.51 -  __ movl(Operand(eax, offsetof(sp_context_t, frm)), ecx);
    1.52  
    1.53    // Push context and make the call.
    1.54    __ push(eax);
    1.55 @@ -1777,7 +1775,8 @@
    1.56    __ movl(eax, Operand(ebp, 8 + 4 * 2));
    1.57  
    1.58    // Set up run-time registers.
    1.59 -  __ movl(edi, Operand(esi, AMX_INFO_FRAME));
    1.60 +  __ movl(ebx, Operand(ebp, 8 + 4 * 3));
    1.61 +  __ movl(edi, Operand(ebx, offsetof(sp_context_t, sp)));
    1.62    __ addl(edi, eax);
    1.63    __ movl(ebp, eax);
    1.64    __ movl(ebx, edi);
    1.65 @@ -1792,7 +1791,7 @@
    1.66    // Restore stack.
    1.67    __ movl(esp, Operand(info, AMX_INFO_NSTACK));
    1.68  
    1.69 -  // Get input context.
    1.70 +  // Get input context, store rval.
    1.71    __ movl(ecx, Operand(esp, 32));
    1.72    __ movl(Operand(ecx, offsetof(sp_context_t, rval)), pri);
    1.73  
    1.74 @@ -1804,7 +1803,7 @@
    1.75    Label ret;
    1.76    __ bind(&ret);
    1.77    __ subl(stk, dat);
    1.78 -  __ movl(Operand(esi, AMX_INFO_FRAME), stk);
    1.79 +  __ movl(Operand(ecx, offsetof(sp_context_t, sp)), stk);
    1.80  
    1.81    // Restore registers and gtfo.
    1.82    __ pop(ebx);
    1.83 @@ -1817,6 +1816,7 @@
    1.84    Label error;
    1.85    __ bind(&error);
    1.86    __ movl(esp, Operand(info, AMX_INFO_NSTACK));
    1.87 +  __ movl(ecx, Operand(esp, 32)); // ret-path expects ecx = ctx
    1.88    __ jmp(&ret);
    1.89  
    1.90    void *code = LinkCode(masm);
    1.91 @@ -1976,14 +1976,11 @@
    1.92    ctx->cip = fn->GetPCodeAddress();
    1.93  
    1.94    InfoVars vars;
    1.95 -  vars.frm = ctx->sp;
    1.96    /* vars.esp will be set in the entry code */
    1.97  
    1.98    JIT_EXECUTE pfn = (JIT_EXECUTE)m_pJitEntry;
    1.99    int err = pfn(&vars, fn->GetEntryAddress(), runtime->plugin()->memory, ctx);
   1.100  
   1.101 -  ctx->sp = vars.frm;
   1.102 -
   1.103    *result = ctx->rval;
   1.104    return err;
   1.105  }
     2.1 --- a/sourcepawn/jit/x86/jit_x86.h	Mon Aug 12 00:23:00 2013 +0100
     2.2 +++ b/sourcepawn/jit/x86/jit_x86.h	Mon Aug 12 00:23:54 2013 +0100
     2.3 @@ -140,6 +140,10 @@
     2.4      sp_context_t *ctx = rt_->GetBaseContext()->GetCtx();
     2.5      return ExternalAddress(&ctx->hp);
     2.6    }
     2.7 +  ExternalAddress frmAddr() {
     2.8 +    sp_context_t *ctx = rt_->GetBaseContext()->GetCtx();
     2.9 +    return ExternalAddress(&ctx->frm);
    2.10 +  }
    2.11  
    2.12   private:
    2.13    AssemblerX86 masm;
    2.14 @@ -205,11 +209,9 @@
    2.15  const Register frm = ebx;
    2.16  
    2.17  struct InfoVars {
    2.18 -    ucell_t frm;
    2.19      void *esp;
    2.20  };
    2.21  
    2.22 -#define AMX_INFO_FRAME          offsetof(InfoVars, frm)
    2.23  #define AMX_INFO_NSTACK         offsetof(InfoVars, esp)
    2.24  
    2.25  extern Knight::KeCodeCache *g_pCodeCache;