Subject: bug#11087: closed (Re: bug#11087: vector limitation in compiling to bytecode)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 05 Jul 2012 21:07:02 +0000

Your bug report

#11087: vector limitation in compiling to bytecode

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
11087: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11087
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#11087: vector limitation in compiling to bytecode
From: Andy Wingo <[email-masked]>
To: Ian Price <[email-masked]>
Cc: [email-masked]
Date: Thu, 05 Jul 2012 23:01:42 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

On Sat 24 Mar 2012 21:09, Ian Price <[email-masked]> writes:

> ;;; ERROR: In procedure bytevector-u8-set!: Value out of range: 390
> vector constant containing 100000 values
>
> This limitation is documented, and somewhat reasonable, but on IRC mark
> weaver asked me to file a bug anyway, since he thinks the assembler
> should have a fall back plan.

I agree with Mark.

For what it's worth, if the vector is really constant (e.g. just
composed of immediates), the RTL VM will emit the whole thing
statically.  Otherwise it will emit code to allocate a vector
of the right size at init time, initializing its elements with
individual instructions.   This latter strategy is probably the right
thing to do with the Guile 2.0 VM.

In the mean time, I added a check for the vector-length to
glil/compile-assembly.scm.  If the vector is too big, it hits the array
case, which has a 24-bit range.  It seems to hit some other problem
after that, but I gave it the ole college try, right?

Cheers,

Andy
-- 
http://wingolog.org/

Subject: vector limitation in compiling to bytecode
From: Ian Price <[email-masked]>
To: [email-masked]
Date: Sat, 24 Mar 2012 20:09:28 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi guilers,

Earlier today I had a compilation warning while running a script.

~/src/mine/algorithms-course $ guile -L . -s invsinarray.scm 
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /home/ian/src/mine/algorithms-course/invsinarray.scm
;;; WARNING: compilation of /home/ian/src/mine/algorithms-course/invsinarray.scm failed:
;;; ERROR: In procedure bytevector-u8-set!: Value out of range: 390

It ran fine, but the compilation problem was that I had a vector
constant containing 100000 values[0]. Now, the vector instruction in the
vm expects the value to be less than 2^16, and when compiling this it
performs splits the value into two by taking the value and modulus from
dividing by 256. This leads to the instruction (vector 390 160), which
further on down the line write-byte fails on.

This limitation is documented, and somewhat reasonable, but on IRC mark
weaver asked me to file a bug anyway, since he thinks the assembler
should have a fall back plan.

[0] as you can guess from the names, it was data provided for an online
algorithms class I'm taking. I did the lazy thing and just wrapped the
file in #(...). I've since changed it to actually read the vector from
the file.

-- 
Ian Price

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"