Rename Function to CompiledFunction.

This commit is contained in:
dvander@alliedmods.net 2015-02-23 16:27:57 -08:00
parent 0ee4885056
commit b2d8dde3a5
7 changed files with 30 additions and 30 deletions

View File

@ -279,8 +279,8 @@ int BaseRuntime::CreateFromMemory(sp_file_hdr_t *hdr, uint8_t *base)
if (m_plugin.num_publics > 0) { if (m_plugin.num_publics > 0) {
m_PubFuncs = new ScriptedInvoker *[m_plugin.num_publics]; m_PubFuncs = new ScriptedInvoker *[m_plugin.num_publics];
memset(m_PubFuncs, 0, sizeof(ScriptedInvoker *) * m_plugin.num_publics); memset(m_PubFuncs, 0, sizeof(ScriptedInvoker *) * m_plugin.num_publics);
m_PubJitFuncs = new Function *[m_plugin.num_publics]; m_PubJitFuncs = new CompiledFunction *[m_plugin.num_publics];
memset(m_PubJitFuncs, 0, sizeof(Function *) * m_plugin.num_publics); memset(m_PubJitFuncs, 0, sizeof(CompiledFunction *) * m_plugin.num_publics);
} }
MD5 md5_pcode; MD5 md5_pcode;
@ -298,14 +298,14 @@ int BaseRuntime::CreateFromMemory(sp_file_hdr_t *hdr, uint8_t *base)
SetupFloatNativeRemapping(); SetupFloatNativeRemapping();
function_map_size_ = m_plugin.pcode_size / sizeof(cell_t) + 1; function_map_size_ = m_plugin.pcode_size / sizeof(cell_t) + 1;
function_map_ = new Function *[function_map_size_]; function_map_ = new CompiledFunction *[function_map_size_];
memset(function_map_, 0, function_map_size_ * sizeof(Function *)); memset(function_map_, 0, function_map_size_ * sizeof(CompiledFunction *));
return SP_ERROR_NONE; return SP_ERROR_NONE;
} }
void void
BaseRuntime::AddJittedFunction(Function *fn) BaseRuntime::AddJittedFunction(CompiledFunction *fn)
{ {
m_JitFunctions.append(fn); m_JitFunctions.append(fn);
@ -318,7 +318,7 @@ BaseRuntime::AddJittedFunction(Function *fn)
function_map_[pcode_index] = fn; function_map_[pcode_index] = fn;
} }
Function * CompiledFunction *
BaseRuntime::GetJittedFunctionByOffset(cell_t pcode_offset) BaseRuntime::GetJittedFunctionByOffset(cell_t pcode_offset)
{ {
assert(pcode_offset % 4 == 0); assert(pcode_offset % 4 == 0);

View File

@ -67,8 +67,8 @@ class BaseRuntime
virtual size_t GetMemUsage(); virtual size_t GetMemUsage();
virtual unsigned char *GetCodeHash(); virtual unsigned char *GetCodeHash();
virtual unsigned char *GetDataHash(); virtual unsigned char *GetDataHash();
Function *GetJittedFunctionByOffset(cell_t pcode_offset); CompiledFunction *GetJittedFunctionByOffset(cell_t pcode_offset);
void AddJittedFunction(Function *fn); void AddJittedFunction(CompiledFunction *fn);
void SetName(const char *name); void SetName(const char *name);
unsigned GetNativeReplacement(size_t index); unsigned GetNativeReplacement(size_t index);
ScriptedInvoker *GetPublicFunction(size_t index); ScriptedInvoker *GetPublicFunction(size_t index);
@ -81,7 +81,7 @@ class BaseRuntime
size_t NumJitFunctions() const { size_t NumJitFunctions() const {
return m_JitFunctions.length(); return m_JitFunctions.length();
} }
Function *GetJitFunction(size_t i) const { CompiledFunction *GetJitFunction(size_t i) const {
return m_JitFunctions[i]; return m_JitFunctions[i];
} }
@ -94,15 +94,15 @@ class BaseRuntime
unsigned int m_NumFuncs; unsigned int m_NumFuncs;
unsigned int m_MaxFuncs; unsigned int m_MaxFuncs;
floattbl_t *float_table_; floattbl_t *float_table_;
Function **function_map_; CompiledFunction **function_map_;
size_t function_map_size_; size_t function_map_size_;
ke::Vector<Function *> m_JitFunctions; ke::Vector<CompiledFunction *> m_JitFunctions;
public: public:
DebugInfo m_Debug; DebugInfo m_Debug;
BaseContext *m_pCtx; BaseContext *m_pCtx;
ScriptedInvoker **m_PubFuncs; ScriptedInvoker **m_PubFuncs;
Function **m_PubJitFuncs; CompiledFunction **m_PubJitFuncs;
private: private:
ICompilation *co_; ICompilation *co_;

View File

@ -14,14 +14,14 @@
#include "sp_vm_engine.h" #include "sp_vm_engine.h"
#include "jit_x86.h" #include "jit_x86.h"
Function::Function(void *entry_addr, cell_t pcode_offs, FixedArray<LoopEdge> *edges) CompiledFunction::CompiledFunction(void *entry_addr, cell_t pcode_offs, FixedArray<LoopEdge> *edges)
: entry_(entry_addr), : entry_(entry_addr),
code_offset_(pcode_offs), code_offset_(pcode_offs),
edges_(edges) edges_(edges)
{ {
} }
Function::~Function() CompiledFunction::~CompiledFunction()
{ {
g_Jit.FreeCode(entry_); g_Jit.FreeCode(entry_);
} }

View File

@ -27,11 +27,11 @@ struct LoopEdge
int32_t disp32; int32_t disp32;
}; };
class Function class CompiledFunction
{ {
public: public:
Function(void *entry_addr, cell_t pcode_offs, FixedArray<LoopEdge> *edges); CompiledFunction(void *entry_addr, cell_t pcode_offs, FixedArray<LoopEdge> *edges);
~Function(); ~CompiledFunction();
public: public:
void *GetEntryAddress() const { void *GetEntryAddress() const {

View File

@ -525,7 +525,7 @@ BaseContext::Execute2(IPluginFunction *function, const cell_t *params, unsigned
int ir; int ir;
int serial; int serial;
cell_t *sp; cell_t *sp;
Function *fn; CompiledFunction *fn;
cell_t _ignore_result; cell_t _ignore_result;
EnterProfileScope profileScope("SourcePawn", "EnterJIT"); EnterProfileScope profileScope("SourcePawn", "EnterJIT");

View File

@ -280,7 +280,7 @@ CompileFromThunk(BaseRuntime *runtime, cell_t pcode_offs, void **addrp, char *pc
if (!g_WatchdogTimer.HandleInterrupt()) if (!g_WatchdogTimer.HandleInterrupt())
return SP_ERROR_TIMEOUT; return SP_ERROR_TIMEOUT;
Function *fn = runtime->GetJittedFunctionByOffset(pcode_offs); CompiledFunction *fn = runtime->GetJittedFunctionByOffset(pcode_offs);
if (!fn) { if (!fn) {
int err; int err;
fn = g_Jit.CompileFunction(runtime, pcode_offs, &err); fn = g_Jit.CompileFunction(runtime, pcode_offs, &err);
@ -320,7 +320,7 @@ Compiler::~Compiler()
delete [] jump_map_; delete [] jump_map_;
} }
Function * CompiledFunction *
Compiler::emit(int *errp) Compiler::emit(int *errp)
{ {
if (cip_ >= code_end_ || *cip_ != OP_PROC) { if (cip_ >= code_end_ || *cip_ != OP_PROC) {
@ -382,7 +382,7 @@ Compiler::emit(int *errp)
edges->at(i).disp32 = *reinterpret_cast<int32_t *>(code + edges->at(i).offset - 4); edges->at(i).disp32 = *reinterpret_cast<int32_t *>(code + edges->at(i).offset - 4);
} }
return new Function(code, pcode_start_, edges.take()); return new CompiledFunction(code, pcode_start_, edges.take());
} }
bool bool
@ -1480,7 +1480,7 @@ Compiler::emitCall()
// Store the CIP of the function we're about to call. // Store the CIP of the function we're about to call.
__ movl(Operand(cipAddr()), offset); __ movl(Operand(cipAddr()), offset);
Function *fun = rt_->GetJittedFunctionByOffset(offset); CompiledFunction *fun = rt_->GetJittedFunctionByOffset(offset);
if (!fun) { if (!fun) {
// Need to emit a delayed thunk. // Need to emit a delayed thunk.
CallThunk *thunk = new CallThunk(offset); CallThunk *thunk = new CallThunk(offset);
@ -1926,11 +1926,11 @@ JITX86::ShutdownJIT()
KE_DestroyCodeCache(g_pCodeCache); KE_DestroyCodeCache(g_pCodeCache);
} }
Function * CompiledFunction *
JITX86::CompileFunction(BaseRuntime *prt, cell_t pcode_offs, int *err) JITX86::CompileFunction(BaseRuntime *prt, cell_t pcode_offs, int *err)
{ {
Compiler cc(prt, pcode_offs); Compiler cc(prt, pcode_offs);
Function *fun = cc.emit(err); CompiledFunction *fun = cc.emit(err);
if (!fun) if (!fun)
return NULL; return NULL;
@ -2030,7 +2030,7 @@ CompData::SetOption(const char *key, const char *val)
} }
int int
JITX86::InvokeFunction(BaseRuntime *runtime, Function *fn, cell_t *result) JITX86::InvokeFunction(BaseRuntime *runtime, CompiledFunction *fn, cell_t *result)
{ {
sp_context_t *ctx = runtime->GetBaseContext()->GetCtx(); sp_context_t *ctx = runtime->GetBaseContext()->GetCtx();
@ -2081,7 +2081,7 @@ JITX86::PatchAllJumpsForTimeout()
for (ke::InlineList<BaseRuntime>::iterator iter = runtimes_.begin(); iter != runtimes_.end(); iter++) { for (ke::InlineList<BaseRuntime>::iterator iter = runtimes_.begin(); iter != runtimes_.end(); iter++) {
BaseRuntime *rt = *iter; BaseRuntime *rt = *iter;
for (size_t i = 0; i < rt->NumJitFunctions(); i++) { for (size_t i = 0; i < rt->NumJitFunctions(); i++) {
Function *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());
for (size_t j = 0; j < fun->NumLoopEdges(); j++) { for (size_t j = 0; j < fun->NumLoopEdges(); j++) {
@ -2100,7 +2100,7 @@ JITX86::UnpatchAllJumpsFromTimeout()
for (ke::InlineList<BaseRuntime>::iterator iter = runtimes_.begin(); iter != runtimes_.end(); iter++) { for (ke::InlineList<BaseRuntime>::iterator iter = runtimes_.begin(); iter != runtimes_.end(); iter++) {
BaseRuntime *rt = *iter; BaseRuntime *rt = *iter;
for (size_t i = 0; i < rt->NumJitFunctions(); i++) { for (size_t i = 0; i < rt->NumJitFunctions(); i++) {
Function *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());
for (size_t j = 0; j < fun->NumLoopEdges(); j++) { for (size_t j = 0; j < fun->NumLoopEdges(); j++) {

View File

@ -88,7 +88,7 @@ class Compiler
Compiler(BaseRuntime *rt, cell_t pcode_offs); Compiler(BaseRuntime *rt, cell_t pcode_offs);
~Compiler(); ~Compiler();
Function *emit(int *errp); CompiledFunction *emit(int *errp);
private: private:
bool setup(cell_t pcode_offs); bool setup(cell_t pcode_offs);
@ -160,9 +160,9 @@ class JITX86
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);
Function *CompileFunction(BaseRuntime *runtime, cell_t pcode_offs, int *err); CompiledFunction *CompileFunction(BaseRuntime *runtime, cell_t pcode_offs, int *err);
ICompilation *ApplyOptions(ICompilation *_IN, ICompilation *_OUT); ICompilation *ApplyOptions(ICompilation *_IN, ICompilation *_OUT);
int InvokeFunction(BaseRuntime *runtime, Function *fn, cell_t *result); int InvokeFunction(BaseRuntime *runtime, CompiledFunction *fn, cell_t *result);
void RegisterRuntime(BaseRuntime *rt); void RegisterRuntime(BaseRuntime *rt);
void DeregisterRuntime(BaseRuntime *rt); void DeregisterRuntime(BaseRuntime *rt);