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

CMake Migration #2

Open
dnakamura opened this issue Sep 21, 2017 · 0 comments
Open

CMake Migration #2

dnakamura opened this issue Sep 21, 2017 · 0 comments
Labels

Comments

@dnakamura
Copy link
Owner

No description provided.

@dnakamura dnakamura added the Epic label Sep 21, 2017
dnakamura pushed a commit that referenced this issue Aug 6, 2019
There can be abitrary bytecodes between an `if` bytecode and its branch
target, some of which don't belong to the if's fall through block. When
folding the `if` to its branch target, we need to turn the it into a
`goto` such that the CFG is correctly constructed. There is no such
problem folding the `if` to its fall through as there is no bytecode in
between.

The following is an example. If we were to fold the `if` at bytecode
index 5 to its branch target 19, current implemenation will result in an
edge between the fall through block for the first `if` and its `else`
block, which means that `s` will always be 2 regardless of the value of
`condition1`. This commit will fix this issue.

```
if (condition1) {
   if (condition2) {
   s = 1;
   }
} else {
  s = 2;
}
return;
```
bytecodes
```
  0: iload_1
  1: ifeq          15
  4: iload_2
  5: ifeq          19
  8: iconst_1
  9: putstatic     #2                  // Field s:I
 12: goto          19
 15: iconst_2
 16: putstatic     #2                  // Field s:I
 19: return
```

closes eclipse-openj9#6421

Signed-off-by: Liqun Liu <liqunl@ca.ibm.com>
dnakamura pushed a commit that referenced this issue Jan 31, 2023
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 (`#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant