-
Notifications
You must be signed in to change notification settings - Fork 720
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
WIP: Add code to patch unresolved trampolines for x86-64 #11426
base: master
Are you sure you want to change the base?
Conversation
@mpirvu I'm having trouble putting |
; Call to adjust trampoline reservations, since this callsite is now resolved | ||
mov edx, dword [rsi+20] | ||
push rdx ; descriptor+24: CP index | ||
mov rdx, qword [rdi + J9TR_MethodFlagsOffset] |
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.
Shouldn't this be mov rdx, dword [rsi+12]
to get to the cpAddr?
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 is, but this also works, because %rdi
is the J9Method
addres.s and J9TR_MethodFlagsOFfset
is the offset to constant pool from start of J9Method
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.
mov edx, dword [rsi+20]
looks ok to me and I have no clue why the address is invalid.
Is it always invalid, or only in some particular cases? maybe you could trace it instruction by instruction using the debugger and see how registers change
Ok, I see why this is not working. We call |
A way to fix this would be to perform trampoline patching from callers of |
I was wrong, we can't just patch trampoline from callers of |
Here is a possible solution: store |
Shouldn't the trampoline reservation happen at the point where method is discovered as resolved? |
The new code doesn't reserve trampolines, it replaces unresolved trampoline entry with resolved one at the point where the corresponding method becomes resolved. So we can't put the new code in unresolved routines, since in many cases there is no resolved trampoline entry yet. |
e031840
to
41e68c2
Compare
But the call to the helper in the new code can delete the unresolved trampoline and create a new resolved trampoline. |
41e68c2
to
e9b895e
Compare
Alright, so implementing it according to @mpirvu's advice seems to solve the issue. Looking at stack traces, this is the only thread that's doing anything:
|
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.
The assembly code looks right to me
b1e1c1d
to
cd95d69
Compare
Previously, we didn't have JITServer specific code for handling method trampoline reservations because we assumed that all methods can be called without trampolines. This is true for x86, where code repository is enabled by default, but leads to crashes on Power. There are 2 types of method trampolines: resolved and unresolved, corresponding to the types of method calls they enable. In baseline JIT compilation (no JITServer, no AOT) we reserve trampolines during codegen and they are patched during method execution. However, for AOT and JITServer reservation during codegen would not work, since compiled code is executed by a different VM that doesn't have trampolines reserved. AOT uses 2 relocation types to handle this: 1. For unresolved trampolines, we create a `TR_Trampolines` relocation. This relocation is also added for JITServer compilations so this case is already handled. 2. For resolved trampolines, AOT only allows their use (and thus resolved call dispatch) when SVM is enabled because `TR_ResolvedTrampolines` relocation requires SVM. This is a problem for JITServer, since non-AOT compilations do not use SVM and we don't want to use unresolved dispatch for every call. This commit keeps track of methods for which resolved trampoline is needed during compilation on the server and sends the list to the client at the end of the compilation. Once the client receives compiled method and allocates code cache, it will reserve trampolines. Signed-off-by: Dmitry Ten <Dmitry.Ten@ibm.com>
Signed-off-by: Dmitry Ten <Dmitry.Ten@ibm.com>
cd95d69
to
5d8b02a
Compare
Can one of the admins verify this patch? |
No description provided.