1.1 --- a/sourcepawn/jit/x86/jit_x86.h Fri Mar 28 06:21:34 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,146 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourcePawn JIT
1.8 - * Copyright (C)2004-2007 AlliedModders LLC. All rights reserved.
1.9 - * =============================================================================
1.10 - *
1.11 - * This file is not open source and may not be copied without explicit wriiten
1.12 - * permission of AlliedModders LLC. This file may not be redistributed in whole
1.13 - * or significant part.
1.14 - * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
1.15 - *
1.16 - * Version: $Id$
1.17 - */
1.18 -
1.19 -#ifndef _INCLUDE_SOURCEPAWN_JIT_X86_H_
1.20 -#define _INCLUDE_SOURCEPAWN_JIT_X86_H_
1.21 -
1.22 -#include <sp_vm_types.h>
1.23 -#include <sp_vm_api.h>
1.24 -#include <jit_helpers.h>
1.25 -
1.26 -using namespace SourcePawn;
1.27 -
1.28 -#define JIT_INLINE_ERRORCHECKS (1<<0)
1.29 -#define JIT_INLINE_NATIVES (1<<1)
1.30 -#define STACK_MARGIN 64 //8 parameters of safety, I guess
1.31 -#define JIT_FUNCMAGIC 0x214D4148 //magic function offset
1.32 -
1.33 -#define JITVARS_TRACKER 0 //important: don't change this to avoid trouble
1.34 -#define JITVARS_FUNCINFO 1 //important: don't change this aWOAWOGJQG I LIKE HAM
1.35 -#define JITVARS_REBASE 2 //important: hi, i'm bail
1.36 -
1.37 -#define sDIMEN_MAX 5 //this must mirror what the compiler has.
1.38 -
1.39 -typedef struct tracker_s
1.40 -{
1.41 - size_t size;
1.42 - ucell_t *pBase;
1.43 - ucell_t *pCur;
1.44 -} tracker_t;
1.45 -
1.46 -typedef struct funcinfo_s
1.47 -{
1.48 - unsigned int magic;
1.49 - unsigned int index;
1.50 -} funcinfo_t;
1.51 -
1.52 -typedef struct functracker_s
1.53 -{
1.54 - unsigned int num_functions;
1.55 - unsigned int code_size;
1.56 -} functracker_t;
1.57 -
1.58 -struct floattbl_t
1.59 -{
1.60 - floattbl_t()
1.61 - {
1.62 - found = false;
1.63 - index = 0;
1.64 - }
1.65 - bool found;
1.66 - unsigned int index;
1.67 -};
1.68 -
1.69 -class CompData : public ICompilation
1.70 -{
1.71 -public:
1.72 - CompData() : plugin(NULL),
1.73 - debug(false), profile(0), inline_level(0), rebase(NULL),
1.74 - error_set(SP_ERROR_NONE), func_idx(0)
1.75 - {
1.76 - };
1.77 -public:
1.78 - sp_plugin_t *plugin; /* plugin handle */
1.79 - bool debug; /* whether to compile debug mode */
1.80 - int profile; /* profiling flags */
1.81 - int inline_level; /* inline optimization level */
1.82 - jitcode_t rebase; /* relocation map */
1.83 - int error_set; /* error code to halt process */
1.84 - unsigned int func_idx; /* current function index */
1.85 - jitoffs_t jit_return; /* point in main call to return to */
1.86 - jitoffs_t jit_verify_addr_eax;
1.87 - jitoffs_t jit_verify_addr_edx;
1.88 - jitoffs_t jit_break; /* call to op.break */
1.89 - jitoffs_t jit_sysreq_n; /* call version of op.sysreq.n */
1.90 - jitoffs_t jit_genarray; /* call to genarray intrinsic */
1.91 - jitoffs_t jit_error_bounds;
1.92 - jitoffs_t jit_error_divzero;
1.93 - jitoffs_t jit_error_stacklow;
1.94 - jitoffs_t jit_error_stackmin;
1.95 - jitoffs_t jit_error_memaccess;
1.96 - jitoffs_t jit_error_heaplow;
1.97 - jitoffs_t jit_error_heapmin;
1.98 - jitoffs_t jit_error_array_too_big;
1.99 - jitoffs_t jit_extern_error; /* returning generic error */
1.100 - jitoffs_t jit_sysreq_c; /* old version! */
1.101 - jitoffs_t jit_rounding_table;
1.102 - floattbl_t *jit_float_table;
1.103 - uint32_t codesize; /* total codesize */
1.104 -};
1.105 -
1.106 -class JITX86 : public IVirtualMachine
1.107 -{
1.108 -public:
1.109 - const char *GetVMName();
1.110 - ICompilation *StartCompilation(sp_plugin_t *plugin);
1.111 - bool SetCompilationOption(ICompilation *co, const char *key, const char *val);
1.112 - sp_context_t *CompileToContext(ICompilation *co, int *err);
1.113 - void AbortCompilation(ICompilation *co);
1.114 - void FreeContext(sp_context_t *ctx);
1.115 - int ContextExecute(sp_context_t *ctx, uint32_t code_idx, cell_t *result);
1.116 - unsigned int GetAPIVersion();
1.117 - bool FunctionLookup(const sp_context_t *ctx, uint32_t code_addr, unsigned int *result);
1.118 - bool FunctionPLookup(const sp_context_t *ctx, uint32_t code_addr, unsigned int *result);
1.119 - unsigned int FunctionCount(const sp_context_t *ctx);
1.120 - const char *GetVersionString();
1.121 - const char *GetCPUOptimizations();
1.122 - SPVM_NATIVE_FUNC CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData);
1.123 - void DestroyFakeNative(SPVM_NATIVE_FUNC func);
1.124 -};
1.125 -
1.126 -cell_t NativeCallback(sp_context_t *ctx, ucell_t native_idx, cell_t *params);
1.127 -cell_t NativeCallback_Debug(sp_context_t *ctx, ucell_t native_idx, cell_t *params);
1.128 -cell_t NativeCallback_Debug_Profile(sp_context_t *ctx, ucell_t native_idx, cell_t *params);
1.129 -cell_t NativeCallback_Profile(sp_context_t *ctx, ucell_t native_idx, cell_t *params);
1.130 -jitoffs_t RelocLookup(JitWriter *jit, cell_t pcode_offs, bool relative=false);
1.131 -
1.132 -#define AMX_REG_PRI REG_EAX
1.133 -#define AMX_REG_ALT REG_EDX
1.134 -#define AMX_REG_STK REG_EDI
1.135 -#define AMX_REG_DAT REG_EBP
1.136 -#define AMX_REG_TMP REG_ECX
1.137 -#define AMX_REG_INFO REG_ESI
1.138 -#define AMX_REG_FRM REG_EBX
1.139 -
1.140 -#define AMX_INFO_FRM AMX_REG_INFO //not relocated
1.141 -#define AMX_INFO_FRAME 0 //(same thing as above)
1.142 -#define AMX_INFO_HEAP 4 //not relocated
1.143 -#define AMX_INFO_RETVAL 8 //physical
1.144 -#define AMX_INFO_CONTEXT 12 //physical
1.145 -#define AMX_INFO_STACKTOP 16 //relocated
1.146 -
1.147 -extern ISourcePawnEngine *engine;
1.148 -
1.149 -#endif //_INCLUDE_SOURCEPAWN_JIT_X86_H_