-
Notifications
You must be signed in to change notification settings - Fork 778
Add implementation for JVM_CopyOfSpecialArray #23007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Please open a pull request to remove test/jdk/java/lang/invoke/BigArityTest.java from https://github.com/adoptium/aqa-tests/blob/master/openjdk/excludes/ProblemList_openjdkvalhalla-openj9.txt once this change is merged. |
runtime/j9vm/valhallavmi.cpp
Outdated
| { | ||
| assert(!"JVM_CopyOfSpecialArray unimplemented"); | ||
| return NULL; | ||
| j9object_t origObj; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize these variables to null or 0.
| J9VMThread *currentThread = (J9VMThread *)env; | ||
| J9InternalVMFunctions *vmFuncs = currentThread->javaVM->internalVMFunctions; | ||
| vmFuncs->internalEnterVMFromJNI(currentThread); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the extra space.
runtime/j9vm/valhallavmi.cpp
Outdated
| vmFuncs->internalEnterVMFromJNI(currentThread); | ||
|
|
||
|
|
||
| if (orig == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When comparing a variable to a constant put the constant on the left as per our coding standards.
runtime/j9vm/valhallavmi.cpp
Outdated
|
|
||
| if (NULL == orig) { | ||
| vmFuncs->setCurrentException(currentThread, J9VMCONSTANTPOOL_JAVALANGNULLPOINTEREXCEPTION, NULL); | ||
| vmFuncs->internalExitVMToJNI(currentThread); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having multiple return points that need to make this call I recommend jumping to a label similar to what is done in newArrayHelper in this file.
runtime/j9vm/valhallavmi.cpp
Outdated
| } | ||
| origObj = J9_JNI_UNWRAP_REFERENCE(orig); | ||
| origClass = J9OBJECT_CLAZZ(currentThread, origObj); | ||
| componentClass = ((J9ArrayClass *)origClass)->leafComponentType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see that the componentClass is used anywhere.
| origClass = J9OBJECT_CLAZZ(currentThread, origObj); | ||
| componentClass = ((J9ArrayClass *)origClass)->leafComponentType; | ||
| origLength = J9INDEXABLEOBJECT_SIZE(currentThread, origObj); | ||
| if (from < 0 || to > (jint)origLength || from > to) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add parenthesis around each statement.
| componentClass = ((J9ArrayClass *)origClass)->leafComponentType; | ||
| origLength = J9INDEXABLEOBJECT_SIZE(currentThread, origObj); | ||
| if (from < 0 || to > (jint)origLength || from > to) { | ||
| vmFuncs->setCurrentException(currentThread, J9VMCONSTANTPOOL_JAVALANGARRAYINDEXOUTOFBOUNDSEXCEPTION, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the ri throw ArrayIndexOutOfBoundsException for from > to as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It throws IllegalArgumentException if from >= to. Will change it.
| JNIEXPORT jarray JNICALL | ||
| JVM_CopyOfSpecialArray(JNIEnv *env, jarray orig, jint from, jint to) | ||
| { | ||
| assert(!"JVM_CopyOfSpecialArray unimplemented"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed there is a copyFlattenableArray method in ValueTypeHelpers.hpp. Can this method be reused here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that the copyFlattenableArray method can’t be used here because it requires a special Valhalla stack frame to be built before the call. I’m not sure how the frame could be constructed from here.
Related: eclipse-openj9#22642 Add the implementation for method JVM_CopyOfSpecialArray
Related: #22642
Add the implementation for method JVM_CopyOfSpecialArray
With this change
test/jdk/java/lang/invoke/BigArityTest.javapasses.