From 240d29846cc959da84fb8ef709b7e8a0bf29da71 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 20 Sep 2006 20:11:02 +0000 Subject: [PATCH] committed OP_LCTRL for some reason added setpos() to JIT helpers --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%4083 --- sourcepawn/vm/jit/jit_helpers.h | 4 ++ sourcepawn/vm/jit/x86/jit_x86.cpp | 65 ++++++++++++++++++++++++++ sourcepawn/vm/jit/x86/opcode_helpers.h | 2 +- sourcepawn/vm/jit/x86/x86_macros.h | 5 +- 4 files changed, 74 insertions(+), 2 deletions(-) diff --git a/sourcepawn/vm/jit/jit_helpers.h b/sourcepawn/vm/jit/jit_helpers.h index e7d79084..43e6bd58 100644 --- a/sourcepawn/vm/jit/jit_helpers.h +++ b/sourcepawn/vm/jit/jit_helpers.h @@ -75,6 +75,10 @@ public: { return (outptr - outbase); } + inline void setpos(jitoffs_t offs) + { + outptr = outbase + offs; + } public: cell_t *inptr; /* input pointer */ jitcode_t outbase; /* output pointer */ diff --git a/sourcepawn/vm/jit/x86/jit_x86.cpp b/sourcepawn/vm/jit/x86/jit_x86.cpp index 4a9fd689..85e58322 100644 --- a/sourcepawn/vm/jit/x86/jit_x86.cpp +++ b/sourcepawn/vm/jit/x86/jit_x86.cpp @@ -1104,6 +1104,66 @@ inline void WriteOp_Lidx_B(JitWriter *jit) IA32_Mov_Reg_Rm_Disp_Reg(jit, AMX_REG_PRI, AMX_REG_DAT, AMX_REG_PRI, NOSCALE); } +inline void WriteOp_Lctrl(JitWriter *jit) +{ + cell_t val = jit->read_cell(); + switch (val) + { + case 0: + { + //mov ecx, [esi+ctx] + //mov eax, [ecx+] + IA32_Mov_Reg_Rm_Disp8(jit, REG_ECX, AMX_REG_INFO, AMX_INFO_CONTEXT); + IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_PRI, REG_ECX, offsetof(sp_context_t, base)); + break; + } + case 1: + { + //mov eax, edi + IA32_Mov_Reg_Rm(jit, AMX_REG_PRI, AMX_REG_DAT, MOD_REG); + break; + } + case 2: + { + //mov eax, [esi+hea] + IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_PRI, AMX_REG_INFO, AMX_INFO_HEAP); + break; + } + case 3: + { + //mov ecx, [esi+ctx] + //mov eax, [ecx+ctx.memory] + IA32_Mov_Reg_Rm_Disp8(jit, REG_ECX, AMX_REG_INFO, AMX_INFO_CONTEXT); + IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_PRI, REG_ECX, offsetof(sp_context_t, memory)); + break; + } + case 4: + { + //mov eax, ebp + //sub eax, edi - unrelocate + IA32_Mov_Reg_Rm(jit, AMX_REG_PRI, AMX_REG_STK, MOD_REG); + IA32_Sub_Rm_Reg(jit, AMX_REG_PRI, AMX_REG_DAT, MOD_REG); + break; + } + case 5: + { + //mov eax, [esi+frm] + IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_PRI, AMX_REG_INFO, AMX_INFO_FRM); + break; + } + case 6: + { + //mov eax, [cip] + jitoffs_t imm32 = IA32_Mov_Reg_Imm32(jit, AMX_REG_PRI, 0); + jitoffs_t save = jit->jit_curpos(); + jit->setpos(imm32); + jit->write_int32((uint32_t)(jit->outbase + save)); + jit->setpos(save); + break; + } + } +} + /************************************************* ************************************************* * JIT PROPER ************************************ @@ -1793,6 +1853,11 @@ IPluginContext *JITX86::CompileToContext(ICompilation *co, int *err) WriteOp_Idxaddr_B(jit); break; } + case OP_LCTRL: + { + WriteOp_Lctrl(jit); + break; + } default: { AbortCompilation(co); diff --git a/sourcepawn/vm/jit/x86/opcode_helpers.h b/sourcepawn/vm/jit/x86/opcode_helpers.h index 3fbc6801..7ecfe8f9 100644 --- a/sourcepawn/vm/jit/x86/opcode_helpers.h +++ b/sourcepawn/vm/jit/x86/opcode_helpers.h @@ -63,7 +63,7 @@ typedef enum OP_IDXADDR_B, //DONE OP_ALIGN_PRI, //DONE OP_ALIGN_ALT, //DONE - OP_LCTRL, + OP_LCTRL, //DONE OP_SCTRL, OP_MOVE_PRI, //DONE OP_MOVE_ALT, //DONE diff --git a/sourcepawn/vm/jit/x86/x86_macros.h b/sourcepawn/vm/jit/x86/x86_macros.h index 835a4cd8..5b93e10c 100644 --- a/sourcepawn/vm/jit/x86/x86_macros.h +++ b/sourcepawn/vm/jit/x86/x86_macros.h @@ -650,10 +650,13 @@ inline void IA32_Mov_Rm16_Reg_Disp_Reg(JitWriter *jit, * Moving from IMMEDIATE to REGISTER */ -inline void IA32_Mov_Reg_Imm32(JitWriter *jit, jit_uint8_t dest, jit_int32_t num) +inline jitoffs_t IA32_Mov_Reg_Imm32(JitWriter *jit, jit_uint8_t dest, jit_int32_t num) { + jitoffs_t offs; jit->write_ubyte(IA32_MOV_REG_IMM+dest); + offs = jit->jit_curpos(); jit->write_int32(num); + return offs; } inline void IA32_Mov_Rm_Imm32_Disp8(JitWriter *jit,