summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-06-20 21:48:13 -0700
committerKaz Kylheku <kaz@kylheku.com>2025-06-20 21:48:13 -0700
commite853d74481a69415021aabac70f28fd1b403b62a (patch)
tree46b4bdb10717863c5651dd52f94e8a2d401cb4cf /stdlib
parentc11c2304890a46073349d938b1d17a1e26b093d9 (diff)
downloadtxr-e853d74481a69415021aabac70f28fd1b403b62a.tar.gz
txr-e853d74481a69415021aabac70f28fd1b403b62a.tar.bz2
txr-e853d74481a69415021aabac70f28fd1b403b62a.zip
compiler: bug: end instruction balance in tjmp/bjmp handling.
I was reading the compiler code and noticed that the code template for unwind protect has two end instructions: one for the protected calculation and one for the unwinds. * stdlib/compiler.tl (convert-t-b-jumps): When a uwprot instruction is encountered, the balance must be incremented by 2, in order to skip past two end instructions. Without this we will end up with incorrect code for a block return that jumps out of a block, in which there is a subsequent unwind-protect.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/compiler.tl5
1 files changed, 4 insertions, 1 deletions
diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl
index 59c7601c..01955302 100644
--- a/stdlib/compiler.tl
+++ b/stdlib/compiler.tl
@@ -1901,9 +1901,12 @@
(add ^(jmp ,top))
(pop insns)
(return))
- (((@(or frame dframe block handle catch uwprot) . @nil) . @nil)
+ (((@(or frame dframe block handle catch) . @nil) . @nil)
(inc bal)
(pop rest))
+ (((uwprot . @nil) . @nil)
+ (inc bal 2)
+ (pop rest))
(((end . @nil) . @nil)
(cond
((zerop bal) (add (pop rest)))