-
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
Implement MethodHandleNatives native code #10690
Implement MethodHandleNatives native code #10690
Conversation
5b0e0d3
to
ac41c0b
Compare
I've noticed that |
ac41c0b
to
152ecf0
Compare
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 reviewed about 1/2 this before stopping as I need more context on what the operations are expected to do.
A good next step would be to document each of the functions so it's clear what the expected behaviour is
e6878d7
to
e6640a0
Compare
Thanks for the review @DanHeidinga, I will add documentation comments for the function to provide details on the expected behavior |
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 have updated the code to include a function header that describe the expected behavior of each function and added comments to large code block to make it more readable. Also fixed some formatting issues.
While I was updating the comments, I realized there are more potential places where GC could occur and invalidate the native object reference. I will push the fix for these (either refetch the data or push objects to special frame) once local testing passed
7d72fc2
to
5e4fda0
Compare
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.
Taking a break for lunch. Will pick up the review from sigForPrimitiveOrVoid
later
runtime/jcl/uma/java_lang_invoke_MethodHandleNatives_exports.xml
Outdated
Show resolved
Hide resolved
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.
@fengxue-IS there's a lot of feedback here already so I'll stop reviewing at this point.
Please look at all the allocations and check for allocations failures. Figuring out how to report that back to the callers will help clarify your apis.
It's also good to minimize the lifetimes of every fetched object so they are less likely to be lost by a GC. It'll also make the code easier to reason about
Thanks @DanHeidinga for the indepth review, I will look into the issues pointed out and also go through all the allocation codes to make sure to check for any potential failures. |
687afaa
to
51f67c5
Compare
@DanHeidinga can you take another look please |
Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
- use reflect object's name/type/signature field instead of constructing new object - fill in name/signature for method/constructor rather than lazily computing during resolve - idFromReflectObject can't fail as long as the object is not null Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
- expand reflectFunctions table - reflectFunctions->createFieldObject Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
- replace copyStringToUTF8Helper with copyStringToUTF8WithMemAlloc - add MN_CALLER_SENSITIVE check - add OOM checks and exit with goto - throw and handle nativeOOMError - fix all missing Error checking and refetch after any GC point - fix tracepoint modifiers - fix use of bool in c code - fix declaration skipped by goto Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
- use Class.classNameString if possible - check if arrayClass to set proper classNameString format Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
15eaf9e
to
a7bf780
Compare
Fix all issues in review comments, local build passed |
- create common helper for setCallSiteTargetNormal & setCallSiteTargetVolatile - add static keyword for helper functions - fix array store index Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
Addressed review comments, local compile/basic testing passed. |
UDATA offset = (UDATA)vmFuncs->instanceFieldOffset(currentThread, J9VM_J9CLASS_FROM_HEAPCLASS(currentThread, callsiteObject), (U_8*)"target", strlen("target"), (U_8*)"Ljava/lang/invoke/MethodHandle;", strlen("Ljava/lang/invoke/MethodHandle;"), NULL, NULL, 0); | ||
MM_ObjectAccessBarrierAPI objectAccessBarrier = MM_ObjectAccessBarrierAPI(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.
This seems like a good candidate to put these in the VMConstantpool
I don't see any holes where objects will be lost now so I'm OK with proceeding with this change. Having said that, I'm not 100% onboard with this approach. The heavy string allocation and copying should be looked at again to see if there's a better way to solve this. Given the other up-calls to the VM, I'd be tempted to implement this in Java and cache the signature per MT to make this cleaner. All that can wait for a later PR though. |
Jenkins test sanity xlinux jdk16 |
Jenkins test sanity xlinux jdk8,jdk11 |
Thanks for the suggestions Dan, I have added this to the TODO list (#11443) to be investigated later |
Related: #7352
Co-authored-by: Babneet Singh sbabneet@ca.ibm.com
Signed-off-by: Jack Lu Jack.S.Lu@ibm.com