copy elimination for tuples
Wed Mar 17 20:06:23 CET 2004
On Wed, 17 Mar 2004, Vlad Balin wrote:
> I'm interested in copy elimination optimization for tuples. As far as I
> know, this feature has not been implemented yet. Is there any specific
> reason or considerations? Have anyone tried to do that?
The main obstacle is that the garbage collector currently requires
that there are no pointers from an older generation to a younger one.
This means that you can only "zap" fields in a tuple if you have full
control of where the tuple is located. For instance, a tuple that
was created only a few steps earlier (even in the same function) may
have already been moved to an older generation if a GC was triggered
between the two program points. So it is not enough to know that the
tuple will not be needed in its old form when you do a "setelement".
Currently, some destructive updating of tuple fields is introduced when
it is certain that there will be no GC; this typically happens in the
code generated to create tuples when the "record syntax" is expanded.
Note that this is a compiler optimization only - the destructive
setelement operations cannot be accessed from normal Erlang code.
Richard Carlsson (richardc@REDACTED) (This space intentionally left blank.)
E-mail: Richard.Carlsson@REDACTED WWW: http://user.it.uu.se/~richardc/
"Having users is like optimization: the wise course is to delay it."
-- Paul Graham
More information about the erlang-questions