-
Notifications
You must be signed in to change notification settings - Fork 721
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
JEP-370 Implementation (Part 2) #8414
Conversation
How to run JEP370 tests?
|
fb67385
to
7252558
Compare
JEP370 Tests SummaryLog output after running the JEP370 tests: jep370_tests8.log There are two kinds of failures, which are seen repeatedly:
Test source code: TestVarHandleCombinators.testByteOrderLE
This is related to the difference in operations class. In OpenJ9, the VarHandle argument is the last argument. In OpenJDK, the VarHandle argument is the first argument. I updated few dependencies in order to account for both scenarios. I will need help in identifying the missed dependencies. @DanHeidinga @tajila
The MemoryAddress VarHandle classes are generated dynamically during runtime with ASM. class AddressVarHandleGenerator generates the MemoryAddress VarHandle classes. It adds an accessor method to access the |
For Also, what is the methodType for the "set" MH in the in the VarForm |
In |
7252558
to
19f5fe2
Compare
VM_MHInterpreter::dispatchLoop has the JEP370 has 14 test-suites, which comprise of 95 test-cases in total. With this pull request, 85 test-cases pass and 10 test-cases fail. The latest log output after running the JEP370 tests: jep370_tests9.log. There are two unique failures in the 10 failing test-cases:
Test source code: TestByteBuffer.testScopedBufferAndVarHandle. We need to throw
I feel that these failures are related to something missing in constant pool patching. @fengxue-IS can you verify? |
19f5fe2
to
8f4d3ac
Compare
Will test this locally to verify cpPatching related issues |
Update: @fengxue-IS fixed constant pool patching to resolve Two pending issues:
fyi @DanHeidinga @tajila |
78a8f15
to
fe3507e
Compare
Update: In the header description, the new commits 6 and 7 resolve the following issue:
Only one kind of failure remains:
@DanHeidinga I feel confident about this direction for JEP370. @fengxue-IS's constant pool changes work and only one kind of failure remains. Instead of working on the alternate solution, I will prioritize fixing the one remaining failure? Meanwhile, we can start merging ibmruntimes/openj9-openjdk-jdk14#6, #8330, @fengxue-IS's constant pool changes and this pull request? I will account for the one remaining failure in a separate pull request. |
+1 this approach. |
fe3507e
to
f5978d5
Compare
jcl/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
Outdated
Show resolved
Hide resolved
jcl/src/java.base/share/classes/java/lang/invoke/VarHandle.java
Outdated
Show resolved
Hide resolved
8084315
to
75a8afb
Compare
This looks OK to me. We'll need to figure out the delivery plan for this and parts 1 & 3 + @fengxue-IS's cp patch PRs |
Delivery plan: D1. #8330 (Part 1) depends on ibmruntimes/openj9-openjdk-jdk14#6 The changes can be delivered in the above order. The first two items need to be delivered together. |
@babsingh can you rebase this? The prereqs have been merged now |
BasicType.basicType takes a class as input and outputs the corresponding BasicType enum value depending on the class's basic type char. The class's basic type char is derived using the sun.invoke.util.Wrapper class. Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
The method passed in the constructor, MemberName(Method method), is cached in the MemberName instance. Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
AccessMode.methodNameToAccessMode is a HashMap<String, AccessMode>, where the key is the method name and the value is the AccessMode enum value. This hashmap is used in AccessMode.valueFromMethodName to retrieve the AccessMode enum value for the corresponding method name. It is also directly accessed from VarForm.linkFromStatic. It is needed so that OpenJ9 can consume OpenJDK's VarForm class. Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
75a8afb
to
2635bb5
Compare
In this constructor, fieldType, coordinateTypes, handleTable and modifiers are initialized using the VarForm class. This should allow us to consume OpenJDK's VarHandles with OpenJ9's VarHandle class as the base class. Currently, it will only be used for OpenJDK's MemoryAddress VarHandles. Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
2635bb5
to
28cbd71
Compare
@DanHeidinga rebased. |
OpenJDK VarHandle operation methods have the following parameter sequence: {VarHandle, Receiver, Intermediate ..., Value}. During invocation, OpenJ9 uses the following parameter sequence for the VarHandle operations: {Receiver, Intermediate ..., Value, VarHandle}. The location of the VarHandle argument is different in the above two cases. MethodHandles.permuteArguments is used to translate from the OpenJ9 to OpenJDK invocation. Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com> Co-Authored-By: Tobi Ajila <atobia@ca.ibm.com>
AccessType.accessModeType is implemented to retrieve the receiver class from the derived VarHandle class since VarForm does not provide the exact receiver class. In VarForm, the receiver class is always java.lang.Object. Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
a90fba7
to
cc6d0fa
Compare
When the AccessMode methods have the receiver class defined generically or as java.lang.Object in the derived VarHandle classes, then the handleTable needs to be initialized with the exact method types, which will be used during invocation of the AccessMode methods. The exact method types need to specify the actual receiver class. This change yields correct behavior with respect to WrongMethodTypeException and ClassCastException. Without this change, ClassCastException is thrown when WrongMethodTypeException is expected. Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
cc6d0fa
to
604dd59
Compare
Jenkins test sanity zlinux jdk11,jdk14 |
@babsingh Can you open a PR for this against the 0.19.0 release branch? |
And also rebase #8501 so it's ready for review? |
Related: #8292.
This pull request has commits from and is dependent on #8330 and #8369.
The top seven commits are new, and they are described below.
Files changed
will show all the commits. So, individually refer to the new commits in order to review the changes specific to this pull request.1. Implement
LambdaForm.BasicType.basicType(Class<?> cls)
BasicType.basicType
takes a class as input and outputs the correspondingBasicType
enum value depending on the class's basic type char. Theclass's basic type char is derived using the
sun.invoke.util.Wrapper
class.
2. Implement the constructor
MemberName(Method method)
The
method
passed in the constructor,MemberName(Method method)
, iscached in the
MemberName
instance.3. Initialize
AccessMode.methodNameToAccessMode
(HashMap
)AccessMode.methodNameToAccessMode
is aHashMap<String, AccessMode>
,where the key is the
method name
and the value is theAccessMode
enumvalue. This hashmap is used in
AccessMode.valueFromMethodName
toretrieve the AccessMode enum value for the corresponding method name. It
is also directly accessed from
VarForm.linkFromStatic
. It is needed sothat OpenJ9 can consume OpenJDK's VarForm class.
4. Implement constructor
VarHandle(VarForm varForm)
In this constructor,
fieldType
,coordinateTypes
,handleTable
andmodifiers
are initialized using theVarForm
class. This should allow usto consume OpenJDK's VarHandles with OpenJ9's
VarHandle
class as thebase class. Currently, it will only be used for OpenJDK's
MemoryAddress
VarHandles.
5. Handle conversion from OpenJDK to OpenJ9 VarHandle operation methods
OpenJDK VarHandle operation methods have the following parameter
sequence:
{VarHandle, Receiver, Intermediate ..., Value}
.During invocation, OpenJ9 uses the following parameter sequence for the
VarHandle operations:
{Receiver, Intermediate ..., Value, VarHandle}
.The location of the
VarHandle
argument is different in the above twocases.
MethodHandles.permuteArguments
is used to translate from theOpenJ9 to OpenJDK invocation.
6. Implement VarHandle.AccessType.accessModeType
AccessType.accessModeType
is implemented to retrieve the receiver classfrom the derived
VarHandle
class sinceVarForm
does not provide theexact receiver class. In
VarForm
, the receiver class is alwaysjava.lang.Object
.7. Initialize VarHandle.handleTable with exact method types
When the
AccessMode
methods have the receiver class defined genericallyor as
java.lang.Object
in the derivedVarHandle
classes, then thehandleTable
needs to be initialized with the exact method types, whichwill be used during invocation of the
AccessMode
methods. The exactmethod types need to specify the actual receiver class. This change
yields correct behavior with respect to
WrongMethodTypeException
andClassCastException
. Without this change,ClassCastException
is thrownwhen
WrongMethodTypeException
is expected.Signed-off-by: Babneet Singh sbabneet@ca.ibm.com