Eliminate InfoVars::cip (bug 5844 part 7, r=ds).
authorDavid Anderson <dvander@alliedmods.net>
Mon Aug 12 00:22:54 2013 +0100 (2013-08-12)
changeset 3990c7fb79059d7a
parent 3989 b73dae36a0da
child 3991 a93a52306572
Eliminate InfoVars::cip (bug 5844 part 7, r=ds).
sourcepawn/jit/jit_shared.h
sourcepawn/jit/sp_vm_basecontext.cpp
sourcepawn/jit/sp_vm_engine.cpp
sourcepawn/jit/x86/jit_x86.cpp
sourcepawn/jit/x86/jit_x86.h
     1.1 --- a/sourcepawn/jit/jit_shared.h	Mon Aug 12 00:22:41 2013 +0100
     1.2 +++ b/sourcepawn/jit/jit_shared.h	Mon Aug 12 00:22:54 2013 +0100
     1.3 @@ -73,7 +73,7 @@
     1.4  	cell_t			sp;				/**< Stack pointer */
     1.5  	cell_t			frm;			/**< Frame pointer */
     1.6  	cell_t			rval;			/**< Return value from InvokeFunction() */
     1.7 -	int32_t			err_cip;		/**< Code pointer last error occurred in */
     1.8 +	int32_t			cip;			/**< Code pointer last error occurred in */
     1.9  	int32_t			n_err;			/**< Error code set by a native */
    1.10  	uint32_t		n_idx;			/**< Current native index being executed */
    1.11  	void *			vm[8];			/**< VM-specific pointers */
     2.1 --- a/sourcepawn/jit/sp_vm_basecontext.cpp	Mon Aug 12 00:22:41 2013 +0100
     2.2 +++ b/sourcepawn/jit/sp_vm_basecontext.cpp	Mon Aug 12 00:22:54 2013 +0100
     2.3 @@ -620,7 +620,7 @@
     2.4  	save_exec = m_InExec;
     2.5  	save_n_idx = m_ctx.n_idx;
     2.6  	save_rp = m_ctx.rp;
     2.7 -	save_cip = m_ctx.err_cip;
     2.8 +	save_cip = m_ctx.cip;
     2.9  
    2.10  	/* Push parameters */
    2.11  
    2.12 @@ -688,7 +688,7 @@
    2.13  		m_pRuntime->plugin()->profiler->OnCallbackEnd(serial);
    2.14  	}
    2.15  
    2.16 -	m_ctx.err_cip = save_cip;
    2.17 +	m_ctx.cip = save_cip;
    2.18  	m_ctx.n_idx = save_n_idx;
    2.19  	m_ctx.n_err = SP_ERROR_NONE;
    2.20  	m_MsgCache[0] = '\0';
     3.1 --- a/sourcepawn/jit/sp_vm_engine.cpp	Mon Aug 12 00:22:41 2013 +0100
     3.2 +++ b/sourcepawn/jit/sp_vm_engine.cpp	Mon Aug 12 00:22:54 2013 +0100
     3.3 @@ -277,7 +277,7 @@
     3.4  
     3.5  	if (m_Level == 0)
     3.6  	{
     3.7 -		cip = m_ctx->err_cip;
     3.8 +		cip = m_ctx->cip;
     3.9  	}
    3.10  	else if (m_ctx->rp > 0)
    3.11  	{
     4.1 --- a/sourcepawn/jit/x86/jit_x86.cpp	Mon Aug 12 00:22:41 2013 +0100
     4.2 +++ b/sourcepawn/jit/x86/jit_x86.cpp	Mon Aug 12 00:22:54 2013 +0100
     4.3 @@ -1298,7 +1298,7 @@
     4.4      case OP_BREAK:
     4.5      {
     4.6        cell_t cip = uintptr_t(cip_ - 1) - uintptr_t(plugin_->pcode);
     4.7 -      __ movl(Operand(info, AMX_INFO_CIP), cip);
     4.8 +      __ movl(Operand(cipAddr()), cip);
     4.9        break;
    4.10      }
    4.11  
    4.12 @@ -1486,7 +1486,7 @@
    4.13    __ addl(Operand(eax, offsetof(sp_context_t, rp)), 1);
    4.14  
    4.15    // Store the CIP of the function we're about to call.
    4.16 -  __ movl(Operand(info, AMX_INFO_CIP), offset);
    4.17 +  __ movl(Operand(cipAddr()), offset);
    4.18  
    4.19    JitFunction *fun = rt_->GetJittedFunctionByOffset(offset);
    4.20    if (!fun) {
    4.21 @@ -1501,7 +1501,7 @@
    4.22    }
    4.23  
    4.24    // Restore the last cip.
    4.25 -  __ movl(Operand(info, AMX_INFO_CIP), cip);
    4.26 +  __ movl(Operand(cipAddr()), cip);
    4.27  
    4.28    // Mark us as leaving the last frame.
    4.29    __ movl(tmp, intptr_t(rt_->GetBaseContext()->GetCtx()));
    4.30 @@ -1544,7 +1544,7 @@
    4.31      __ ret();
    4.32  
    4.33      __ bind(&error);
    4.34 -    __ movl(Operand(info, AMX_INFO_CIP), thunk->pcode_offset);
    4.35 +    __ movl(Operand(cipAddr()), thunk->pcode_offset);
    4.36      __ jmp(g_Jit.GetUniversalReturn());
    4.37    }
    4.38  }
    4.39 @@ -1972,10 +1972,11 @@
    4.40  {
    4.41    sp_context_t *ctx = runtime->GetBaseContext()->GetCtx();
    4.42  
    4.43 +  ctx->cip = fn->GetPCodeAddress();
    4.44 +
    4.45    InfoVars vars;
    4.46    vars.frm = ctx->sp;
    4.47    vars.hp = ctx->hp;
    4.48 -  vars.cip = fn->GetPCodeAddress();
    4.49    /* vars.esp will be set in the entry code */
    4.50  
    4.51    JIT_EXECUTE pfn = (JIT_EXECUTE)m_pJitEntry;
    4.52 @@ -1983,7 +1984,6 @@
    4.53  
    4.54    ctx->sp = vars.frm;
    4.55    ctx->hp = vars.hp;
    4.56 -  ctx->err_cip = vars.cip;
    4.57  
    4.58    *result = ctx->rval;
    4.59    return err;
     5.1 --- a/sourcepawn/jit/x86/jit_x86.h	Mon Aug 12 00:22:41 2013 +0100
     5.2 +++ b/sourcepawn/jit/x86/jit_x86.h	Mon Aug 12 00:22:54 2013 +0100
     5.3 @@ -39,6 +39,7 @@
     5.4  #include <ke_vector.h>
     5.5  #include "jit_shared.h"
     5.6  #include "BaseRuntime.h"
     5.7 +#include "sp_vm_basecontext.h"
     5.8  #include "jit_function.h"
     5.9  #include "opcodes.h"
    5.10  
    5.11 @@ -131,6 +132,11 @@
    5.12    void emitErrorPath(Label *dest, int code);
    5.13    void emitErrorPaths();
    5.14  
    5.15 +  ExternalAddress cipAddr() {
    5.16 +    sp_context_t *ctx = rt_->GetBaseContext()->GetCtx();
    5.17 +    return ExternalAddress(&ctx->cip);
    5.18 +  }
    5.19 +
    5.20   private:
    5.21    AssemblerX86 masm;
    5.22    BaseRuntime *rt_;
    5.23 @@ -197,13 +203,11 @@
    5.24  struct InfoVars {
    5.25      ucell_t frm;
    5.26      ucell_t hp;
    5.27 -    ucell_t cip;
    5.28      void *esp;
    5.29  };
    5.30  
    5.31  #define AMX_INFO_FRAME          offsetof(InfoVars, frm)
    5.32  #define AMX_INFO_HEAP           offsetof(InfoVars, hp)
    5.33 -#define AMX_INFO_CIP            offsetof(InfoVars, cip)
    5.34  #define AMX_INFO_NSTACK         offsetof(InfoVars, esp)
    5.35  
    5.36  extern Knight::KeCodeCache *g_pCodeCache;