Implement build_function_asm

Uses ASMJIT to build function at startup
This commit is contained in:
Nekotekina 2018-05-14 23:06:17 +03:00
parent fd8aae5725
commit fd525ae1cf
3 changed files with 88 additions and 7 deletions

View file

@ -1,3 +1,34 @@
#include "JIT.h"
asmjit::JitRuntime& asmjit::get_global_runtime()
{
// Magic static
static asmjit::JitRuntime g_rt;
return g_rt;
}
void asmjit::build_transaction_enter(asmjit::X86Assembler& c, asmjit::Label abort)
{
Label fall = c.newLabel();
Label begin = c.newLabel();
c.jmp(begin);
c.bind(fall);
c.test(x86::eax, _XABORT_RETRY);
c.jz(abort);
c.align(kAlignCode, 16);
c.bind(begin);
c.xbegin(fall);
}
void asmjit::build_transaction_abort(asmjit::X86Assembler& c, unsigned char code)
{
c.db(0xc6);
c.db(0xf8);
c.db(code);
c.xor_(x86::eax, x86::eax);
c.ret();
}
#ifdef LLVM_AVAILABLE
#include <unordered_map>
@ -34,8 +65,6 @@
#include <sys/mman.h>
#endif
#include "JIT.h"
// Memory manager mutex
shared_mutex s_mutex;