lightning
[Top][All Lists]
Advanced

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

[Lightning] Re: Predicting generated code size


From: Ludovic Courtès
Subject: [Lightning] Re: Predicting generated code size
Date: Fri, 28 Sep 2007 19:50:22 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Hi,

"Sandro Magi" <address@hidden> writes:

> The examples in the manual provide a buffer to which Lightning outputs
> the generated code.

[...]

> Are there any heuristics or techniques to portably predict the size of
> the generated code so as to more accurately allocate the buffer?

I think you'd have to roll your own heuristics as a function of the
input data (e.g., bytecode) that feeds the code generation process.  And
you'd have to make sure they "mostly work" on all the architectures you
care about, since code size can obviously vary between, say, CISCs and
RISCs.  That's definitely not convenient.

Another approach is to start afresh with a new, larger buffer when the
initial buffer turned out to be too small.

> Or perhaps, some technique to chain buffers together and auto-insert a
> jmp to the next buffer address when the current buffer is full?

That's another possibility.  It makes code generation faster, compared
to reallocating a new buffer and restarting from scratch, but it might
be cache-unfriendly.

Also, whatever strategy you choose, you may have to check every few
lightning instructions whether your code buffer is "getting full" [0]...

That's pretty annoying, indeed.

I'm wondering whether others have better strategies.  Paolo?

Thanks,
Ludovic.

[0] http://lists.gnu.org/archive/html/lightning/2005-08/msg00007.html





reply via email to

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