mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-17 01:31:25 +00:00
Start jit_call implementation
This commit is contained in:
parent
0b769474b0
commit
5c06d0911d
2 changed files with 29 additions and 16 deletions
|
@ -3,10 +3,6 @@
|
|||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#if 1
|
||||
|
||||
#else
|
||||
|
||||
void JitCompiler::EmitPARAM()
|
||||
{
|
||||
ParamOpcodes.Push(pc);
|
||||
|
@ -35,18 +31,21 @@ void JitCompiler::EmitVtbl(const VMOP *op)
|
|||
int b = op->b;
|
||||
int c = op->c;
|
||||
|
||||
auto label = EmitThrowExceptionLabel(X_READ_NIL);
|
||||
cc.test(regA[b], regA[b]);
|
||||
cc.jz(label);
|
||||
auto exceptionbb = EmitThrowExceptionLabel(X_READ_NIL);
|
||||
auto continuebb = irfunc->createBasicBlock({});
|
||||
cc.CreateCondBr(cc.CreateICmpNE(LoadA(b), ConstValueA(0)), exceptionbb, continuebb);
|
||||
cc.SetInsertPoint(continuebb);
|
||||
|
||||
cc.mov(regA[a], asmjit::x86::qword_ptr(regA[b], myoffsetof(DObject, Class)));
|
||||
cc.mov(regA[a], asmjit::x86::qword_ptr(regA[a], myoffsetof(PClass, Virtuals) + myoffsetof(FArray, Array)));
|
||||
cc.mov(regA[a], asmjit::x86::qword_ptr(regA[a], c * (int)sizeof(void*)));
|
||||
IRValue* ptrObject = LoadA(b);
|
||||
IRValue* ptrClass = Load(ToPtrPtr(ptrObject, ConstValueD(myoffsetof(DObject, Class))));
|
||||
IRValue* ptrArray = Load(ToPtrPtr(ptrClass, ConstValueD(myoffsetof(PClass, Virtuals) + myoffsetof(FArray, Array))));
|
||||
IRValue* ptrFunc = Load(ToPtrPtr(ptrArray, ConstValueD(c * (int)sizeof(void*))));
|
||||
StoreA(ptrFunc, a);
|
||||
}
|
||||
|
||||
void JitCompiler::EmitCALL()
|
||||
{
|
||||
EmitVMCall(regA[A], nullptr);
|
||||
EmitVMCall(LoadA(A), nullptr);
|
||||
pc += C; // Skip RESULTs
|
||||
}
|
||||
|
||||
|
@ -64,14 +63,24 @@ void JitCompiler::EmitCALL_K()
|
|||
}
|
||||
else
|
||||
{
|
||||
auto ptr = newTempIntPtr();
|
||||
cc.mov(ptr, asmjit::imm_ptr(target));
|
||||
EmitVMCall(ptr, target);
|
||||
EmitVMCall(ConstValueA(target), target);
|
||||
}
|
||||
|
||||
pc += C; // Skip RESULTs
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
||||
void JitCompiler::EmitNativeCall(VMNativeFunction* target)
|
||||
{
|
||||
}
|
||||
|
||||
void JitCompiler::EmitVMCall(IRValue* ptr, VMFunction* target)
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void JitCompiler::EmitVMCall(asmjit::X86Gp vmfunc, VMFunction *target)
|
||||
{
|
||||
using namespace asmjit;
|
||||
|
|
|
@ -35,6 +35,10 @@ private:
|
|||
|
||||
IRBasicBlock* GetLabel(size_t pos) { return nullptr; }
|
||||
|
||||
void EmitNativeCall(VMNativeFunction* target);
|
||||
void EmitVMCall(IRValue* ptr, VMFunction* target);
|
||||
void EmitVtbl(const VMOP* op);
|
||||
|
||||
void EmitReadBarrier();
|
||||
|
||||
void EmitNullPointerThrow(int index, EVMAbortException reason);
|
||||
|
@ -135,6 +139,8 @@ private:
|
|||
|
||||
const VMOP* pc;
|
||||
VM_UBYTE op;
|
||||
|
||||
TArray<const VMOP*> ParamOpcodes;
|
||||
};
|
||||
|
||||
#else
|
||||
|
@ -382,8 +388,6 @@ private:
|
|||
int offsetD;
|
||||
int offsetExtra;
|
||||
|
||||
TArray<const VMOP *> ParamOpcodes;
|
||||
|
||||
void CheckVMFrame();
|
||||
asmjit::X86Gp GetCallReturns();
|
||||
|
||||
|
|
Loading…
Reference in a new issue