[armedbear-devel] failure to compile big files

Alessio Stalla alessiostalla at gmail.com
Sun Aug 22 20:14:04 UTC 2010

On Sun, Aug 22, 2010 at 3:19 PM, Carlos Ungil <carlos.ungil at gmail.com> wrote:
> Dear ABCL developers,
> trying to "compile-file" the following fragment of code using the
> latest release results in an error "s2 argument 32778 out of 16-bit
> signed range."
> -----------------------------------------------------
> (defmacro many-functions (n)
>  (append '(progn)
>          (loop for i from 1 to n
>             collect `(defun ,(intern (format nil "TEST~A" i)) ()
>                        (print ,i)))))
> (many-functions 1525)
> -----------------------------------------------------
> There are no problems with 0.20 (even for much bigger values of the
> parameter, i.e. bigger output files). I encountered the problem with a
> file containing several calls to the macro def-java-class in Jfli. It
> took me some time to discover that splitting the file in two was
> enough to make the problem go away...
> This is not a critical bug (it's usually easy to reorganize the code
> to ensure the files are small enough), but you might want to look at
> it.

The bug appears to be caused by the new way functions are loaded to
avoid reflection: a big loader function is created that installs all
the other functions by instantiating them as Java objects directly in
bytecode. Since a function gets compiled to a single method and
there's a limit on the size of a method, I believe we're hitting that
limit. The obvious solution is to split the big method in many smaller
methods (say, one every 1024 functions). I'd say this is a nice
occasion to test Erik's new class-file writer! ;) So, stay tuned: I'll
try to fix the bug asap.

Cheers, and thanks for the report,

More information about the armedbear-devel mailing list