diff options
-rw-r--r-- | compiler/vmdef.nim | 10 | ||||
-rw-r--r-- | tests/vm/tfarjump.nim | 14 | ||||
-rw-r--r-- | tests/vm/tmanyregs.nim | 16 |
3 files changed, 35 insertions, 5 deletions
diff --git a/compiler/vmdef.nim b/compiler/vmdef.nim index 0c3c54d0e..a5df87ca8 100644 --- a/compiler/vmdef.nim +++ b/compiler/vmdef.nim @@ -12,14 +12,14 @@ import ast, idents, options, modulegraphs, lineinfos -type TInstrType* = uint32 +type TInstrType* = uint64 const regOBits = 8 # Opcode - regABits = 8 - regBBits = 8 - regCBits = 8 - regBxBits = 16 + regABits = 16 + regBBits = 16 + regCBits = 16 + regBxBits = 24 byteExcess* = 128 # we use excess-K for immediates diff --git a/tests/vm/tfarjump.nim b/tests/vm/tfarjump.nim new file mode 100644 index 000000000..f5798b8d2 --- /dev/null +++ b/tests/vm/tfarjump.nim @@ -0,0 +1,14 @@ +# Test a VM relative jump with an offset larger then 32767 instructions. + +import macros + +static: + var a = 0 + macro foo(): untyped = + let s = newStmtList() + for i in 1..6554: + s.add nnkCommand.newTree(ident("inc"), ident("a")) + quote do: + if true: + `s` + foo() diff --git a/tests/vm/tmanyregs.nim b/tests/vm/tmanyregs.nim new file mode 100644 index 000000000..711c69285 --- /dev/null +++ b/tests/vm/tmanyregs.nim @@ -0,0 +1,16 @@ +import macros + +# Generate a proc with more then 255 registers. Should not generate an error at +# compile time + +static: + macro mkFoo() = + let ss = newStmtList() + for i in 1..256: + ss.add parseStmt "var x" & $i & " = " & $i + ss.add parseStmt "inc x" & $i + quote do: + proc foo() = + `ss` + mkFoo() + foo() |