-
Notifications
You must be signed in to change notification settings - Fork 396
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
Fix calculation of XPLINK call descriptor offset #4154
Fix calculation of XPLINK call descriptor offset #4154
Conversation
Although this change is in OMR I have only been able to produce this bug via OpenJ9 since OMR does not support calling non-XPLINK targets. I'm attaching the test case suite to this comment below. It adapts the JNI tests found in [1] as a standalone since we need to compile the said tests with non-XPLINK linkage. In the ZIP file attached you may find both ASCII and EBCDIC logs of a sample of 4 method compilations which have different alignments modulo 8 for an exhaustive confirmation that the XPLINK offset descriptor is now encoded correctly. I'll copy/paste the relevant snippets here for the reviewer's convenience: nopLocationIs0Modulo8.trace.ascii:
nopLocationIs2Modulo8.trace.ascii:
nopLocationIs4Modulo8.trace.ascii:
nopLocationIs6Modulo8.trace.ascii (note the float parameter descriptor is properly encoded):
[1] https://github.com/eclipse/openj9/tree/master/runtime/tests/jniarg |
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.
In the 3rd paragraph of the commit message: "This is not something we can encoding with the existing locations" -> "existing relocations"?
The call descriptor offset in the NOP following a call within an XPLINK frame was not being correctly calculated. The patch location was correct, however the offset encoded was from the patch location, which is incorrect. As per the documentation linked in the source code the value we wish to encoding is a (positive) signed offset in doublewords from the doubleword at or preceding the return point (NOP) to the XPLINK call descriptor for this signature. This is not something we can encode with the existing relocations, and due to the doubleword alignment that is required it is not something that we should generalize either since we don't envision other uses for such a strict API. Instead we create a private relocation in the XPLINK linkage class and handle the relocation there. Signed-off-by: Filip Jeremic <fjeremic@ca.ibm.com>
d0f0416
to
6810584
Compare
…location failsafe Fail the compilation if we are unable to encode the distance to the XPLINKCallDescriptorSnippet. Signed-off-by: Filip Jeremic <fjeremic@ca.ibm.com>
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.
Good idea inheriting from ConstantDataSnippet. The changes LGTM. Thanks!
@genie-omr build zlinux,zos |
Use the already calculated offsetToCallDescriptor instead of recalculating it again. Signed-off-by: Filip Jeremic <fjeremic@ca.ibm.com>
6810584
to
6c0ad4f
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.
looks good to me
Commits well structured, only affects compiler on Z platform so Z testing is sufficient, code has been reviewed by two developers with Z background. Since @fjeremic can't merge it himself, I'll do it. Thanks, everyone! |
The fatal bug fixed in eclipse-omr/omr#4154 was not caught during automated testing because there currently do not exist JNI tests which are built with non-XPLINK (system) linkage. To prevent such obvious bugs from escaping into production we reuse the jniargtests and compile them with system linkage on z/OS 31-bit. We modify the existing Java test so it can run against custom native libraries, then we build two native libraries on z/OS, one with XPLINK which is already done today, and one with system linkage which will exercise callouts to non-XPLINK natives. Signed-off-by: Filip Jeremic <fjeremic@ca.ibm.com>
The call descriptor offset in the NOP following a call within an XPLINK
frame was not being correctly calculated. The patch location was
correct, however the offset encoded was from the patch location, which
is incorrect.
As per the documentation linked in the source code the value we wish to
encoding is a (positive) signed offset in doublewords from the
doubleword at or preceding the return point (NOP) to the XPLINK call
descriptor for this signature.
This is not something we can encoding with the existing locations, and
due to the doubleword alignment that is required it is not something
that we should generalize either since we don't envision other uses for
such a strict API. Instead we create a private relocation in the XPLINK
linkage class and handle the relocation there.
Signed-off-by: Filip Jeremic fjeremic@ca.ibm.com