GNU bug report logs - #58905
Vector initialization loop remains even when allocation is elided

Previous Next

Package: guile;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Sun, 30 Oct 2022 21:39:01 UTC

Severity: normal

To reply to this bug, email your comments to 58905 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#58905; Package guile. (Sun, 30 Oct 2022 21:39:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludo <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sun, 30 Oct 2022 21:39:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: bug-guile <at> gnu.org
Subject: Vector initialization loop remains even when allocation is elided
Date: Sun, 30 Oct 2022 22:38:51 +0100
Spot the issue in the code below?

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (version)
$28 = "3.0.8"
scheme@(guile-user)> ,c (let () (make-vector 12345 #\x) 42)
Disassembly of <unnamed function> at #xe8:

   0    (instrument-entry 42)                                 at (unknown file):5009:35
   2    (assert-nargs-ee/locals 1 1)    ;; 2 slots (0 args)
   3    (load-u64 1 0 12346)                                  at (unknown file):5009:11
   6    (load-u64 0 0 1)                
   9    (uadd/immediate 0 0 1)          
  10    (u64<? 0 1)                     
  11    (jnl 7)                         ;; -> L2
L1:
  12    (instrument-loop 30)            
  14    (handle-interrupts)             
  15    (uadd/immediate 0 0 1)          
  16    (u64<? 0 1)                     
  17    (jl -5)                         ;; -> L1
L2:
  18    (make-immediate 1 170)          ;; 42                 at (unknown file):5009:35
  19    (reset-frame 1)                 ;; 1 slot
  20    (handle-interrupts)             
  21    (return-values)                 

--8<---------------cut here---------------end--------------->8---

Vector allocation is elided (no ‘allocate-words’ instruction),
rightfully so (assuming we neglect the possibility of an out-of-memory
effect), but we still have the skeleton of the vector initialization
loop with its 12345 iterations.

Vector allocation is removed by the ‘eliminate-dead-code’ pass, which
happens on the VM instruction stream, so it explains why the loop
remains.

Still kinda surprising!

Also weird is the fact that ‘make-vector’ is kept by ‘peval’, on the
grounds that it might throw, but down the road it’s removed anyway.

Thoughts?

Ludo’.




This bug report was last modified 2 years and 28 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.