Status update: generic specializer
Paul Benedict
pbenedict at apache.org
Mon Aug 25 21:04:30 UTC 2014
Thanks Brian. I've been curious if there is a reason, beyond the extensive
use of memory, that the specializer couldn't be use to reifiy any
generalized classes (by opt-in of course). That doesn't seem to be a step
much further off once you have TypeVariablesMap existing. How wrong am I in
this assessment?
Cheers,
Paul
On Mon, Aug 25, 2014 at 3:36 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
> We've gotten the generic specializer to a point where it can do quite a
> lot; I've pushed code to the jdk/ repo so that specialization now can
> happen on the fly through classloading hacks.
>
> Maurizio has already posted details on the compiler part of the
> implementation. To opt into specialization, decorate a specializable type
> variable with the "any" modifier:
>
> class Box<any T> {
> T element;
>
> Box(T t) { this.t = t; }
>
> T get() { return t; }
>
> void set(T t) { this.t = t; }
> }
>
> When used as a raw type, or with reference types as the instantiation of
> T, things will behave exactly as before. When used with primitive
> instantiations of T, a new class will be specialized on the fly when
> needed, rewriting T to its specialized value in interface and
> implementation.
>
> There are *many* limitations. But, it is at the point where a lot of
> things work already, and people may well want to play with it, and you
> should be able to just use javac and java from the valhalla build and do
> some reasonable simple things with specialized classes.
>
> Next up: specializing ArrayList<int>.
>
> Have fun!
>
More information about the valhalla-dev
mailing list