[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] library constants

From: felix winkelmann
Subject: Re: [Chicken-users] library constants
Date: Thu, 11 Nov 2004 09:18:03 +0100

On Tue, 09 Nov 2004 02:18:08 -0600, Alex Shinn <address@hidden> wrote:
> I currently have a library which is just a collection of constant
> char-sets - the file is about 65kb and the compiled library is about
> 190kb.
> The definitions are all of the form:
>   (define char-set:foo
>     (moderately-expensive-computation ...))
> If I use
>   (define-constant char-set:foo ...)
> then even though char-set:foo is declared as an export no code is
> generated for it and it gets left out of the library.

Correct, constants defined with `define-constant' are like
C #define's: they are not visible outside of the compilation unit.

> Unfortunately, if I define _all_ the char-sets this way the
> compilation for some reason requires much more memory and fails with
> the following error:
> cc1: out of memory allocating 285658208 bytes after a total of 21295104 bytes
> Is this a reasonable approach to creating fast-loading libraries and
> if so why does it require so much more memory to compile?

That's (AFAIK) a problem with gcc: the "literal frame" (the data structure
that holds all constants in a compilation unit) is built in the toplevel-
procedure of a unit, which with large sets of literals can get very big.

What you can do is compile them as strings, and the the toplevel
procedure read them in at load time, by using

(declare (compress-literals ...))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]