summaryrefslogtreecommitdiffstats
path: root/stdlib/compiler.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-06-16 22:51:45 -0700
committerKaz Kylheku <kaz@kylheku.com>2025-06-16 22:51:45 -0700
commite10d748899c821a8ceba411fe24745023dae602b (patch)
tree57cb7cdabb6025658e4df312f15c2138bd213bf2 /stdlib/compiler.tl
parentd06ffa36d79963dd084628d24a455517bb333a92 (diff)
downloadtxr-e10d748899c821a8ceba411fe24745023dae602b.tar.gz
txr-e10d748899c821a8ceba411fe24745023dae602b.tar.bz2
txr-e10d748899c821a8ceba411fe24745023dae602b.zip
compiler: remove loop-nest counter hack
The loop-nest counter in the compiler context is positive whenever a loop is being compiled. This informs the eliminate-frame function that a variable-binding block can be executed multiple times, and so when variables are converted to registers, those registers have to be explicitly initialized to nil (in order to bring about the semantics of fresh lexical variables being nil). In this patch, we get rid of the counter and just always generate the zero-initializations. They get well optimized away. The code is usually the same. Sometimes four bytes longer or shorter. I'm noticing smaller frame sizes across the board due to registers being eliminated. * stdlib/compiler.tl (compiler): Remove loop-nest slot. (compiler eliminate-frame): Unconditionally emit the mov instructions which set all the new tregs to nil (i.e. copy the value of nil register (t 0)). (comp-for): Do not increment and decrement the loop count.
Diffstat (limited to 'stdlib/compiler.tl')
-rw-r--r--stdlib/compiler.tl13
1 files changed, 3 insertions, 10 deletions
diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl
index 52c9a908..002ef24d 100644
--- a/stdlib/compiler.tl
+++ b/stdlib/compiler.tl
@@ -218,7 +218,6 @@
(dreg-cntr 0)
(sidx-cntr 0)
(nlev 2)
- (loop-nest 0)
(tregs nil)
(dreg (hash :eql-based))
(data (hash :eql-based))
@@ -988,9 +987,7 @@
(let ((vb [vbhash loc]))
(set vb.loc treg)))
me.(free-tregs tregs)
- (if (plusp me.loop-nest)
- (append (mapcar (ret ^(mov ,@1 (t 0))) (nreverse tregs)) ncode)
- ncode)))
+ (append (mapcar (ret ^(mov ,@1 (t 0))) (nreverse tregs)) ncode)))
code))
(defmeth compiler comp-let (me oreg env form)
@@ -1588,14 +1585,10 @@
(let* ((treg me.(alloc-treg))
(ifrag me.(comp-progn treg env inits))
(*load-time* nil)
- (tfrag (progn
- (inc me.loop-nest)
- (if test-p (ntp me.(compile treg env test)))))
+ (tfrag (if test-p (ntp me.(compile treg env test))))
(rfrag me.(comp-progn oreg env rets))
(nfrag (ntp me.(comp-progn treg env incs)))
- (bfrag (prog1
- me.(comp-progn treg env body)
- (dec me.loop-nest)))
+ (bfrag me.(comp-progn treg env body))
(lback (gensym "l"))
(lskip (gensym "l"))
(frags (build