Skip to content

Patch addresses in LLILF/IIHF pairs on class unload and HCR - #15705

Merged
joransiu merged 1 commit into
eclipse-openj9:masterfrom
Spencer-Comin:compensate-split-address
May 12, 2023
Merged

Patch addresses in LLILF/IIHF pairs on class unload and HCR#15705
joransiu merged 1 commit into
eclipse-openj9:masterfrom
Spencer-Comin:compensate-split-address

Conversation

@Spencer-Comin

Copy link
Copy Markdown
Contributor

With eclipse-omr/omr#6596, LLILF/IIHF pairs can be used to hold 64 bit address constants in two 32 bit immediate fields. This commit adds logic to HCR and class unloading compensate functions to patch the split constants.

Also, in the case of 32 bit compressed class pointers stored in LLILF (without a following IIHF) the opcode is changed to LGFI when patched on class unload, so that the -1 patched over the address immediate is sign-extended rather than zero-extended.

@Spencer-Comin

Copy link
Copy Markdown
Contributor Author

A bit of an explanation/proof of concept for patching. For class unload, the class address is patched over with a -1 value. In the nocompressedrefs case, the 64 class pointer is placed in a LLILF/IIHF pair, and patching is as simple as patching the 32 bit immediate of both instructions with -1 (FFFF FFFF).

class unload nocompressedrefs
BEFORE:
0x3fb77146a46 {UnitTest.virtualCallTest} +80                c00f883ea700 llilf     %r0, 0x883ea700 
0x3fb77146a4c {UnitTest.virtualCallTest} +86                c008000003ff iihf      %r0, 0x3ff
AFTER:
0x3fb77146a46 {UnitTest.virtualCallTest} +80                c00fffffffff llilf     %r0, 0xffffffff 
0x3fb77146a4c {UnitTest.virtualCallTest} +86                c008ffffffff iihf      %r0, 0xffffffff

In the default compressed refs case, the class pointer is guaranteed to fit into 32 bits, so only an LLILF is needed. However, if the immediate is simply patched over with -1, the FFFF FFFF will get zero-extended to 0000 0000 FFFF FFFF rather than sign-extended to keep the -1 value. To fix this, the LLILF needs to be changed to LGFI.

class unload default
BEFORE:
0x3ff7388aa32 {UnitTest.virtualCallTest} +60                c00f00227500 llilf     %r0, 0x227500 MemBlk
AFTER:
0x3ff7388aa32 {UnitTest.virtualCallTest} +60                c001ffffffff lgfi      %r0, -1

For HCR, I could not come up with a unit test where the class address changes on reload. However, when stepping through the compensate function in gdb, the immediate location is patched to the same class address.

HCR default
BEFORE:
0x3ff80113d28 {redef/ClassRedefUnitTest.unitTest} +44                c00f0023ec00 llilf     %r0, 0x23ec00 Ptr
AFTER:
0x3ff80113d28 {redef/ClassRedefUnitTest.unitTest} +44                c00f0023ec00 llilf     %r0, 0x23ec00 Ptr

HCR nocompressedrefs
BEFORE:
0x3fb8f674d28 {redef/ClassRedefUnitTest.unitTest} +44                c00fa0404400 llilf     %r0, 0xa0404400 
0x3fb8f674d2e {redef/ClassRedefUnitTest.unitTest} +50                c008000003ff iihf      %r0, 0x3ff
AFTER:
0x3fb8f674d28 {redef/ClassRedefUnitTest.unitTest} +44                c00fa0404400 llilf     %r0, 0xa0404400 
0x3fb8f674d2e {redef/ClassRedefUnitTest.unitTest} +50                c008000003ff iihf      %r0, 0x3ff

As a sidenote, there might be room for improvement in HCR by skipping patching altogether when the class address doesn't change.

@r30shah

r30shah commented Aug 19, 2022

Copy link
Copy Markdown
Contributor

@Spencer-Comin Is this ready for review or there are some changes needed to be added on ? Also I see that on x86 and Z, we check if the Size is 4 and check the instructions if it is what you generated, can you verify if eclipse-omr/omr#6596 (comment) is actually an issue?

@Spencer-Comin
Spencer-Comin marked this pull request as draft August 22, 2022 15:02
@Spencer-Comin

Copy link
Copy Markdown
Contributor Author

I've marked this as draft while I investigate to see how we can avoid the bug @r30shah brought up in eclipse-omr/omr#6596 (comment)

@Spencer-Comin
Spencer-Comin force-pushed the compensate-split-address branch from 1084fd9 to 96e3a96 Compare March 6, 2023 19:03
@Spencer-Comin
Spencer-Comin marked this pull request as ready for review March 6, 2023 19:56
@Spencer-Comin

Copy link
Copy Markdown
Contributor Author

FYI @joransiu @r30shah

@r30shah r30shah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Spencer-Comin can you also run the sanity test on P and X (Reason being it touches the routines that are used by other code-gens as well.) Just for sanity, we should run the test on other platforms. Overall change looks good to me, besides that odd comment regarding to tab.

Comment thread runtime/compiler/runtime/ClassUnloadAssumption.cpp Outdated
LLILF/IIHF pairs can be used to hold 64 bit address constants in two 32
bit immediate fields. This commit adds logic to HCR and class unloading
compensate functions to patch the split constants.

Signed-off-by: Spencer Comin <spencer.comin@ibm.com>
@Spencer-Comin
Spencer-Comin force-pushed the compensate-split-address branch from 96e3a96 to 974844e Compare May 5, 2023 18:26
@Spencer-Comin

Copy link
Copy Markdown
Contributor Author

Passed sanity test on P, X, and Z

@r30shah r30shah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joransiu Can I request you to review and merge this PR?

@joransiu

Copy link
Copy Markdown
Member

jenkins test sanity xlinux,zlinux JDK17

@joransiu

Copy link
Copy Markdown
Member

The x86 sanity.functional cmdLineTester_criu_jitPostRestore failure is not related to this PR: #17367

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants