[erlang-questions] Compiling functions returning large ground tuples

Bjorn Gustavsson bgustavsson@REDACTED
Tue Feb 3 08:35:58 CET 2009

On Tue, Feb 3, 2009 at 6:22 AM, Richard O'Keefe <ok@REDACTED> wrote:
> I was enchanted to discover that the Mercury (strongly statically
> typed and moded logic programming with Clean-like uniqueness typing)
> system has an Erlang back-end.
> I was less enchanted to discover that its originators
> "lost interest", mainly because they needed to generate
> functions that return large ground tuples.  In a message
> today, they said "those tuples (which can be rather large)
> would be reconstructed each time the function was called.
> HiPE was better, but (I think at that time) tuples
> containing binaries wouldn't be statically allocated."
> I though the default compiler now generated code to make
> static copies of large ground terms.  Was I mistaken about
> that?  Did HiPE ever/does it now have any problem
> generating static copies of large ground terms containing
> binaries?

I am not exactly sure what you mean with "ground term".

In R12B, constant terms (for instance, {a,b,c,[e,f,g]} or {a,<<1,2,3>>})
will be stored in a constant pool and not reconstructed every time.
That includes binaries. (The same mechanism is used for both
BEAM code and native code.)

Before R12B, I don't think binaries were treated as constants
by the HiPE compiler.

Björn Gustavsson, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list