-
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
Clean up J9HookDisable calls in the compiler #16960
Conversation
Signed-off-by: Irwin D'Souza <[email protected]>
@pshipton could you please review? |
Does this depend on something not yet merged or promoted? I don't find any J9_EVENT_CAN_BE_HOOKED. jenkins compile amac jdk11 |
I added |
@@ -25,4 +25,6 @@ | |||
|
|||
#include "omrhookable.h" | |||
|
|||
#define J9_EVENT_CAN_BE_HOOKED(javaVM, J9_EVENT_MASK) (J9_EVENT_IS_HOOKED(javaVM->hookInterface, J9_EVENT_MASK) || J9_EVENT_IS_RESERVED(javaVM->hookInterface, J9_EVENT_MASK)) |
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.
Why is this added to OpenJ9 rather than OMR?
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.
Partly to minimize the number of PRs needed, but also because usually if the name has J9
in it I try as much as possible to keep in the openj9 codebase. However, if you think I should move it to OMR I can do that and open that PR.
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 it should be in OMR. The macros J9_EVENT_IS_HOOKED and J9_EVENT_IS_RESERVED are defined in omrhookable.h
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, will do (pending GAC's blessing wrt the rest of the changes in this PR).
Has someone run this past @gacholio ? The interactions between various pieces of which hooks are disabled (or not) was IMHO subtle and finicky with GAC being the one most likely to remember why it was designed the way it was.... |
No I haven't run it past GAC; @gacholio do you know if these compiler changes have any unintended consequences? Because the VM has to still function normally if the compiler isn't loaded such as with |
I don't believe this is correct. It's important that the hooks be disabled - the JIT will generate code assuming that it doesn't need to support a hookable event. If the hook is not disabled, JVMTI will allow an agent to acquire capabilities which can not be supported by the compiled code. |
I do agree that the hooks should be disabled (and not left floating in an uninitialized state). However, aren't the calls to |
Example: The JIT says "I can't support the exception catch event/hook because the code generation is going to be optimized using throwToGoto", implemented by checking and disabling the related hook. If the -Xint case, the hook will simply not be disabled, allowing any agent to acquire the matching JVMTI capability. |
The JIT does inverse; it generates throwToGoto by default unless the hook is enabled, in which case it disables throwToGoto. It doesn't try to enforce an optimization by disabling a hook, at least not intentionally, and by that I mean: It is my understanding is that if JVMTI is enabled, then the agent needs to inform the VM of the capabilities it will want (even if it's late attach). If one of these capabilities is for example being informed about a exception catch, then |
This is not correct. Late attach agents request capabilties when they are loaded, so if you have not disabled the exception catch hook, the agent will be able to acquire the capability, but no compiled code that used throwToGoto would ever generate the hook call to report the event. |
Ah I understand. Well that complicates things for CRIU mode then... Thanks for explaining it, this is indeed very subtle. Thanks @DanHeidinga for word of caution. Closing this since this change is fundamentally wrong. |
The compiler uses
J9HookDisable
not to disable a hook but rather to check if the hook is disabled. However, this can have unintended consequences in CRIU mode (see #16959). Therefore, this PR cleans up the code to check the flag rather than check ifJ9HookDisable
fails.