initial import of dynamic native code for both the JIT and plugins
note: dependency resolution is not done yet! --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40607
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
#include "dll_exports.h"
|
||||
|
||||
SourcePawn::ISourcePawnEngine *engine = NULL;
|
||||
JITX86 jit;
|
||||
JITX86 g_jit;
|
||||
|
||||
EXPORTFUNC int GiveEnginePointer(SourcePawn::ISourcePawnEngine *engine_p)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ EXPORTFUNC SourcePawn::IVirtualMachine *GetExport(unsigned int exportnum)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &jit;
|
||||
return &g_jit;
|
||||
}
|
||||
|
||||
#if defined __linux__
|
||||
|
||||
@@ -2188,6 +2188,52 @@ jit_rewind:
|
||||
return ctx;
|
||||
}
|
||||
|
||||
SPVM_NATIVE_FUNC JITX86::CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData)
|
||||
{
|
||||
JitWriter jw;
|
||||
JitWriter *jit = &jw;
|
||||
|
||||
jw.outbase = NULL;
|
||||
jw.outptr = NULL;
|
||||
jw.data = NULL;
|
||||
|
||||
/* First pass, calculate size */
|
||||
rewind:
|
||||
//push pData ;push pData
|
||||
//push [esp+12] ;push params
|
||||
//push [esp+12] ;push ctx
|
||||
//call [callback] ;invoke the meta-callback
|
||||
//add esp, 12 ;restore the stack
|
||||
//ret ;return
|
||||
IA32_Push_Imm32(jit, (jit_int32_t)pData);
|
||||
IA32_Push_Rm_Disp8_ESP(jit, 12);
|
||||
IA32_Push_Rm_Disp8_ESP(jit, 12);
|
||||
uint32_t call = IA32_Call_Imm32(jit, 0);
|
||||
IA32_Write_Jump32_Abs(jit, call, (void *)callback);
|
||||
IA32_Add_Rm_Imm8(jit, REG_ESP, 12, MOD_REG);
|
||||
IA32_Return(jit);
|
||||
|
||||
if (jw.outbase == NULL)
|
||||
{
|
||||
/* Second pass: Actually write */
|
||||
jw.outbase = (jitcode_t)engine->ExecAlloc(jw.get_outputpos());
|
||||
if (!jw.outbase)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
jw.outptr = jw.outbase;
|
||||
|
||||
goto rewind;
|
||||
}
|
||||
|
||||
return (SPVM_NATIVE_FUNC)jw.outbase;
|
||||
}
|
||||
|
||||
void JITX86::DestroyFakenative(SPVM_NATIVE_FUNC func)
|
||||
{
|
||||
engine->ExecFree(func);
|
||||
}
|
||||
|
||||
const char *JITX86::GetVMName()
|
||||
{
|
||||
return "JIT (x86)";
|
||||
|
||||
@@ -98,6 +98,8 @@ public:
|
||||
unsigned int FunctionCount(const sp_context_t *ctx);
|
||||
const char *GetVersionString();
|
||||
const char *GetCPUOptimizations();
|
||||
SPVM_NATIVE_FUNC CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData);
|
||||
void DestroyFakenative(SPVM_NATIVE_FUNC func);
|
||||
};
|
||||
|
||||
cell_t NativeCallback(sp_context_t *ctx, ucell_t native_idx, cell_t *params);
|
||||
|
||||
@@ -234,6 +234,10 @@
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\jit_version.tpl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\opcode_switch.inc"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user