Rename JitFunction to CompiledFunction and CFunction to ScriptedInvoker.

This commit is contained in:
2015-02-23 16:03:08 -08:00
parent 7d64ade621
commit 892b8c05b1
11 changed files with 118 additions and 104 deletions
+14 -13
View File
@@ -280,7 +280,7 @@ CompileFromThunk(BaseRuntime *runtime, cell_t pcode_offs, void **addrp, char *pc
if (!g_WatchdogTimer.HandleInterrupt())
return SP_ERROR_TIMEOUT;
JitFunction *fn = runtime->GetJittedFunctionByOffset(pcode_offs);
Function *fn = runtime->GetJittedFunctionByOffset(pcode_offs);
if (!fn) {
int err;
fn = g_Jit.CompileFunction(runtime, pcode_offs, &err);
@@ -320,7 +320,7 @@ Compiler::~Compiler()
delete [] jump_map_;
}
JitFunction *
Function *
Compiler::emit(int *errp)
{
if (cip_ >= code_end_ || *cip_ != OP_PROC) {
@@ -375,13 +375,14 @@ Compiler::emit(int *errp)
return NULL;
}
LoopEdge *edges = new LoopEdge[backward_jumps_.length()];
AutoPtr<FixedArray<LoopEdge>> edges(
new FixedArray<LoopEdge>(backward_jumps_.length()));
for (size_t i = 0; i < backward_jumps_.length(); i++) {
edges[i].offset = backward_jumps_[i];
edges[i].disp32 = *reinterpret_cast<int32_t *>(code + edges[i].offset - 4);
edges->at(i).offset = backward_jumps_[i];
edges->at(i).disp32 = *reinterpret_cast<int32_t *>(code + edges->at(i).offset - 4);
}
return new JitFunction(code, pcode_start_, edges, backward_jumps_.length());
return new Function(code, pcode_start_, edges.take());
}
bool
@@ -1479,7 +1480,7 @@ Compiler::emitCall()
// Store the CIP of the function we're about to call.
__ movl(Operand(cipAddr()), offset);
JitFunction *fun = rt_->GetJittedFunctionByOffset(offset);
Function *fun = rt_->GetJittedFunctionByOffset(offset);
if (!fun) {
// Need to emit a delayed thunk.
CallThunk *thunk = new CallThunk(offset);
@@ -1925,11 +1926,11 @@ JITX86::ShutdownJIT()
KE_DestroyCodeCache(g_pCodeCache);
}
JitFunction *
Function *
JITX86::CompileFunction(BaseRuntime *prt, cell_t pcode_offs, int *err)
{
Compiler cc(prt, pcode_offs);
JitFunction *fun = cc.emit(err);
Function *fun = cc.emit(err);
if (!fun)
return NULL;
@@ -2029,12 +2030,12 @@ CompData::SetOption(const char *key, const char *val)
}
int
JITX86::InvokeFunction(BaseRuntime *runtime, JitFunction *fn, cell_t *result)
JITX86::InvokeFunction(BaseRuntime *runtime, Function *fn, cell_t *result)
{
sp_context_t *ctx = runtime->GetBaseContext()->GetCtx();
// Note that cip, hp, sp are saved and restored by Execute2().
ctx->cip = fn->GetPCodeAddress();
ctx->cip = fn->GetCodeOffset();
JIT_EXECUTE pfn = (JIT_EXECUTE)m_pJitEntry;
@@ -2080,7 +2081,7 @@ JITX86::PatchAllJumpsForTimeout()
for (ke::InlineList<BaseRuntime>::iterator iter = runtimes_.begin(); iter != runtimes_.end(); iter++) {
BaseRuntime *rt = *iter;
for (size_t i = 0; i < rt->NumJitFunctions(); i++) {
JitFunction *fun = rt->GetJitFunction(i);
Function *fun = rt->GetJitFunction(i);
uint8_t *base = reinterpret_cast<uint8_t *>(fun->GetEntryAddress());
for (size_t j = 0; j < fun->NumLoopEdges(); j++) {
@@ -2099,7 +2100,7 @@ JITX86::UnpatchAllJumpsFromTimeout()
for (ke::InlineList<BaseRuntime>::iterator iter = runtimes_.begin(); iter != runtimes_.end(); iter++) {
BaseRuntime *rt = *iter;
for (size_t i = 0; i < rt->NumJitFunctions(); i++) {
JitFunction *fun = rt->GetJitFunction(i);
Function *fun = rt->GetJitFunction(i);
uint8_t *base = reinterpret_cast<uint8_t *>(fun->GetEntryAddress());
for (size_t j = 0; j < fun->NumLoopEdges(); j++) {
+3 -3
View File
@@ -88,7 +88,7 @@ class Compiler
Compiler(BaseRuntime *rt, cell_t pcode_offs);
~Compiler();
JitFunction *emit(int *errp);
Function *emit(int *errp);
private:
bool setup(cell_t pcode_offs);
@@ -160,9 +160,9 @@ class JITX86
void FreeContextVars(sp_context_t *ctx);
SPVM_NATIVE_FUNC CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData);
void DestroyFakeNative(SPVM_NATIVE_FUNC func);
JitFunction *CompileFunction(BaseRuntime *runtime, cell_t pcode_offs, int *err);
Function *CompileFunction(BaseRuntime *runtime, cell_t pcode_offs, int *err);
ICompilation *ApplyOptions(ICompilation *_IN, ICompilation *_OUT);
int InvokeFunction(BaseRuntime *runtime, JitFunction *fn, cell_t *result);
int InvokeFunction(BaseRuntime *runtime, Function *fn, cell_t *result);
void RegisterRuntime(BaseRuntime *rt);
void DeregisterRuntime(BaseRuntime *rt);