eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.27k stars 720 forks source link

Add implementation for new JNI functions in Valhalla #19460

Closed hangshao0 closed 3 weeks ago

hangshao0 commented 4 months ago

There are 3 new JNI functions added in Valhalla:

JNIEXPORT jboolean JNICALL
JVM_IsImplicitlyConstructibleClass(JNIEnv *env, jclass cls)

JNIEXPORT jboolean JNICALL
JVM_IsNullRestrictedArray(JNIEnv *env, jobject obj)

JNIEXPORT jarray JNICALL
JVM_NewNullRestrictedArray(JNIEnv *env, jclass cls, jint length)

OpenJ9 needs to add implementation for them.

  1. Support for JVM_IsImplicitlyConstructibleClass() We just need to check the ImplicitCreation attribute added in https://github.com/eclipse-openj9/openj9/issues/17234

  2. Support for JVM_IsNullRestrictedArray() and JVM_NewNullRestrictedArray() Currently, each J9Class has a pointer to its arrayClass and J9arrayClass has a pointer to leafComponentType. We need to create 2 array classes for null-restricted value type. One nullable array class and one null restricted array class. The exiting J9Class->arrayClass can be used as nullable arrayClass. We can create a new field in J9Class called nullrestrictedArrayClass, and let it point to null restricted array class(which is created by JVM_NewNullRestrictedArray()). We can use a bit in J9ArrayClass->classFlags to indicate if it is null restricted array (prohibiting storing null to its element). The implementation of JVM_IsNullRestrictedArray() can check this bit. The implementation of JVM_NewNullRestrictedArray() might follow the example JVM_NewArray().

hangshao0 commented 4 months ago

@theresa-m

theresa-m commented 3 months ago

Before closing this issue please re-enable ValueTypeSystemArraycopyTests, ValueTypeArrayTests and ValueTypeArrayTestsJIT in the functional/Valhalla test suite. They are disabled https://github.com/eclipse-openj9/openj9/pull/19646 due to reliance on these JNI functions.

theresa-m commented 3 weeks ago

Reopening since the fixing change was reverted https://github.com/eclipse-openj9/openj9/pull/20109