- implement throwing by storing exception information in a struct, then return from the jitted function and throw from c++

This commit is contained in:
Magnus Norddahl 2018-08-18 22:41:18 +02:00
commit 3453f05f06
5 changed files with 69 additions and 28 deletions

View file

@ -80,17 +80,16 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
sfunc->JitFunc = JitCompile(sfunc);
sfunc->JitCompiled = true;
}
if (sfunc->JitFunc) {
try {
return sfunc->JitFunc(stack, &reg, ret, numret);
}
catch (CVMAbortException &err)
if (sfunc->JitFunc)
{
JitExceptionInfo exceptInfo;
exceptInfo.reason = -1;
int result = sfunc->JitFunc(stack, &reg, ret, numret, &exceptInfo);
if (exceptInfo.reason != -1)
{
err.MaybePrintMessage();
err.stacktrace.AppendFormat("Called from %s at %s, line %d\n", sfunc->PrintableName.GetChars(), sfunc->SourceFileName.GetChars(), sfunc->PCToLine(sfunc->pcOnJitAbort));
// PrintParameters(reg.param + f->NumParam - B, B);
throw;
ThrowAbortException(sfunc, exceptInfo.pcOnJitAbort, (EVMAbortException)exceptInfo.reason, nullptr);
}
return result;
}
}