summary refs log tree commit diff stats
path: root/tests/vm/tfarjump.nim
diff options
context:
space:
mode:
authorIco Doornekamp <ico@pruts.nl>2019-12-10 19:04:02 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-12-10 19:04:02 +0100
commite61d702206d62fb47aa55f34f83f41264299c0a3 (patch)
tree0ed7ddbd04d0d4dd42f5f473f82458248e2769e3 /tests/vm/tfarjump.nim
parentb8152b29e8b7274eef62f3252dfe8f2cce8adb8a (diff)
downloadNim-e61d702206d62fb47aa55f34f83f41264299c0a3.tar.gz
Increased TInstr field sizes: allow long jumps and 65535 VM registers (#12777)
* Increased regBx size from 16 to 24 bits to increase jump range in the VM
from 32K to 8M instructions. Fixes #12727

* Increased VM TInst register field sizes to 16 bits to allow up to 65535 VM registers per proc

* Added test case for >255 VM registers
Diffstat (limited to 'tests/vm/tfarjump.nim')
-rw-r--r--tests/vm/tfarjump.nim14
1 files changed, 14 insertions, 0 deletions
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()