This is the mail archive of the mailing list for the Java project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: New C++ ABI: patches.

Tom Tromey <> writes:

> The compiler can generate constant primitive arrays statically, which
> means that the array class and its vtable must have a static name.

An alternative would be to generate code to back-patch the vtable
pointer at class load or init time, but it is much cleaner to just
use a static name for the array class vtable.

Note that at some point it would be nice to statically allocate static
non-primitive arrays as well.  To do that we could either do back-patching,
or we could use the magic linker mentioned in a previous post.  (I.e.
the compiler emits an undefined reference to the vtable;  the linker
generates the array class and its vtable on demand.  When using a
dynamic linker, the latter would have to have a call-back allowing
an application to satisfy unknown symbols.)

It alsos mays sense to pre-allocate static final objects allocated
with a new expression.  I.e. compile:

  static final Pair xy = new Pair(x, y);


  foo_Pair _xy = {0, 0};
  static { _xy.<init>(x, y); Pair.xy = &_xy; }

or if Pair.<init> can be inlined and x and y are constant plain:

  foo_Pair _xy = {x, y};
  static { Pair.xy = &_xy; }
	--Per Bothner

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]