Skip to content
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

Disable ClassLookahead by default #16453

Conversation

klangman
Copy link
Contributor

@klangman klangman commented Dec 9, 2022

Disable CLassLookahead because it is possible for static final field value to be changes via reflection or the unsafe API.

  1. Disable ClassLookahead. Similar to GVP, ClassLookahead is using static analysis of static final field initialization code to provide field information that is later used to make assumptions about the field contents which might not be true if reflection or the unsafe API is used to change static final field values. An environment variable is introduced to allow ClassLookahead to be re-enable.

  2. Apply a fix to ClassLookahead so that it does not not generate field information for static final fields that can be initialized with different values on different code paths. This fix is being applied in case the ClassLookahead code is resurrected in the future since #1 above has disabled it globally.

  3. Remove the code in IlGen what would replace array length checks with hard coded obj array length values. This code would look for static final fields that contain ClassLookahead fieldInfo and use the existence of that information to permit the inspection of a heap object and replace array length checks with a constant based on the current heap object's array length. This fix is also applied as a safety measure because the disabling of ClassLookahead (#1 above) would effectively disable this code path.

In general the only safe way to inspect at compile time heap objects pointed to by static final fields is to us the "Static Final Field Folding" optimization which uses OSR to invalidate any code which made an assumptions based on the contents of a static final field when that fields contents may have been modified by reflection.

Signed-off-by: Kevin Langman langman@ca.ibm.com

@vijaysun-omr vijaysun-omr self-assigned this Dec 9, 2022
@vijaysun-omr
Copy link
Contributor

Jenkins test sanity all jdk8,jdk11,jdk19

@klangman klangman changed the title WIP: Disable ClassLookahead by default Disable ClassLookahead by default Dec 9, 2022
@vijaysun-omr
Copy link
Contributor

Jenkins test sanity aix jdk8,jdk11

@vijaysun-omr
Copy link
Contributor

Jenkins test sanity.functional aix jdk8

Disable CLassLookahead because it is possible for static final field
value to be changes via reflection or the unsafe API.

1. Disable ClassLookahead. Similar to GVP, ClassLookahead is using
static analysis of static final field initialization code to provide
field information that is later used to make assumptions about the
field contents which might not be true if reflection or the unsafe
API is used to change static final field values. An environment
variable is introduced to allow ClassLookahead to be re-enable.

2. Apply a fix to ClassLookahead so that it does not not generate field
information for static final fields that can be initialized with
different values on different code paths. This fix is being applied in
case the ClassLookahead code is resurrected in the future since `eclipse-openj9#1`
above has disabled it globally.

3.Remove the code in IlGen what would replace array length checks with
hard coded obj array length values. This code would look for static
final fields that contain ClassLookahead fieldInfo and use the existence
of that information to permit the inspection of a heap object and
replace array length checks with a constant based on the current heap
object's array length. This fix is also applied as a safety measure
because the disabling of ClassLookahead (`eclipse-openj9#2` above) would effectively
disable this code path.

In general the only safe way to inspect at compile time heap objects
pointed to by static final fields is to us the "Static Final Field
Folding" optimization which uses OSR to invalidate any code which made
an assumptions based on the contents of a static final field when that
fields contents may have been modified by reflection.

Signed-off-by: Kevin Langman <langman@ca.ibm.com>
@klangman klangman force-pushed the prevent-invalid-compiletime-field-access branch from 2424b88 to 2cf11bc Compare December 12, 2022 19:01
@klangman
Copy link
Contributor Author

The "GVP" changes referenced in the comments is here: eclipse-omr/omr#6843
The above force-push was to update the comments only.

@vijaysun-omr
Copy link
Contributor

All checks had passed in sanity functional testing earlier across releases. Last change was to commit message only. Merging.

@vijaysun-omr vijaysun-omr merged commit 60a4172 into eclipse-openj9:master Dec 12, 2022
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.

2 participants