mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-16 09:31:14 +00:00
- improve jit debug output slightly
This commit is contained in:
parent
f0dbc8414a
commit
2efaa7846d
1 changed files with 33 additions and 18 deletions
|
@ -70,7 +70,7 @@ public:
|
||||||
cc.bind(labels[i]);
|
cc.bind(labels[i]);
|
||||||
|
|
||||||
FString lineinfo;
|
FString lineinfo;
|
||||||
lineinfo.Format("; %s(line %d): %02x%02x%02x%02x %s", sfunc->Name.GetChars(), sfunc->PCToLine(pc), pc->op, pc->a, pc->b, pc->c, OpNames[op]);
|
lineinfo.Format("; %s(line %d): %02x%02x%02x%02x %s", sfunc->PrintableName.GetChars(), sfunc->PCToLine(pc), pc->op, pc->a, pc->b, pc->c, OpNames[op]);
|
||||||
cc.comment(lineinfo.GetChars(), lineinfo.Len());
|
cc.comment(lineinfo.GetChars(), lineinfo.Len());
|
||||||
|
|
||||||
EmitFuncPtr opcodeFunc = GetOpcodeEmitFunc(op);
|
EmitFuncPtr opcodeFunc = GetOpcodeEmitFunc(op);
|
||||||
|
@ -2377,6 +2377,10 @@ private:
|
||||||
{
|
{
|
||||||
using namespace asmjit;
|
using namespace asmjit;
|
||||||
|
|
||||||
|
FString funcname;
|
||||||
|
funcname.Format("Function: %1", sfunc->PrintableName.GetChars());
|
||||||
|
cc.comment(funcname.GetChars(), funcname.Len());
|
||||||
|
|
||||||
stack = cc.newIntPtr("stack"); // VMFrameStack *stack
|
stack = cc.newIntPtr("stack"); // VMFrameStack *stack
|
||||||
vmregs = cc.newIntPtr("vmregs"); // void *vmregs
|
vmregs = cc.newIntPtr("vmregs"); // void *vmregs
|
||||||
ret = cc.newIntPtr("ret"); // VMReturn *ret
|
ret = cc.newIntPtr("ret"); // VMReturn *ret
|
||||||
|
@ -2593,9 +2597,30 @@ void JitCleanUp(VMScriptFunction *func)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void OutputJitLog(const asmjit::StringLogger &logger)
|
||||||
|
{
|
||||||
|
// Write line by line since I_FatalError seems to cut off long strings
|
||||||
|
const char *pos = logger.getString();
|
||||||
|
const char *end = pos;
|
||||||
|
while (*end)
|
||||||
|
{
|
||||||
|
if (*end == '\n')
|
||||||
|
{
|
||||||
|
FString substr(pos, (int)(ptrdiff_t)(end - pos));
|
||||||
|
Printf("%s\n", substr.GetChars());
|
||||||
|
pos = end + 1;
|
||||||
|
}
|
||||||
|
end++;
|
||||||
|
}
|
||||||
|
if (pos != end)
|
||||||
|
Printf("%s\n", pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
//#define DEBUG_JIT
|
||||||
|
|
||||||
JitFuncPtr JitCompile(VMScriptFunction *sfunc)
|
JitFuncPtr JitCompile(VMScriptFunction *sfunc)
|
||||||
{
|
{
|
||||||
#if 0 // For debugging
|
#if defined(DEBUG_JIT)
|
||||||
if (strcmp(sfunc->Name.GetChars(), "EmptyFunction") != 0)
|
if (strcmp(sfunc->Name.GetChars(), "EmptyFunction") != 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#else
|
#else
|
||||||
|
@ -2622,26 +2647,16 @@ JitFuncPtr JitCompile(VMScriptFunction *sfunc)
|
||||||
Error err = jit->add(&fn, &code);
|
Error err = jit->add(&fn, &code);
|
||||||
if (err)
|
if (err)
|
||||||
I_FatalError("JitRuntime::add failed: %d", err);
|
I_FatalError("JitRuntime::add failed: %d", err);
|
||||||
|
|
||||||
|
#if defined(DEBUG_JIT)
|
||||||
|
OutputJitLog(logger);
|
||||||
|
#endif
|
||||||
|
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
// Write line by line since I_FatalError seems to cut off long strings
|
OutputJitLog(logger);
|
||||||
const char *pos = logger.getString();
|
|
||||||
const char *end = pos;
|
|
||||||
while (*end)
|
|
||||||
{
|
|
||||||
if (*end == '\n')
|
|
||||||
{
|
|
||||||
FString substr(pos, (int)(ptrdiff_t)(end - pos));
|
|
||||||
Printf("%s\n", substr.GetChars());
|
|
||||||
pos = end + 1;
|
|
||||||
}
|
|
||||||
end++;
|
|
||||||
}
|
|
||||||
if (pos != end)
|
|
||||||
Printf("%s\n", pos);
|
|
||||||
|
|
||||||
I_FatalError("Unexpected JIT error: %s\n", e.what());
|
I_FatalError("Unexpected JIT error: %s\n", e.what());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue