Rename BaseRuntime to PluginRuntime.
This commit is contained in:
parent
b8d2be9a0d
commit
2f71cb4cd7
@ -1,4 +1,15 @@
|
|||||||
// vim: set ts=8 sts=2 sw=2 tw=99 et:
|
// vim: set sts=2 ts=8 sw=2 tw=99 et:
|
||||||
|
//
|
||||||
|
// Copyright (C) 2006-2015 AlliedModders LLC
|
||||||
|
//
|
||||||
|
// This file is part of SourcePawn. SourcePawn is free software: you can
|
||||||
|
// redistribute it and/or modify it under the terms of the GNU General Public
|
||||||
|
// License as published by the Free Software Foundation, either version 3 of
|
||||||
|
// the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along with
|
||||||
|
// SourcePawn. If not, see http://www.gnu.org/licenses/.
|
||||||
|
//
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -20,7 +31,7 @@ IsPointerCellAligned(void *p)
|
|||||||
return uintptr_t(p) % 4 == 0;
|
return uintptr_t(p) % 4 == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseRuntime::BaseRuntime()
|
PluginRuntime::PluginRuntime()
|
||||||
: m_Debug(&m_plugin),
|
: m_Debug(&m_plugin),
|
||||||
m_pCtx(NULL),
|
m_pCtx(NULL),
|
||||||
m_PubFuncs(NULL),
|
m_PubFuncs(NULL),
|
||||||
@ -43,7 +54,7 @@ BaseRuntime::BaseRuntime()
|
|||||||
g_Jit.RegisterRuntime(this);
|
g_Jit.RegisterRuntime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseRuntime::~BaseRuntime()
|
PluginRuntime::~PluginRuntime()
|
||||||
{
|
{
|
||||||
// The watchdog thread takes the global JIT lock while it patches all
|
// The watchdog thread takes the global JIT lock while it patches all
|
||||||
// runtimes. It is not enough to ensure that the unlinking of the runtime is
|
// runtimes. It is not enough to ensure that the unlinking of the runtime is
|
||||||
@ -104,7 +115,7 @@ static const NativeMapping sNativeMap[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
BaseRuntime::SetupFloatNativeRemapping()
|
PluginRuntime::SetupFloatNativeRemapping()
|
||||||
{
|
{
|
||||||
float_table_ = new floattbl_t[m_plugin.num_natives];
|
float_table_ = new floattbl_t[m_plugin.num_natives];
|
||||||
for (size_t i = 0; i < m_plugin.num_natives; i++) {
|
for (size_t i = 0; i < m_plugin.num_natives; i++) {
|
||||||
@ -122,7 +133,7 @@ BaseRuntime::SetupFloatNativeRemapping()
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
BaseRuntime::GetNativeReplacement(size_t index)
|
PluginRuntime::GetNativeReplacement(size_t index)
|
||||||
{
|
{
|
||||||
if (!float_table_[index].found)
|
if (!float_table_[index].found)
|
||||||
return OP_NOP;
|
return OP_NOP;
|
||||||
@ -130,7 +141,7 @@ BaseRuntime::GetNativeReplacement(size_t index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BaseRuntime::SetName(const char *name)
|
PluginRuntime::SetName(const char *name)
|
||||||
{
|
{
|
||||||
m_plugin.name = strdup(name);
|
m_plugin.name = strdup(name);
|
||||||
}
|
}
|
||||||
@ -140,7 +151,7 @@ static cell_t InvalidNative(IPluginContext *pCtx, const cell_t *params)
|
|||||||
return pCtx->ThrowNativeErrorEx(SP_ERROR_INVALID_NATIVE, "Invalid native");
|
return pCtx->ThrowNativeErrorEx(SP_ERROR_INVALID_NATIVE, "Invalid native");
|
||||||
}
|
}
|
||||||
|
|
||||||
int BaseRuntime::CreateFromMemory(sp_file_hdr_t *hdr, uint8_t *base)
|
int PluginRuntime::CreateFromMemory(sp_file_hdr_t *hdr, uint8_t *base)
|
||||||
{
|
{
|
||||||
char *nameptr;
|
char *nameptr;
|
||||||
uint8_t sectnum = 0;
|
uint8_t sectnum = 0;
|
||||||
@ -305,7 +316,7 @@ int BaseRuntime::CreateFromMemory(sp_file_hdr_t *hdr, uint8_t *base)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BaseRuntime::AddJittedFunction(CompiledFunction *fn)
|
PluginRuntime::AddJittedFunction(CompiledFunction *fn)
|
||||||
{
|
{
|
||||||
m_JitFunctions.append(fn);
|
m_JitFunctions.append(fn);
|
||||||
|
|
||||||
@ -319,7 +330,7 @@ BaseRuntime::AddJittedFunction(CompiledFunction *fn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CompiledFunction *
|
CompiledFunction *
|
||||||
BaseRuntime::GetJittedFunctionByOffset(cell_t pcode_offset)
|
PluginRuntime::GetJittedFunctionByOffset(cell_t pcode_offset)
|
||||||
{
|
{
|
||||||
assert(pcode_offset % 4 == 0);
|
assert(pcode_offset % 4 == 0);
|
||||||
|
|
||||||
@ -330,7 +341,7 @@ BaseRuntime::GetJittedFunctionByOffset(cell_t pcode_offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
BaseRuntime::FindNativeByName(const char *name, uint32_t *index)
|
PluginRuntime::FindNativeByName(const char *name, uint32_t *index)
|
||||||
{
|
{
|
||||||
for (uint32_t i=0; i<m_plugin.num_natives; i++) {
|
for (uint32_t i=0; i<m_plugin.num_natives; i++) {
|
||||||
if (strcmp(m_plugin.natives[i].name, name) == 0) {
|
if (strcmp(m_plugin.natives[i].name, name) == 0) {
|
||||||
@ -344,7 +355,7 @@ BaseRuntime::FindNativeByName(const char *name, uint32_t *index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
BaseRuntime::GetNativeByIndex(uint32_t index, sp_native_t **native)
|
PluginRuntime::GetNativeByIndex(uint32_t index, sp_native_t **native)
|
||||||
{
|
{
|
||||||
if (index >= m_plugin.num_natives)
|
if (index >= m_plugin.num_natives)
|
||||||
return SP_ERROR_INDEX;
|
return SP_ERROR_INDEX;
|
||||||
@ -356,20 +367,20 @@ BaseRuntime::GetNativeByIndex(uint32_t index, sp_native_t **native)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sp_native_t *
|
sp_native_t *
|
||||||
BaseRuntime::GetNativeByIndex(uint32_t index)
|
PluginRuntime::GetNativeByIndex(uint32_t index)
|
||||||
{
|
{
|
||||||
assert(index < m_plugin.num_natives);
|
assert(index < m_plugin.num_natives);
|
||||||
return &m_plugin.natives[index];
|
return &m_plugin.natives[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
BaseRuntime::GetNativesNum()
|
PluginRuntime::GetNativesNum()
|
||||||
{
|
{
|
||||||
return m_plugin.num_natives;
|
return m_plugin.num_natives;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
BaseRuntime::FindPublicByName(const char *name, uint32_t *index)
|
PluginRuntime::FindPublicByName(const char *name, uint32_t *index)
|
||||||
{
|
{
|
||||||
int diff, high, low;
|
int diff, high, low;
|
||||||
uint32_t mid;
|
uint32_t mid;
|
||||||
@ -395,7 +406,7 @@ BaseRuntime::FindPublicByName(const char *name, uint32_t *index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
BaseRuntime::GetPublicByIndex(uint32_t index, sp_public_t **pblic)
|
PluginRuntime::GetPublicByIndex(uint32_t index, sp_public_t **pblic)
|
||||||
{
|
{
|
||||||
if (index >= m_plugin.num_publics)
|
if (index >= m_plugin.num_publics)
|
||||||
return SP_ERROR_INDEX;
|
return SP_ERROR_INDEX;
|
||||||
@ -407,13 +418,13 @@ BaseRuntime::GetPublicByIndex(uint32_t index, sp_public_t **pblic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
BaseRuntime::GetPublicsNum()
|
PluginRuntime::GetPublicsNum()
|
||||||
{
|
{
|
||||||
return m_plugin.num_publics;
|
return m_plugin.num_publics;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
BaseRuntime::GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar)
|
PluginRuntime::GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar)
|
||||||
{
|
{
|
||||||
if (index >= m_plugin.num_pubvars)
|
if (index >= m_plugin.num_pubvars)
|
||||||
return SP_ERROR_INDEX;
|
return SP_ERROR_INDEX;
|
||||||
@ -425,7 +436,7 @@ BaseRuntime::GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
BaseRuntime::FindPubvarByName(const char *name, uint32_t *index)
|
PluginRuntime::FindPubvarByName(const char *name, uint32_t *index)
|
||||||
{
|
{
|
||||||
int diff, high, low;
|
int diff, high, low;
|
||||||
uint32_t mid;
|
uint32_t mid;
|
||||||
@ -451,7 +462,7 @@ BaseRuntime::FindPubvarByName(const char *name, uint32_t *index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
BaseRuntime::GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr)
|
PluginRuntime::GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr)
|
||||||
{
|
{
|
||||||
if (index >= m_plugin.num_pubvars)
|
if (index >= m_plugin.num_pubvars)
|
||||||
return SP_ERROR_INDEX;
|
return SP_ERROR_INDEX;
|
||||||
@ -463,25 +474,25 @@ BaseRuntime::GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_ad
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
BaseRuntime::GetPubVarsNum()
|
PluginRuntime::GetPubVarsNum()
|
||||||
{
|
{
|
||||||
return m_plugin.num_pubvars;
|
return m_plugin.num_pubvars;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPluginContext *
|
IPluginContext *
|
||||||
BaseRuntime::GetDefaultContext()
|
PluginRuntime::GetDefaultContext()
|
||||||
{
|
{
|
||||||
return m_pCtx;
|
return m_pCtx;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPluginDebugInfo *
|
IPluginDebugInfo *
|
||||||
BaseRuntime::GetDebugInfo()
|
PluginRuntime::GetDebugInfo()
|
||||||
{
|
{
|
||||||
return &m_Debug;
|
return &m_Debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPluginFunction *
|
IPluginFunction *
|
||||||
BaseRuntime::GetFunctionById(funcid_t func_id)
|
PluginRuntime::GetFunctionById(funcid_t func_id)
|
||||||
{
|
{
|
||||||
ScriptedInvoker *pFunc = NULL;
|
ScriptedInvoker *pFunc = NULL;
|
||||||
|
|
||||||
@ -500,7 +511,7 @@ BaseRuntime::GetFunctionById(funcid_t func_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ScriptedInvoker *
|
ScriptedInvoker *
|
||||||
BaseRuntime::GetPublicFunction(size_t index)
|
PluginRuntime::GetPublicFunction(size_t index)
|
||||||
{
|
{
|
||||||
ScriptedInvoker *pFunc = m_PubFuncs[index];
|
ScriptedInvoker *pFunc = m_PubFuncs[index];
|
||||||
if (!pFunc) {
|
if (!pFunc) {
|
||||||
@ -515,7 +526,7 @@ BaseRuntime::GetPublicFunction(size_t index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
IPluginFunction *
|
IPluginFunction *
|
||||||
BaseRuntime::GetFunctionByName(const char *public_name)
|
PluginRuntime::GetFunctionByName(const char *public_name)
|
||||||
{
|
{
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
|
|
||||||
@ -525,12 +536,12 @@ BaseRuntime::GetFunctionByName(const char *public_name)
|
|||||||
return GetPublicFunction(index);
|
return GetPublicFunction(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseRuntime::IsDebugging()
|
bool PluginRuntime::IsDebugging()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseRuntime::SetPauseState(bool paused)
|
void PluginRuntime::SetPauseState(bool paused)
|
||||||
{
|
{
|
||||||
if (paused)
|
if (paused)
|
||||||
{
|
{
|
||||||
@ -542,12 +553,12 @@ void BaseRuntime::SetPauseState(bool paused)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseRuntime::IsPaused()
|
bool PluginRuntime::IsPaused()
|
||||||
{
|
{
|
||||||
return ((m_plugin.run_flags & SPFLAG_PLUGIN_PAUSED) == SPFLAG_PLUGIN_PAUSED);
|
return ((m_plugin.run_flags & SPFLAG_PLUGIN_PAUSED) == SPFLAG_PLUGIN_PAUSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BaseRuntime::GetMemUsage()
|
size_t PluginRuntime::GetMemUsage()
|
||||||
{
|
{
|
||||||
size_t mem = 0;
|
size_t mem = 0;
|
||||||
|
|
||||||
@ -559,23 +570,23 @@ size_t BaseRuntime::GetMemUsage()
|
|||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *BaseRuntime::GetCodeHash()
|
unsigned char *PluginRuntime::GetCodeHash()
|
||||||
{
|
{
|
||||||
return m_CodeHash;
|
return m_CodeHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *BaseRuntime::GetDataHash()
|
unsigned char *PluginRuntime::GetDataHash()
|
||||||
{
|
{
|
||||||
return m_DataHash;
|
return m_DataHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseContext *BaseRuntime::GetBaseContext()
|
BaseContext *PluginRuntime::GetBaseContext()
|
||||||
{
|
{
|
||||||
return m_pCtx;
|
return m_pCtx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
BaseRuntime::ApplyCompilationOptions(ICompilation *co)
|
PluginRuntime::ApplyCompilationOptions(ICompilation *co)
|
||||||
{
|
{
|
||||||
if (co == NULL)
|
if (co == NULL)
|
||||||
return SP_ERROR_NONE;
|
return SP_ERROR_NONE;
|
||||||
@ -587,7 +598,7 @@ BaseRuntime::ApplyCompilationOptions(ICompilation *co)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
BaseRuntime::CreateBlank(uint32_t heastk)
|
PluginRuntime::CreateBlank(uint32_t heastk)
|
||||||
{
|
{
|
||||||
memset(&m_plugin, 0, sizeof(m_plugin));
|
memset(&m_plugin, 0, sizeof(m_plugin));
|
||||||
|
|
||||||
|
@ -1,4 +1,15 @@
|
|||||||
// vim: set ts=8 sw=2 sts=2 tw=99 et:
|
// vim: set sts=2 ts=8 sw=2 tw=99 et:
|
||||||
|
//
|
||||||
|
// Copyright (C) 2006-2015 AlliedModders LLC
|
||||||
|
//
|
||||||
|
// This file is part of SourcePawn. SourcePawn is free software: you can
|
||||||
|
// redistribute it and/or modify it under the terms of the GNU General Public
|
||||||
|
// License as published by the Free Software Foundation, either version 3 of
|
||||||
|
// the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along with
|
||||||
|
// SourcePawn. If not, see http://www.gnu.org/licenses/.
|
||||||
|
//
|
||||||
#ifndef _INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_
|
#ifndef _INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_
|
||||||
#define _INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_
|
#define _INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_
|
||||||
|
|
||||||
@ -34,13 +45,13 @@ struct floattbl_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Jit wants fast access to this so we expose things as public */
|
/* Jit wants fast access to this so we expose things as public */
|
||||||
class BaseRuntime
|
class PluginRuntime
|
||||||
: public SourcePawn::IPluginRuntime,
|
: public SourcePawn::IPluginRuntime,
|
||||||
public ke::InlineListNode<BaseRuntime>
|
public ke::InlineListNode<PluginRuntime>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BaseRuntime();
|
PluginRuntime();
|
||||||
~BaseRuntime();
|
~PluginRuntime();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual int CreateBlank(uint32_t heastk);
|
virtual int CreateBlank(uint32_t heastk);
|
||||||
|
@ -37,7 +37,7 @@ SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file, int *err)
|
|||||||
int z_result;
|
int z_result;
|
||||||
int error;
|
int error;
|
||||||
size_t ignore;
|
size_t ignore;
|
||||||
BaseRuntime *pRuntime;
|
PluginRuntime *pRuntime;
|
||||||
|
|
||||||
FILE *fp = fopen(file, "rb");
|
FILE *fp = fopen(file, "rb");
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file, int *err)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pRuntime = new BaseRuntime();
|
pRuntime = new PluginRuntime();
|
||||||
if ((error = pRuntime->CreateFromMemory(&hdr, base)) != SP_ERROR_NONE) {
|
if ((error = pRuntime->CreateFromMemory(&hdr, base)) != SP_ERROR_NONE) {
|
||||||
delete pRuntime;
|
delete pRuntime;
|
||||||
goto return_error;
|
goto return_error;
|
||||||
@ -211,7 +211,7 @@ SourcePawnEngine2::CreateEmptyRuntime(const char *name, uint32_t memory)
|
|||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
BaseRuntime *rt = new BaseRuntime();
|
PluginRuntime *rt = new PluginRuntime();
|
||||||
if ((err = rt->CreateBlank(memory)) != SP_ERROR_NONE) {
|
if ((err = rt->CreateBlank(memory)) != SP_ERROR_NONE) {
|
||||||
delete rt;
|
delete rt;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -95,7 +95,7 @@ CheckAddress(const sp_plugin_t *plugin, sp_context_t *ctx, cell_t *stk, cell_t a
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PopTrackerAndSetHeap(BaseRuntime *rt)
|
PopTrackerAndSetHeap(PluginRuntime *rt)
|
||||||
{
|
{
|
||||||
sp_context_t *ctx = rt->GetBaseContext()->GetCtx();
|
sp_context_t *ctx = rt->GetBaseContext()->GetCtx();
|
||||||
tracker_t *trk = ctx->tracker;
|
tracker_t *trk = ctx->tracker;
|
||||||
@ -192,7 +192,7 @@ BoundNativeCallback(sp_context_t *ctx, SPVM_NATIVE_FUNC pfn, cell_t *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
GenerateArray(BaseRuntime *rt, sp_context_t *ctx, cell_t dims, cell_t *stk, bool autozero)
|
GenerateArray(PluginRuntime *rt, sp_context_t *ctx, cell_t dims, cell_t *stk, bool autozero)
|
||||||
{
|
{
|
||||||
if (dims == 1) {
|
if (dims == 1) {
|
||||||
uint32_t size = *stk;
|
uint32_t size = *stk;
|
||||||
@ -226,7 +226,7 @@ GenerateArray(BaseRuntime *rt, sp_context_t *ctx, cell_t dims, cell_t *stk, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Interpret(BaseRuntime *rt, uint32_t aCodeStart, cell_t *rval)
|
Interpret(PluginRuntime *rt, uint32_t aCodeStart, cell_t *rval)
|
||||||
{
|
{
|
||||||
const sp_plugin_t *plugin = rt->plugin();
|
const sp_plugin_t *plugin = rt->plugin();
|
||||||
cell_t *code = reinterpret_cast<cell_t *>(plugin->pcode);
|
cell_t *code = reinterpret_cast<cell_t *>(plugin->pcode);
|
||||||
|
@ -29,12 +29,12 @@ struct tracker_t
|
|||||||
ucell_t *pCur;
|
ucell_t *pCur;
|
||||||
};
|
};
|
||||||
|
|
||||||
int Interpret(BaseRuntime *rt, uint32_t aCodeStart, cell_t *rval);
|
int Interpret(PluginRuntime *rt, uint32_t aCodeStart, cell_t *rval);
|
||||||
|
|
||||||
int GenerateFullArray(BaseRuntime *rt, uint32_t argc, cell_t *argv, int autozero);
|
int GenerateFullArray(PluginRuntime *rt, uint32_t argc, cell_t *argv, int autozero);
|
||||||
cell_t NativeCallback(sp_context_t *ctx, ucell_t native_idx, cell_t *params);
|
cell_t NativeCallback(sp_context_t *ctx, ucell_t native_idx, cell_t *params);
|
||||||
cell_t BoundNativeCallback(sp_context_t *ctx, SPVM_NATIVE_FUNC pfn, cell_t *params);
|
cell_t BoundNativeCallback(sp_context_t *ctx, SPVM_NATIVE_FUNC pfn, cell_t *params);
|
||||||
int PopTrackerAndSetHeap(BaseRuntime *rt);
|
int PopTrackerAndSetHeap(PluginRuntime *rt);
|
||||||
int PushTracker(sp_context_t *ctx, size_t amount);
|
int PushTracker(sp_context_t *ctx, size_t amount);
|
||||||
|
|
||||||
#endif // _include_sourcepawn_interpreter_h_
|
#endif // _include_sourcepawn_interpreter_h_
|
||||||
|
@ -49,7 +49,7 @@ ScriptedInvoker::GetParentContext()
|
|||||||
return m_pRuntime->GetDefaultContext();
|
return m_pRuntime->GetDefaultContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptedInvoker::ScriptedInvoker(BaseRuntime *runtime, funcid_t id, uint32_t pub_id)
|
ScriptedInvoker::ScriptedInvoker(PluginRuntime *runtime, funcid_t id, uint32_t pub_id)
|
||||||
: m_curparam(0),
|
: m_curparam(0),
|
||||||
m_errorstate(SP_ERROR_NONE),
|
m_errorstate(SP_ERROR_NONE),
|
||||||
m_FnId(id)
|
m_FnId(id)
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include <sp_vm_api.h>
|
#include <sp_vm_api.h>
|
||||||
|
|
||||||
class BaseRuntime;
|
class PluginRuntime;
|
||||||
|
|
||||||
using namespace SourcePawn;
|
using namespace SourcePawn;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ class ScriptedInvoker : public IPluginFunction
|
|||||||
friend class SourcePawnEngine;
|
friend class SourcePawnEngine;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScriptedInvoker(BaseRuntime *pRuntime, funcid_t fnid, uint32_t pub_id);
|
ScriptedInvoker(PluginRuntime *pRuntime, funcid_t fnid, uint32_t pub_id);
|
||||||
~ScriptedInvoker();
|
~ScriptedInvoker();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -77,7 +77,7 @@ class ScriptedInvoker : public IPluginFunction
|
|||||||
int SetError(int err);
|
int SetError(int err);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BaseRuntime *m_pRuntime;
|
PluginRuntime *m_pRuntime;
|
||||||
cell_t m_params[SP_MAX_EXEC_PARAMS];
|
cell_t m_params[SP_MAX_EXEC_PARAMS];
|
||||||
ParamInfo m_info[SP_MAX_EXEC_PARAMS];
|
ParamInfo m_info[SP_MAX_EXEC_PARAMS];
|
||||||
unsigned int m_curparam;
|
unsigned int m_curparam;
|
||||||
|
@ -27,7 +27,7 @@ using namespace SourcePawn;
|
|||||||
#define CELLBOUNDMAX (INT_MAX/sizeof(cell_t))
|
#define CELLBOUNDMAX (INT_MAX/sizeof(cell_t))
|
||||||
#define STACKMARGIN ((cell_t)(16*sizeof(cell_t)))
|
#define STACKMARGIN ((cell_t)(16*sizeof(cell_t)))
|
||||||
|
|
||||||
BaseContext::BaseContext(BaseRuntime *pRuntime)
|
BaseContext::BaseContext(PluginRuntime *pRuntime)
|
||||||
{
|
{
|
||||||
m_pRuntime = pRuntime;
|
m_pRuntime = pRuntime;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
class BaseContext : public IPluginContext
|
class BaseContext : public IPluginContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BaseContext(BaseRuntime *pRuntime);
|
BaseContext(PluginRuntime *pRuntime);
|
||||||
~BaseContext();
|
~BaseContext();
|
||||||
|
|
||||||
public: //IPluginContext
|
public: //IPluginContext
|
||||||
@ -90,7 +90,7 @@ class BaseContext : public IPluginContext
|
|||||||
char m_MsgCache[1024];
|
char m_MsgCache[1024];
|
||||||
bool m_CustomMsg;
|
bool m_CustomMsg;
|
||||||
bool m_InExec;
|
bool m_InExec;
|
||||||
BaseRuntime *m_pRuntime;
|
PluginRuntime *m_pRuntime;
|
||||||
sp_context_t m_ctx;
|
sp_context_t m_ctx;
|
||||||
void *m_keys[4];
|
void *m_keys[4];
|
||||||
bool m_keys_set[4];
|
bool m_keys_set[4];
|
||||||
|
@ -210,7 +210,7 @@ SourcePawnEngine::GetContextCallCount()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SourcePawnEngine::ReportError(BaseRuntime *runtime, int err, const char *errstr, cell_t rp_start)
|
SourcePawnEngine::ReportError(PluginRuntime *runtime, int err, const char *errstr, cell_t rp_start)
|
||||||
{
|
{
|
||||||
if (m_pDebugHook == NULL)
|
if (m_pDebugHook == NULL)
|
||||||
return;
|
return;
|
||||||
@ -220,7 +220,7 @@ SourcePawnEngine::ReportError(BaseRuntime *runtime, int err, const char *errstr,
|
|||||||
m_pDebugHook->OnContextExecuteError(runtime->GetDefaultContext(), &trace);
|
m_pDebugHook->OnContextExecuteError(runtime->GetDefaultContext(), &trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
CContextTrace::CContextTrace(BaseRuntime *pRuntime, int err, const char *errstr, cell_t start_rp)
|
CContextTrace::CContextTrace(PluginRuntime *pRuntime, int err, const char *errstr, cell_t start_rp)
|
||||||
: m_pRuntime(pRuntime),
|
: m_pRuntime(pRuntime),
|
||||||
m_Error(err),
|
m_Error(err),
|
||||||
m_pMsg(errstr),
|
m_pMsg(errstr),
|
||||||
|
@ -21,7 +21,7 @@ class BaseContext;
|
|||||||
class CContextTrace : public IContextTrace
|
class CContextTrace : public IContextTrace
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CContextTrace(BaseRuntime *pRuntime, int err, const char *errstr, cell_t start_rp);
|
CContextTrace(PluginRuntime *pRuntime, int err, const char *errstr, cell_t start_rp);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int GetErrorCode();
|
int GetErrorCode();
|
||||||
@ -33,7 +33,7 @@ class CContextTrace : public IContextTrace
|
|||||||
const char *GetLastNative(uint32_t *index);
|
const char *GetLastNative(uint32_t *index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BaseRuntime *m_pRuntime;
|
PluginRuntime *m_pRuntime;
|
||||||
sp_context_t *m_ctx;
|
sp_context_t *m_ctx;
|
||||||
int m_Error;
|
int m_Error;
|
||||||
const char *m_pMsg;
|
const char *m_pMsg;
|
||||||
@ -65,7 +65,7 @@ class SourcePawnEngine : public ISourcePawnEngine
|
|||||||
void SetReadWriteExecute(void *ptr);
|
void SetReadWriteExecute(void *ptr);
|
||||||
void FreePageMemory(void *ptr);
|
void FreePageMemory(void *ptr);
|
||||||
const char *GetErrorString(int err);
|
const char *GetErrorString(int err);
|
||||||
void ReportError(BaseRuntime *runtime, int err, const char *errstr, cell_t rp_start);
|
void ReportError(PluginRuntime *runtime, int err, const char *errstr, cell_t rp_start);
|
||||||
|
|
||||||
public: //Plugin function stuff
|
public: //Plugin function stuff
|
||||||
IDebugListener *GetDebugHook();
|
IDebugListener *GetDebugHook();
|
||||||
|
@ -169,7 +169,7 @@ GenerateArrayIndirectionVectors(cell_t *arraybase, cell_t dims[], cell_t _dimcou
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
GenerateFullArray(BaseRuntime *rt, uint32_t argc, cell_t *argv, int autozero)
|
GenerateFullArray(PluginRuntime *rt, uint32_t argc, cell_t *argv, int autozero)
|
||||||
{
|
{
|
||||||
sp_context_t *ctx = rt->GetBaseContext()->GetCtx();
|
sp_context_t *ctx = rt->GetBaseContext()->GetCtx();
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ GetFunctionName(const sp_plugin_t *plugin, uint32_t offs)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
CompileFromThunk(BaseRuntime *runtime, cell_t pcode_offs, void **addrp, char *pc)
|
CompileFromThunk(PluginRuntime *runtime, cell_t pcode_offs, void **addrp, char *pc)
|
||||||
{
|
{
|
||||||
// If the watchdog timer has declared a timeout, we must process it now,
|
// If the watchdog timer has declared a timeout, we must process it now,
|
||||||
// and possibly refuse to compile, since otherwise we will compile a
|
// and possibly refuse to compile, since otherwise we will compile a
|
||||||
@ -302,7 +302,7 @@ CompileFromThunk(BaseRuntime *runtime, cell_t pcode_offs, void **addrp, char *pc
|
|||||||
return SP_ERROR_NONE;
|
return SP_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Compiler::Compiler(BaseRuntime *rt, cell_t pcode_offs)
|
Compiler::Compiler(PluginRuntime *rt, cell_t pcode_offs)
|
||||||
: rt_(rt),
|
: rt_(rt),
|
||||||
plugin_(rt->plugin()),
|
plugin_(rt->plugin()),
|
||||||
error_(SP_ERROR_NONE),
|
error_(SP_ERROR_NONE),
|
||||||
@ -1927,7 +1927,7 @@ JITX86::ShutdownJIT()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CompiledFunction *
|
CompiledFunction *
|
||||||
JITX86::CompileFunction(BaseRuntime *prt, cell_t pcode_offs, int *err)
|
JITX86::CompileFunction(PluginRuntime *prt, cell_t pcode_offs, int *err)
|
||||||
{
|
{
|
||||||
Compiler cc(prt, pcode_offs);
|
Compiler cc(prt, pcode_offs);
|
||||||
CompiledFunction *fun = cc.emit(err);
|
CompiledFunction *fun = cc.emit(err);
|
||||||
@ -1943,7 +1943,7 @@ JITX86::CompileFunction(BaseRuntime *prt, cell_t pcode_offs, int *err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
JITX86::SetupContextVars(BaseRuntime *runtime, BaseContext *pCtx, sp_context_t *ctx)
|
JITX86::SetupContextVars(PluginRuntime *runtime, BaseContext *pCtx, sp_context_t *ctx)
|
||||||
{
|
{
|
||||||
ctx->tracker = new tracker_t;
|
ctx->tracker = new tracker_t;
|
||||||
ctx->tracker->pBase = (ucell_t *)malloc(1024);
|
ctx->tracker->pBase = (ucell_t *)malloc(1024);
|
||||||
@ -1993,7 +1993,7 @@ JITX86::StartCompilation()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ICompilation *
|
ICompilation *
|
||||||
JITX86::StartCompilation(BaseRuntime *runtime)
|
JITX86::StartCompilation(PluginRuntime *runtime)
|
||||||
{
|
{
|
||||||
return new CompData;
|
return new CompData;
|
||||||
}
|
}
|
||||||
@ -2030,7 +2030,7 @@ CompData::SetOption(const char *key, const char *val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
JITX86::InvokeFunction(BaseRuntime *runtime, CompiledFunction *fn, cell_t *result)
|
JITX86::InvokeFunction(PluginRuntime *runtime, CompiledFunction *fn, cell_t *result)
|
||||||
{
|
{
|
||||||
sp_context_t *ctx = runtime->GetBaseContext()->GetCtx();
|
sp_context_t *ctx = runtime->GetBaseContext()->GetCtx();
|
||||||
|
|
||||||
@ -2061,14 +2061,14 @@ JITX86::FreeCode(void *code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
JITX86::RegisterRuntime(BaseRuntime *rt)
|
JITX86::RegisterRuntime(PluginRuntime *rt)
|
||||||
{
|
{
|
||||||
mutex_.AssertCurrentThreadOwns();
|
mutex_.AssertCurrentThreadOwns();
|
||||||
runtimes_.append(rt);
|
runtimes_.append(rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
JITX86::DeregisterRuntime(BaseRuntime *rt)
|
JITX86::DeregisterRuntime(PluginRuntime *rt)
|
||||||
{
|
{
|
||||||
mutex_.AssertCurrentThreadOwns();
|
mutex_.AssertCurrentThreadOwns();
|
||||||
runtimes_.remove(rt);
|
runtimes_.remove(rt);
|
||||||
@ -2078,8 +2078,8 @@ void
|
|||||||
JITX86::PatchAllJumpsForTimeout()
|
JITX86::PatchAllJumpsForTimeout()
|
||||||
{
|
{
|
||||||
mutex_.AssertCurrentThreadOwns();
|
mutex_.AssertCurrentThreadOwns();
|
||||||
for (ke::InlineList<BaseRuntime>::iterator iter = runtimes_.begin(); iter != runtimes_.end(); iter++) {
|
for (ke::InlineList<PluginRuntime>::iterator iter = runtimes_.begin(); iter != runtimes_.end(); iter++) {
|
||||||
BaseRuntime *rt = *iter;
|
PluginRuntime *rt = *iter;
|
||||||
for (size_t i = 0; i < rt->NumJitFunctions(); i++) {
|
for (size_t i = 0; i < rt->NumJitFunctions(); i++) {
|
||||||
CompiledFunction *fun = rt->GetJitFunction(i);
|
CompiledFunction *fun = rt->GetJitFunction(i);
|
||||||
uint8_t *base = reinterpret_cast<uint8_t *>(fun->GetEntryAddress());
|
uint8_t *base = reinterpret_cast<uint8_t *>(fun->GetEntryAddress());
|
||||||
@ -2097,8 +2097,8 @@ void
|
|||||||
JITX86::UnpatchAllJumpsFromTimeout()
|
JITX86::UnpatchAllJumpsFromTimeout()
|
||||||
{
|
{
|
||||||
mutex_.AssertCurrentThreadOwns();
|
mutex_.AssertCurrentThreadOwns();
|
||||||
for (ke::InlineList<BaseRuntime>::iterator iter = runtimes_.begin(); iter != runtimes_.end(); iter++) {
|
for (ke::InlineList<PluginRuntime>::iterator iter = runtimes_.begin(); iter != runtimes_.end(); iter++) {
|
||||||
BaseRuntime *rt = *iter;
|
PluginRuntime *rt = *iter;
|
||||||
for (size_t i = 0; i < rt->NumJitFunctions(); i++) {
|
for (size_t i = 0; i < rt->NumJitFunctions(); i++) {
|
||||||
CompiledFunction *fun = rt->GetJitFunction(i);
|
CompiledFunction *fun = rt->GetJitFunction(i);
|
||||||
uint8_t *base = reinterpret_cast<uint8_t *>(fun->GetEntryAddress());
|
uint8_t *base = reinterpret_cast<uint8_t *>(fun->GetEntryAddress());
|
||||||
|
@ -85,7 +85,7 @@ public:
|
|||||||
class Compiler
|
class Compiler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Compiler(BaseRuntime *rt, cell_t pcode_offs);
|
Compiler(PluginRuntime *rt, cell_t pcode_offs);
|
||||||
~Compiler();
|
~Compiler();
|
||||||
|
|
||||||
CompiledFunction *emit(int *errp);
|
CompiledFunction *emit(int *errp);
|
||||||
@ -122,7 +122,7 @@ class Compiler
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
AssemblerX86 masm;
|
AssemblerX86 masm;
|
||||||
BaseRuntime *rt_;
|
PluginRuntime *rt_;
|
||||||
const sp_plugin_t *plugin_;
|
const sp_plugin_t *plugin_;
|
||||||
int error_;
|
int error_;
|
||||||
uint32_t pcode_start_;
|
uint32_t pcode_start_;
|
||||||
@ -154,18 +154,18 @@ class JITX86
|
|||||||
public:
|
public:
|
||||||
bool InitializeJIT();
|
bool InitializeJIT();
|
||||||
void ShutdownJIT();
|
void ShutdownJIT();
|
||||||
ICompilation *StartCompilation(BaseRuntime *runtime);
|
ICompilation *StartCompilation(PluginRuntime *runtime);
|
||||||
ICompilation *StartCompilation();
|
ICompilation *StartCompilation();
|
||||||
void SetupContextVars(BaseRuntime *runtime, BaseContext *pCtx, sp_context_t *ctx);
|
void SetupContextVars(PluginRuntime *runtime, BaseContext *pCtx, sp_context_t *ctx);
|
||||||
void FreeContextVars(sp_context_t *ctx);
|
void FreeContextVars(sp_context_t *ctx);
|
||||||
SPVM_NATIVE_FUNC CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData);
|
SPVM_NATIVE_FUNC CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData);
|
||||||
void DestroyFakeNative(SPVM_NATIVE_FUNC func);
|
void DestroyFakeNative(SPVM_NATIVE_FUNC func);
|
||||||
CompiledFunction *CompileFunction(BaseRuntime *runtime, cell_t pcode_offs, int *err);
|
CompiledFunction *CompileFunction(PluginRuntime *runtime, cell_t pcode_offs, int *err);
|
||||||
ICompilation *ApplyOptions(ICompilation *_IN, ICompilation *_OUT);
|
ICompilation *ApplyOptions(ICompilation *_IN, ICompilation *_OUT);
|
||||||
int InvokeFunction(BaseRuntime *runtime, CompiledFunction *fn, cell_t *result);
|
int InvokeFunction(PluginRuntime *runtime, CompiledFunction *fn, cell_t *result);
|
||||||
|
|
||||||
void RegisterRuntime(BaseRuntime *rt);
|
void RegisterRuntime(PluginRuntime *rt);
|
||||||
void DeregisterRuntime(BaseRuntime *rt);
|
void DeregisterRuntime(PluginRuntime *rt);
|
||||||
void PatchAllJumpsForTimeout();
|
void PatchAllJumpsForTimeout();
|
||||||
void UnpatchAllJumpsFromTimeout();
|
void UnpatchAllJumpsFromTimeout();
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ class JITX86
|
|||||||
void *m_pJitEntry; /* Entry function */
|
void *m_pJitEntry; /* Entry function */
|
||||||
void *m_pJitReturn; /* Universal return address */
|
void *m_pJitReturn; /* Universal return address */
|
||||||
void *m_pJitTimeout; /* Universal timeout address */
|
void *m_pJitTimeout; /* Universal timeout address */
|
||||||
ke::InlineList<BaseRuntime> runtimes_;
|
ke::InlineList<PluginRuntime> runtimes_;
|
||||||
uintptr_t frame_id_;
|
uintptr_t frame_id_;
|
||||||
uintptr_t level_;
|
uintptr_t level_;
|
||||||
ke::Mutex mutex_;
|
ke::Mutex mutex_;
|
||||||
|
Loading…
Reference in New Issue
Block a user