-
Notifications
You must be signed in to change notification settings - Fork 738
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
Add TR_J2IVirtualThunkPointer relocation kind #2874
Conversation
Marked WIP because this depends on eclipse-omr/omr#2965 |
@dsouzai @mstoodle Would you mind reviewing? This goes with #2875 and eclipse-omr/omr#2965 |
@irinarada FYI |
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.
LGTM
@@ -740,7 +756,9 @@ uint32_t J9::ARM::AheadOfTimeCompile::_relocationTargetTypeToHeaderSizeMap[TR_Nu | |||
0, // TR_NativeMethodAbsolute = 56, | |||
0, // TR_NativeMethodRelative = 57, | |||
16, // TR_ArbitraryClassAddress = 58, | |||
28 // TR_DebugCounter = 59 | |||
28, // TR_DebugCounter = 59 | |||
0, // TR_ClassUnloadAssumption = 60 |
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.
is TR_ClassUnloadAssumption supposed to be in this pull request?
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 see, you're also co-dependent on #2672 (one of you will conflict with whichever is merged first :) ).
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.
TR_ClassUnloadAssumption
is an existing TR_ExternalRelocationTargetKind
with value 60. It wasn't in the size tables previously because it's not for AOT:
TR_ClassUnloadAssumption = 60, // this should not be used in AOT relocations
I need to specify a value there in order to get to index 61 (TR_J2IVirtualThunkPointer
).
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's not for AOT, but the relocations are still external ones used for JIT as a Service which means the size entries will need to be set appropriately (just not as part of this PR :) ). I'm fine with them being set to zero here unless, of course, #2672 is merged first.
I have to express some regret that this solution is convoluting an already convoluted thing more than it really should be. I would have preferred to evolve this code in a direction of simplicity. Let me elaborate a little bit. TR_Thunks is currently "over optimized" in my opinion in that performs a constant pool relocation as well as the work required to relocate the thunk. On top of that, it reads the cpIndex out of the code cache rather than having cpIndex as an element in the relocation record. We should really evolve TR_Thunks to only relocate the thunk, and create a TR_ConstantPool relocation to relocate the constant pool. Then we would have introduced a new relocation to accomplish the relocation needed here. I've spoken offline with @jdmpapin and I believe we're in agreement on this general approach being a better way forward. Sadly, that's too much work to get this done in time for our impending 0.10 release. So, I will (reluctantly but pragmatically) review this code as-is even though it's not the generally agreed upon right way forward. @jdmpapin can I ask you to open an issue to detail the improved design so that we do not lose track of this work, and I'll review. It would be awesome to see that correction made in time for 0.11, but its timeline isn't all that far away either, so I could be convinced we shouldn't muck with it until after 0.11 goes out the door. |
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.
Mostly looks very good, but I'd like to see that assert and I think you need to implement TR_RelocationRecordJ2IVirtualThunkPointer::preparePrivateData()
@@ -740,7 +756,9 @@ uint32_t J9::ARM::AheadOfTimeCompile::_relocationTargetTypeToHeaderSizeMap[TR_Nu | |||
0, // TR_NativeMethodAbsolute = 56, | |||
0, // TR_NativeMethodRelative = 57, | |||
16, // TR_ArbitraryClassAddress = 58, | |||
28 // TR_DebugCounter = 59 | |||
28, // TR_DebugCounter = 59 | |||
0, // TR_ClassUnloadAssumption = 60 |
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 see, you're also co-dependent on #2672 (one of you will conflict with whichever is merged first :) ).
TR_RelocationTarget *reloTarget, | ||
uint8_t *reloLocation, | ||
void *thunk) | ||
{ |
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'd stick an assert here that thunk != NULL
just for completeness
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.
Assertion added
// J2I thunk pointer, but rather the location of the constant pool address. | ||
// Find the J2I thunk pointer relative to that. | ||
auto recordData = (TR_RelocationRecordJ2IVirtualThunkPointerBinaryTemplate *)_record; | ||
reloLocation += recordData->_offsetToJ2IVirtualThunkPointer; |
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 think you're missing the preparePrivateData()
code here....nothing sets _offsetToJ2IVirtualThunkPointer from the binary relocation data, does it? Or did I miss it?
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.
Doesn't _record
point into the binary relocation data? I do get the correct offset (when I run with the further change in #2875)
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.
Ok, I was mis-remembering (and didn't read your code well enough :( ) this part of the code, so my apologies for the wrong suggestion.
You do not need to use the private relo data for this particular case. But you do need to use the reloTarget
to access the value out of the binary reloRecord. You should define something like TR_RelocationRecordJ2IVirtualThunkPointer::offsetToJ2IVirtualThunkPointer(TR_RelocationTarget *reloTarget)
(akin to TR_RelocationRecordConstantPoolWithIndex::cpIndex(TR_RelocationTarget *reloTarget)
to fetch the value out of the reloRecord using an appropriate function from reloTarget.
The reason to consistently use the reloTarget is so that we have a hope to deal with endian issues if we ever cross compile (which, for the record, may be something we are drawn towards once the JIT as a Service work matures).
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.
Updated to define and call a helper method that uses reloTarget
to read _offsetToJ2IVirtualThunkPointer
*(uintptrj_t *)cursor = (uintptrj_t)info->data1; // constantPool | ||
cursor += SIZEPOINTER; | ||
|
||
*(uintptrj_t *)cursor = (uintptrj_t)info->data3; // offset to J2I virtual thunk pointer |
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.
Ah, the good ol' data1
, data2
, data3
field names. I definitely agree with @mstoodle we need an overhaul in this area of the code. This seems like too much work just to add a pointer relocation.
This relocates a J2I (JIT to interpreter) virtual thunk pointer along with a nearby constant pool address and index. The relocation is necessary because with nestmates, the data consumed by PicBuilder now contains a J2I thunk pointer, which is used for direct dispatch in case the callee has not yet been compiled. No such relocations are created yet. That will be done in each code generator's call snippet code. Signed-off-by: Devin Papineau <devinmp@ca.ibm.com>
3b66171
to
0da7fa8
Compare
Removed WIP now that eclipse-omr/omr#2965 has been merged |
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.
LGTM. Thanks, @jdmpapin ! Just need to run the tests before we merge...
@andrewcraik has graciously agreed to usher this PR the rest of the way, since I will not be able to keep a very close eye on it for the next little while. Thanks, Andrew! |
Jenkins test sanity xlinux,win jdk11 |
travis failed due to the il change that depended on #2649 which has been merged now to resolve the failure |
JDK11 windows fails look to be existing known issues/unrelated to this change |
JDK11 Linux fails look to be existing known issues/unrelated to this change |
Given the failures are unrelated/known issues I'll merge this now to unblock other changes (eg #2875) |
This relocates a J2I (JIT to interpreter) virtual thunk pointer along
with a nearby constant pool address and index. The relocation is
necessary because with nestmates, the data consumed by PicBuilder now
contains a J2I thunk pointer, which is used for direct dispatch in case
the callee has not yet been compiled.
No such relocations are created yet. That will be done in each code
generator's call snippet code.