VM exception fixes (#11868)

This commit is contained in:
Oscar Nihlgård 2019-08-02 23:59:04 +02:00 • committed by cooldome
commit 50e921bb94
3 changed files with 28 additions and 2 deletions

View file

@ -102,7 +102,8 @@ template stackTrace(c: PCtx, tos: PStackFrame, pc: int, msg: string) =
proc bailOut(c: PCtx; tos: PStackFrame) =
stackTrace(c, tos, c.exceptionInstr, "unhandled exception: " &
c.currentExceptionA.sons[3].skipColon.strVal)
c.currentExceptionA.sons[3].skipColon.strVal &
" [" & c.currentExceptionA.sons[2].skipColon.strVal & "]")
when not defined(nimComputedGoto):
{.pragma: computedGoto.}
@ -1199,8 +1200,15 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
tos = savedFrame
move(regs, tos.slots)
of opcRaise:
let raised = regs[ra].node
let raised =
# Empty `raise` statement - reraise current exception
if regs[ra].kind == rkNone:
c.currentExceptionA
else:
regs[ra].node
c.currentExceptionA = raised
# Set the `name` field of the exception
c.currentExceptionA.sons[2].skipColon.strVal = c.currentExceptionA.typ.sym.name.s
c.exceptionInstr = pc
var frame = tos