Move context var initialization into BaseContext.

This commit is contained in:
David Anderson 2015-02-24 00:06:49 -08:00
parent 8c95919b32
commit 8cf3e227ea
3 changed files with 8 additions and 22 deletions

View File

@ -58,12 +58,18 @@ BaseContext::BaseContext(PluginRuntime *pRuntime)
m_ctx.n_idx = SP_ERROR_NONE;
m_ctx.rp = 0;
g_Jit.SetupContextVars(m_pRuntime, this, &m_ctx);
m_ctx.tracker = new tracker_t;
m_ctx.tracker->pBase = (ucell_t *)malloc(1024);
m_ctx.tracker->pCur = m_ctx.tracker->pBase;
m_ctx.tracker->size = 1024 / sizeof(cell_t);
m_ctx.basecx = this;
m_ctx.plugin = const_cast<sp_plugin_t *>(pRuntime->plugin());
}
BaseContext::~BaseContext()
{
g_Jit.FreeContextVars(&m_ctx);
free(m_ctx.tracker->pBase);
delete m_ctx.tracker;
}
IVirtualMachine *

View File

@ -1934,17 +1934,6 @@ JITX86::CompileFunction(PluginRuntime *prt, cell_t pcode_offs, int *err)
return fun;
}
void
JITX86::SetupContextVars(PluginRuntime *runtime, BaseContext *pCtx, sp_context_t *ctx)
{
ctx->tracker = new tracker_t;
ctx->tracker->pBase = (ucell_t *)malloc(1024);
ctx->tracker->pCur = ctx->tracker->pBase;
ctx->tracker->size = 1024 / sizeof(cell_t);
ctx->basecx = pCtx;
ctx->plugin = const_cast<sp_plugin_t *>(runtime->plugin());
}
SPVM_NATIVE_FUNC
JITX86::CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData)
{
@ -1996,13 +1985,6 @@ CompData::Abort()
delete this;
}
void
JITX86::FreeContextVars(sp_context_t *ctx)
{
free(ctx->tracker->pBase);
delete ctx->tracker;
}
bool
CompData::SetOption(const char *key, const char *val)
{

View File

@ -154,8 +154,6 @@ class JITX86
void ShutdownJIT();
ICompilation *StartCompilation(PluginRuntime *runtime);
ICompilation *StartCompilation();
void SetupContextVars(PluginRuntime *runtime, BaseContext *pCtx, sp_context_t *ctx);
void FreeContextVars(sp_context_t *ctx);
SPVM_NATIVE_FUNC CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData);
void DestroyFakeNative(SPVM_NATIVE_FUNC func);
CompiledFunction *CompileFunction(PluginRuntime *runtime, cell_t pcode_offs, int *err);