New C++ ABI: patches.

Per Bothner per@bothner.com
Tue Jan 9 10:53:00 GMT 2001


Tom Tromey <tromey@redhat.com> 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);
as
 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
per@bothner.com http://www.bothner.com/~per/


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /