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

8255046: [lworld] JIT should make use of array layout encoding in markWord #256

wants to merge 3 commits into from


Copy link

@TobiHartmann TobiHartmann commented Nov 12, 2020

This patch re-implements the flat array check in C1 and C2 by using the mark word bits instead of the layout helper from the array Klass (see JDK-8247299). Unfortunately, this turned out to be far from trivial to implement in C2.

I've introduced a new FlatArrayCheck macro node to wrap the logic of the new check and to make it easier for the loop unswitching optimization to detect and hoist the check. One major problem is that we can't use immutable memory anymore because we are loading the mark word which is mutable (AliasType::_is_rewritable is true). Although the bits we are interested in are in fact immutable (we check for markWord::unlocked_value), we need to use raw memory to not break anti dependency analysis. As a result, flat array checks are not hoisted out of loops anymore and loop unswitching fails. PhaseIdealLoop::move_flat_array_check_out_of_loop will attempt to still move flat array checks out of loops by walking up the memory edge to before the loop and re-wiring the check accordingly.

This patch also fixes an existing issue in Escape Analysis that was only triggered now that we are able to fold the flat array check in more cases due to the ::Ideal/::Value transformations.

@kuksenko, could you please evaluate performance of this change? Disabling the UseArrayMarkWordCheck flag allows to switch back to the old check using the layout helper.



  • Change must not contain extraneous whitespace


Linux x64 Windows x64 macOS x64
Build ✔️ (4/4 passed) ✔️ (2/2 passed) ✔️ (2/2 passed)
Test (tier1) (1/9 running) (9/9 running) (1/9 running)


  • JDK-8255046: [lworld] JIT should make use of array layout encoding in markWord



$ git fetch pull/256/head:pull/256
$ git checkout pull/256

Copy link

bridgekeeper bot commented Nov 12, 2020

👋 Welcome back thartmann! A progress list of the required criteria for merging this PR into lworld will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

Copy link

openjdk bot commented Nov 12, 2020

@TobiHartmann This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file for details.

After integration, the commit message for the final commit will be:

8255046: [lworld] JIT should make use of array layout encoding in markWord

Reviewed-by: roland

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the lworld branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the lworld branch, type /integrate in a new comment.

Copy link

mlbridge bot commented Nov 12, 2020


Copy link

@rwestrel rwestrel left a comment

Looks good to me.

Copy link

kuksenko commented Nov 13, 2020

Performance behavior is as expected.
aaload operation got speedup up +15% on some scenarios.
In general, cost of aaload operation now is 103%-106% from legacy (non valhalla) cost.
and it looks like the minimally possible overhead of aaload operation.
Unfortunately, if array is locked aaload got 20% slowdown (also expected). locking on an array object is quite rare situation.

As for aastore operation - performance unchanged. aastore operation has the same cost in valhalla and in legacy world long before that. The reason of that is either hotspot has precise type information (and doesn't generate checks) or ArrayStoreException check is generated (ArrayStoreException check dominates aastore performance).

Note: I considered benchmarks when ArrayFlattened check can't be hoisted out loop (ref to array is loaded on every loop iteration).

Copy link
Member Author

TobiHartmann commented Nov 13, 2020

Thanks @rwestrel for the review and thanks @kuksenko for the evaluation! I've added as small follow-up fix for EA.

Copy link
Member Author

TobiHartmann commented Nov 13, 2020


@openjdk openjdk bot closed this Nov 13, 2020
@openjdk openjdk bot added integrated and removed ready rfr labels Nov 13, 2020
Copy link

openjdk bot commented Nov 13, 2020

@TobiHartmann Pushed as commit 1b1aefa.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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