VM: attempt to get integer ops right
This commit is contained in:
parent
ee1192679e
commit
907e1b80b2
3 changed files with 53 additions and 27 deletions
|
|
@ -948,17 +948,15 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
|||
of opcReset:
|
||||
internalError(c.debug[pc], "too implement")
|
||||
of opcNarrowS:
|
||||
decodeBC(rkInt)
|
||||
let min = -(1 shl (rc-1))
|
||||
let max = (1 shl (rc-1))-1
|
||||
if regs[rb].intVal >= min and regs[rb].intVal <= max:
|
||||
regs[ra].intVal = regs[rb].intVal
|
||||
else:
|
||||
decodeB(rkInt)
|
||||
let min = -(1 shl (rb-1))
|
||||
let max = (1 shl (rb-1))-1
|
||||
if regs[ra].intVal < min or regs[ra].intVal > max:
|
||||
stackTrace(c, tos, pc, errGenerated,
|
||||
msgKindToString(errUnhandledExceptionX) % "value out of range")
|
||||
of opcNarrowU:
|
||||
decodeBC(rkInt)
|
||||
regs[ra].intVal = regs[rb].intVal and ((1'i64 shl rc)-1)
|
||||
decodeB(rkInt)
|
||||
regs[ra].intVal = regs[ra].intVal and ((1'i64 shl rb)-1)
|
||||
of opcIsNil:
|
||||
decodeB(rkInt)
|
||||
regs[ra].intVal = ord(regs[rb].node.kind == nkNilLit)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue