2006-09-20 02:41:24 +02:00
|
|
|
#ifndef _INCLUDE_SOURCEPAWN_JIT_X86_H_
|
|
|
|
#define _INCLUDE_SOURCEPAWN_JIT_X86_H_
|
|
|
|
|
2006-09-20 04:56:20 +02:00
|
|
|
#include <sp_vm_types.h>
|
2006-09-20 02:41:24 +02:00
|
|
|
#include <sp_vm_api.h>
|
2006-09-20 10:44:21 +02:00
|
|
|
#include "..\jit_helpers.h"
|
2006-09-20 02:41:24 +02:00
|
|
|
|
|
|
|
using namespace SourcePawn;
|
|
|
|
|
2006-09-20 10:44:21 +02:00
|
|
|
#define JIT_INLINE_ERRORCHECKS (1<<0)
|
|
|
|
#define JIT_INLINE_NATIVES (1<<1)
|
2006-09-21 01:33:40 +02:00
|
|
|
#define STACK_MARGIN 16
|
2006-09-20 10:44:21 +02:00
|
|
|
|
2006-09-20 02:41:24 +02:00
|
|
|
class CompData : public ICompilation
|
|
|
|
{
|
|
|
|
public:
|
2006-09-20 17:51:05 +02:00
|
|
|
CompData() : plugin(NULL),
|
2006-09-23 06:11:01 +02:00
|
|
|
debug(false), inline_level(3), checks(true),
|
|
|
|
rebase(NULL)
|
2006-09-20 02:41:24 +02:00
|
|
|
{
|
|
|
|
};
|
|
|
|
public:
|
|
|
|
sp_plugin_t *plugin;
|
2006-09-23 06:11:01 +02:00
|
|
|
jitcode_t *rebase;
|
2006-09-20 10:44:21 +02:00
|
|
|
jitoffs_t jit_return;
|
|
|
|
jitoffs_t jit_verify_addr_eax;
|
|
|
|
jitoffs_t jit_verify_addr_edx;
|
2006-09-21 01:33:40 +02:00
|
|
|
jitoffs_t jit_chkmargin_heap;
|
2006-09-21 04:58:59 +02:00
|
|
|
jitoffs_t jit_bounds;
|
2006-09-21 07:04:51 +02:00
|
|
|
jitoffs_t jit_break;
|
2006-09-23 06:11:01 +02:00
|
|
|
uint32_t codesize;
|
2006-09-20 09:07:49 +02:00
|
|
|
int inline_level;
|
2006-09-20 17:51:05 +02:00
|
|
|
bool checks;
|
2006-09-20 02:41:24 +02:00
|
|
|
bool debug;
|
|
|
|
};
|
|
|
|
|
|
|
|
class JITX86 : public IVirtualMachine
|
|
|
|
{
|
2006-09-20 03:59:56 +02:00
|
|
|
public:
|
|
|
|
JITX86();
|
2006-09-20 02:41:24 +02:00
|
|
|
public:
|
|
|
|
const char *GetVMName() =0;
|
|
|
|
ICompilation *StartCompilation(sp_plugin_t *plugin);
|
|
|
|
bool SetCompilationOption(ICompilation *co, const char *key, const char *val) ;
|
2006-09-20 03:59:56 +02:00
|
|
|
IPluginContext *CompileToContext(ICompilation *co, int *err);
|
2006-09-20 02:41:24 +02:00
|
|
|
void AbortCompilation(ICompilation *co);
|
|
|
|
void FreeContextVars(sp_context_t *ctx);
|
|
|
|
int ContextExecute(sp_context_t *ctx, uint32_t code_idx, cell_t *result);
|
|
|
|
};
|
|
|
|
|
2006-09-23 06:11:01 +02:00
|
|
|
jitoffs_t RelocLookup(JitWriter *jit, cell_t pcode_offs, bool relative=false);
|
|
|
|
|
2006-09-20 04:56:20 +02:00
|
|
|
#define AMX_REG_PRI REG_EAX
|
|
|
|
#define AMX_REG_ALT REG_EDX
|
|
|
|
#define AMX_REG_STK REG_EBP
|
|
|
|
#define AMX_REG_DAT REG_EDI
|
|
|
|
#define AMX_REG_TMP REG_ECX
|
|
|
|
#define AMX_REG_INFO REG_ESI
|
|
|
|
#define AMX_REG_FRM REG_EBX
|
|
|
|
|
2006-09-21 01:33:40 +02:00
|
|
|
#define AMX_INFO_FRM AMX_REG_INFO //not relocated
|
2006-09-21 07:04:51 +02:00
|
|
|
#define AMX_INFO_FRAME 0 //(same thing as above)
|
2006-09-21 01:33:40 +02:00
|
|
|
#define AMX_INFO_HEAP 4 //not relocated
|
|
|
|
#define AMX_INFO_RETVAL 8 //physical
|
|
|
|
#define AMX_INFO_CONTEXT 12 //physical
|
|
|
|
#define AMX_INFO_STACKTOP 16 //relocated
|
|
|
|
#define AMX_INFO_HEAPLOW 20 //not relocated
|
2006-09-20 03:59:56 +02:00
|
|
|
|
2006-09-23 06:11:01 +02:00
|
|
|
extern ISourcePawnEngine *engine;
|
|
|
|
|
2006-09-20 02:41:24 +02:00
|
|
|
#endif //_INCLUDE_SOURCEPAWN_JIT_X86_H_
|