Eliminate InfoVars::cip (bug 5844 part 7, r=ds).

This commit is contained in:
David Anderson 2013-08-12 00:22:54 +01:00
parent 87ccd272ee
commit 2822bf7a65
5 changed files with 16 additions and 12 deletions

View File

@ -73,7 +73,7 @@ typedef struct sp_context_s
cell_t sp; /**< Stack pointer */ cell_t sp; /**< Stack pointer */
cell_t frm; /**< Frame pointer */ cell_t frm; /**< Frame pointer */
cell_t rval; /**< Return value from InvokeFunction() */ cell_t rval; /**< Return value from InvokeFunction() */
int32_t err_cip; /**< Code pointer last error occurred in */ int32_t cip; /**< Code pointer last error occurred in */
int32_t n_err; /**< Error code set by a native */ int32_t n_err; /**< Error code set by a native */
uint32_t n_idx; /**< Current native index being executed */ uint32_t n_idx; /**< Current native index being executed */
void * vm[8]; /**< VM-specific pointers */ void * vm[8]; /**< VM-specific pointers */

View File

@ -620,7 +620,7 @@ int BaseContext::Execute2(IPluginFunction *function, const cell_t *params, unsig
save_exec = m_InExec; save_exec = m_InExec;
save_n_idx = m_ctx.n_idx; save_n_idx = m_ctx.n_idx;
save_rp = m_ctx.rp; save_rp = m_ctx.rp;
save_cip = m_ctx.err_cip; save_cip = m_ctx.cip;
/* Push parameters */ /* Push parameters */
@ -688,7 +688,7 @@ int BaseContext::Execute2(IPluginFunction *function, const cell_t *params, unsig
m_pRuntime->plugin()->profiler->OnCallbackEnd(serial); m_pRuntime->plugin()->profiler->OnCallbackEnd(serial);
} }
m_ctx.err_cip = save_cip; m_ctx.cip = save_cip;
m_ctx.n_idx = save_n_idx; m_ctx.n_idx = save_n_idx;
m_ctx.n_err = SP_ERROR_NONE; m_ctx.n_err = SP_ERROR_NONE;
m_MsgCache[0] = '\0'; m_MsgCache[0] = '\0';

View File

@ -277,7 +277,7 @@ bool CContextTrace::GetTraceInfo(CallStackInfo *trace)
if (m_Level == 0) if (m_Level == 0)
{ {
cip = m_ctx->err_cip; cip = m_ctx->cip;
} }
else if (m_ctx->rp > 0) else if (m_ctx->rp > 0)
{ {

View File

@ -1298,7 +1298,7 @@ Compiler::emitOp(OPCODE op)
case OP_BREAK: case OP_BREAK:
{ {
cell_t cip = uintptr_t(cip_ - 1) - uintptr_t(plugin_->pcode); cell_t cip = uintptr_t(cip_ - 1) - uintptr_t(plugin_->pcode);
__ movl(Operand(info, AMX_INFO_CIP), cip); __ movl(Operand(cipAddr()), cip);
break; break;
} }
@ -1486,7 +1486,7 @@ Compiler::emitCall()
__ addl(Operand(eax, offsetof(sp_context_t, rp)), 1); __ addl(Operand(eax, offsetof(sp_context_t, rp)), 1);
// Store the CIP of the function we're about to call. // Store the CIP of the function we're about to call.
__ movl(Operand(info, AMX_INFO_CIP), offset); __ movl(Operand(cipAddr()), offset);
JitFunction *fun = rt_->GetJittedFunctionByOffset(offset); JitFunction *fun = rt_->GetJittedFunctionByOffset(offset);
if (!fun) { if (!fun) {
@ -1501,7 +1501,7 @@ Compiler::emitCall()
} }
// Restore the last cip. // Restore the last cip.
__ movl(Operand(info, AMX_INFO_CIP), cip); __ movl(Operand(cipAddr()), cip);
// Mark us as leaving the last frame. // Mark us as leaving the last frame.
__ movl(tmp, intptr_t(rt_->GetBaseContext()->GetCtx())); __ movl(tmp, intptr_t(rt_->GetBaseContext()->GetCtx()));
@ -1544,7 +1544,7 @@ Compiler::emitCallThunks()
__ ret(); __ ret();
__ bind(&error); __ bind(&error);
__ movl(Operand(info, AMX_INFO_CIP), thunk->pcode_offset); __ movl(Operand(cipAddr()), thunk->pcode_offset);
__ jmp(g_Jit.GetUniversalReturn()); __ jmp(g_Jit.GetUniversalReturn());
} }
} }
@ -1972,10 +1972,11 @@ int JITX86::InvokeFunction(BaseRuntime *runtime, JitFunction *fn, cell_t *result
{ {
sp_context_t *ctx = runtime->GetBaseContext()->GetCtx(); sp_context_t *ctx = runtime->GetBaseContext()->GetCtx();
ctx->cip = fn->GetPCodeAddress();
InfoVars vars; InfoVars vars;
vars.frm = ctx->sp; vars.frm = ctx->sp;
vars.hp = ctx->hp; vars.hp = ctx->hp;
vars.cip = fn->GetPCodeAddress();
/* vars.esp will be set in the entry code */ /* vars.esp will be set in the entry code */
JIT_EXECUTE pfn = (JIT_EXECUTE)m_pJitEntry; JIT_EXECUTE pfn = (JIT_EXECUTE)m_pJitEntry;
@ -1983,7 +1984,6 @@ int JITX86::InvokeFunction(BaseRuntime *runtime, JitFunction *fn, cell_t *result
ctx->sp = vars.frm; ctx->sp = vars.frm;
ctx->hp = vars.hp; ctx->hp = vars.hp;
ctx->err_cip = vars.cip;
*result = ctx->rval; *result = ctx->rval;
return err; return err;

View File

@ -39,6 +39,7 @@
#include <ke_vector.h> #include <ke_vector.h>
#include "jit_shared.h" #include "jit_shared.h"
#include "BaseRuntime.h" #include "BaseRuntime.h"
#include "sp_vm_basecontext.h"
#include "jit_function.h" #include "jit_function.h"
#include "opcodes.h" #include "opcodes.h"
@ -131,6 +132,11 @@ class Compiler
void emitErrorPath(Label *dest, int code); void emitErrorPath(Label *dest, int code);
void emitErrorPaths(); void emitErrorPaths();
ExternalAddress cipAddr() {
sp_context_t *ctx = rt_->GetBaseContext()->GetCtx();
return ExternalAddress(&ctx->cip);
}
private: private:
AssemblerX86 masm; AssemblerX86 masm;
BaseRuntime *rt_; BaseRuntime *rt_;
@ -197,13 +203,11 @@ const Register frm = ebx;
struct InfoVars { struct InfoVars {
ucell_t frm; ucell_t frm;
ucell_t hp; ucell_t hp;
ucell_t cip;
void *esp; void *esp;
}; };
#define AMX_INFO_FRAME offsetof(InfoVars, frm) #define AMX_INFO_FRAME offsetof(InfoVars, frm)
#define AMX_INFO_HEAP offsetof(InfoVars, hp) #define AMX_INFO_HEAP offsetof(InfoVars, hp)
#define AMX_INFO_CIP offsetof(InfoVars, cip)
#define AMX_INFO_NSTACK offsetof(InfoVars, esp) #define AMX_INFO_NSTACK offsetof(InfoVars, esp)
extern Knight::KeCodeCache *g_pCodeCache; extern Knight::KeCodeCache *g_pCodeCache;