"libffi closures"?

Andrew Haley aph@redhat.com
Thu May 8 14:15:00 GMT 2003


Ranjit Mathew writes:
 > > I get the same.  The failing test here was written since SPARC closures
 > > were added to libffi.
 > 
 > This might be a very dumb question to ask but I guess asking
 > a dumb question is better than nodding in apparent comprehension
 > and completely missing the significance: what *are* libffi
 > closures and why is it such a big deal when a target gets
 > them?
 > 
 > I *vaguely* remember closures from my undergrad days and
 > this page seems to agree with my memories:
 > 
 > http://research.microsoft.com/vault/learn/tutorial/closures.htm
 > 
 > but how exactly are they significant for GCJ? I mean,
 > without closures what does a target lack?

They're critical.  libffi closures allow you to define an interpreted
function and then call that function as though it were machine code,
via a single pointer.  That is, for every interpreted routine there is
a unique machine address that, when called, invokes the interpreted
routine.

Because of this, when an interpreted Java app invokes a method, the VM
does not need to distinguish between calling an interpreted method and
calling a compiled method.

 > Is there much voodoo involved in implementing closures 
 > for a target that most initial ports of GCJ for a target
 > come without it?

It's rather voodoo, yes.

Andrew.



More information about the Java mailing list