Move cip from sp_context_t to PluginContext.
This commit is contained in:
parent
8817de8a55
commit
d2005bd42a
@ -66,7 +66,7 @@ CContextTrace::GetTraceInfo(CallStackInfo *trace)
|
||||
cell_t cip;
|
||||
|
||||
if (m_Level == 0) {
|
||||
cip = m_ctx->cip;
|
||||
cip = context_->cip();
|
||||
} else if (context_->rp() > 0) {
|
||||
/* Entries go from ctx.rp - 1 to m_StartRp */
|
||||
cell_t offs, start, end;
|
||||
|
@ -238,10 +238,11 @@ Environment::UnpatchAllJumpsFromTimeout()
|
||||
int
|
||||
Environment::Invoke(PluginRuntime *runtime, CompiledFunction *fn, cell_t *result)
|
||||
{
|
||||
sp_context_t *ctx = runtime->GetBaseContext()->GetCtx();
|
||||
PluginContext *cx = runtime->GetBaseContext();
|
||||
sp_context_t *ctx = cx->GetCtx();
|
||||
|
||||
// Note that cip, hp, sp are saved and restored by Execute2().
|
||||
ctx->cip = fn->GetCodeOffset();
|
||||
*cx->addressOfCip() = fn->GetCodeOffset();
|
||||
|
||||
InvokeStubFn invoke = code_stubs_->InvokeStub();
|
||||
|
||||
|
@ -777,7 +777,7 @@ Interpret(PluginRuntime *rt, uint32_t aCodeStart, cell_t *rval)
|
||||
}
|
||||
|
||||
case OP_BREAK:
|
||||
ctx->cip = uintptr_t(cip - 1) - uintptr_t(plugin->pcode);
|
||||
*cx->addressOfCip() = uintptr_t(cip - 1) - uintptr_t(plugin->pcode);
|
||||
break;
|
||||
|
||||
case OP_BOUNDS:
|
||||
@ -805,13 +805,13 @@ Interpret(PluginRuntime *rt, uint32_t aCodeStart, cell_t *rval)
|
||||
err = SP_ERROR_STACKLOW;
|
||||
goto error;
|
||||
}
|
||||
ctx->cip = offset;
|
||||
*cx->addressOfCip() = offset;
|
||||
ctx->sp = uintptr_t(stk) - uintptr_t(plugin->memory);
|
||||
|
||||
int err = Interpret(rt, offset, &pri);
|
||||
|
||||
stk = reinterpret_cast<cell_t *>(plugin->memory + ctx->sp);
|
||||
ctx->cip = rcip;
|
||||
*cx->addressOfCip() = rcip;
|
||||
cx->popReturnCip();
|
||||
|
||||
if (err != SP_ERROR_NONE)
|
||||
|
@ -76,7 +76,6 @@ typedef struct sp_context_s
|
||||
cell_t sp; /**< Stack pointer */
|
||||
cell_t frm; /**< Frame pointer */
|
||||
cell_t rval; /**< Return value from InvokeFunction() */
|
||||
int32_t cip; /**< Code pointer last error occurred in */
|
||||
sp_plugin_t *plugin;
|
||||
PluginContext *basecx;
|
||||
} sp_context_t;
|
||||
|
@ -583,7 +583,7 @@ PluginContext::Execute2(IPluginFunction *function, const cell_t *params, unsigne
|
||||
save_exec = m_InExec;
|
||||
save_n_idx = last_native_;
|
||||
save_rp = rp_;
|
||||
save_cip = m_ctx.cip;
|
||||
save_cip = cip_;
|
||||
|
||||
/* Push parameters */
|
||||
|
||||
@ -644,7 +644,7 @@ PluginContext::Execute2(IPluginFunction *function, const cell_t *params, unsigne
|
||||
m_ctx.hp = save_hp;
|
||||
rp_ = save_rp;
|
||||
|
||||
m_ctx.cip = save_cip;
|
||||
cip_ = save_cip;
|
||||
last_native_ = save_n_idx;
|
||||
native_error_ = SP_ERROR_NONE;
|
||||
m_MsgCache[0] = '\0';
|
||||
|
@ -104,6 +104,13 @@ class PluginContext : public IPluginContext
|
||||
return offsetof(PluginContext, native_error_);
|
||||
}
|
||||
|
||||
int32_t *addressOfCip() {
|
||||
return &cip_;
|
||||
}
|
||||
int32_t cip() const {
|
||||
return cip_;
|
||||
}
|
||||
|
||||
// Return stack logic.
|
||||
bool pushReturnCip(cell_t cip) {
|
||||
if (rp_ >= SP_MAX_RETURN_STACK)
|
||||
@ -157,6 +164,9 @@ class PluginContext : public IPluginContext
|
||||
// Track the currently executing native index, and any error it throws.
|
||||
int32_t last_native_;
|
||||
int native_error_;
|
||||
|
||||
// Most recent CIP.
|
||||
int32_t cip_;
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_SOURCEPAWN_BASECONTEXT_H_
|
||||
|
@ -303,6 +303,7 @@ CompileFromThunk(PluginRuntime *runtime, cell_t pcode_offs, void **addrp, char *
|
||||
Compiler::Compiler(PluginRuntime *rt, cell_t pcode_offs)
|
||||
: env_(Environment::get()),
|
||||
rt_(rt),
|
||||
context_(rt->GetBaseContext()),
|
||||
plugin_(rt->plugin()),
|
||||
error_(SP_ERROR_NONE),
|
||||
pcode_start_(pcode_offs),
|
||||
|
@ -91,8 +91,7 @@ class Compiler
|
||||
void emitFloatCmp(ConditionCode cc);
|
||||
|
||||
ExternalAddress cipAddr() {
|
||||
sp_context_t *ctx = rt_->GetBaseContext()->GetCtx();
|
||||
return ExternalAddress(&ctx->cip);
|
||||
return ExternalAddress(context_->addressOfCip());
|
||||
}
|
||||
ExternalAddress hpAddr() {
|
||||
sp_context_t *ctx = rt_->GetBaseContext()->GetCtx();
|
||||
@ -107,6 +106,7 @@ class Compiler
|
||||
AssemblerX86 masm;
|
||||
sp::Environment *env_;
|
||||
PluginRuntime *rt_;
|
||||
PluginContext *context_;
|
||||
const sp_plugin_t *plugin_;
|
||||
int error_;
|
||||
uint32_t pcode_start_;
|
||||
|
Loading…
Reference in New Issue
Block a user