Arrays now implement "Arrayish"

John Rose john.r.rose at oracle.com
Thu Apr 28 17:39:08 UTC 2016


This is great work. Thanks for making it happen. 

– John

> On Apr 27, 2016, at 5:52 AM, David Simms <david.simms at oracle.com> wrote:
> 
> Greetings,
> 
> I've just pushed a set of changes to enable all arrays to implement the "java.lang.Arrayish" interface:
> 
>   public interface Arrayish<any T> extends Cloneable,
>   java.io.Serializable {
>        int arraySize();
>        T arrayGet(int index);
>        void arraySet(int index, T element);
>   }
> 
> Thanks to John Rose for the original patch, which I have adapted somewhat.
> 
> How does it work ?
> 
> * "Klass->extra_super()" contains an optional "InstanceKlass*"
>   pointer, which all array klasses have set to their appropriate
>   Arrayish, i.e.:
>     o int[] extra_super() = "Arrayish<int>"
>     o Object[] extra_super() = "Arrayish"
> * Classes used as "extra_super" must currently be interfaces, and have
>   their own "self itable" generated at load time.
> * The extra_super mechanism allows the "Arrayish" interface to be
>   injected during JVM start-up, but after the basic array types need
>   to be initialized
> * "extra_super()" is used when, checkcast/instanceof and looking up
>   interface methods
> * See jtreg test: "hotspot/runtime/valhalla/arrays/ArrayTypes.java"
> 
> 
> This is a prototype, there are caveats (and dragons):
> 
> * The current "Model 3" implementation uses a specializer written in
>   Java, for bootstrapping the Arrayish specializations, these are
>   currently built at JDK compile time (placed
>   "$JAVA_HOME/valhalla-prespecialized")
>     o There is no support yet for double slot types (double and long,
>       and hence their arrays)
>     o These classes are specific to the JVM runtime, and must not be
>       seen by "javac" ( "VALHALLA_PRESPECIALIZED_DIR" is known to the
>       classloader implementation, but not the classpath).
> * x86 32 & 64 bit architectures only at this point
>     o arrays on other architectures will simply not implement "Arrayish"
> * Nothing about this implementation is set in stone, prototype code
>   and quality (piggy-backing on these changes, then ymmv)
> * The type hierarchy for arrays will no doubt continue to be in flux
> 
> 
> Cheers
> /David Simms
> 




More information about the valhalla-dev mailing list