I've been trying to use the Blind Mind Studios' JIT compiler for AS, but never got it working.
My setup is:
- MSVC 2013
- 64bit
- Angelscript version 2.29.1
- latest version of the JIT (update 23 10 2014)
I'm building these files along with my project:
- as_jit.cpp
- virtual_asm_windows.cpp
- virtual_asm_x64.cpp
I hope thats correct, anything else seemed to cause linker errors.
I'm starting the JIT like this:
asCJITCompiler* jit = new asCJITCompiler(0);
engine->SetEngineProperty(as::asEP_INCLUDE_JIT_INSTRUCTIONS, 1);
engine->SetJITCompiler(jit);
Right after engine creation, before compiling or running any scripts.
The problem is that script compilation crashes every time, if the script is anything even remotely complex. Calling a few print functions works fine, but trying to create even 1 object causes the compilation to crash.
This is the call stack when it crashes:
KernelBase.dll!000007fefcc8940d() Unknown
msvcr120d.dll!000007fee439c366() Unknown
> as tests_debug.exe!AngelScript::assembler::Processor::end_short_jump(void * p) Line 547 C++
as tests_debug.exe!AngelScript::asCJITCompiler::CompileFunction(AngelScript::asIScriptFunction * function, void (AngelScript::asSVMRegisters *, unsigned __int64) * * output) Line 1840 C++
as tests_debug.exe!AngelScript::asCScriptFunction::JITCompile() Line 1439 C++
as tests_debug.exe!AngelScript::asCModule::JITCompile() Line 241 C++
as tests_debug.exe!AngelScript::asCModule::Build() Line 290 C++
as tests_debug.exe!AngelScript::CScriptBuilder::Build() Line 501 C++
as tests_debug.exe!AngelScript::CScriptBuilder::BuildModule() Line 104 C++
as tests_debug.exe!AngelScript::main_contents() Line 19 C++
as tests_debug.exe!main() Line 47 C++
[External Code]
This thing seems to be throwing its exception, because offset is 138 and CHAR_MAX is 127
void assembler::Processor::end_short_jump(void* p) {
volatile byte* jumpFrom = (volatile byte*)p;
int64_t offset = ((size_t)op - (size_t)jumpFrom) - 1;
if(offset < CHAR_MIN || offset > CHAR_MAX)
throw "Short jump too long.";
*jumpFrom = (char)offset;
}