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

8265480: add basic JVMCI support for JEP 309: Dynamic Class-File Constants #3578

Closed
wants to merge 4 commits into from

Conversation

@dougxc
Copy link
Member

@dougxc dougxc commented Apr 19, 2021

This PR adds support to JVMCI for CONSTANT_Dynamic constant pool entries. It brings the JVMCI support on par with the support in CI for C1 and C2 with one difference: JVMCI will resolve unresolved condy entries where as CI bails out in this case (it expects condy entries to be resolved by the interpreter).

When using JVMCI for JIT compilation, unresolved entries should only be seen when running under -Xcomp.

When using JVMCI for AoT (e.g. Native Image), most entries will be unresolved since no other code apart from the AoT compiler is running.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8265480: add basic JVMCI support for JEP 309: Dynamic Class-File Constants

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3578/head:pull/3578
$ git checkout pull/3578

Update a local copy of the PR:
$ git checkout pull/3578
$ git pull https://git.openjdk.java.net/jdk pull/3578/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3578

View PR using the GUI difftool:
$ git pr show -t 3578

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3578.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Apr 19, 2021

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

@openjdk
Copy link

@openjdk openjdk bot commented Apr 19, 2021

@dougxc The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@dougxc dougxc force-pushed the JDK-8265480 branch 4 times, most recently from 8c657c1 to 5cdeb18 Apr 21, 2021
@dougxc dougxc marked this pull request as ready for review Apr 21, 2021
@openjdk openjdk bot added the rfr label Apr 21, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Apr 21, 2021

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Good. Please, update copyright year in files you touched.

@openjdk
Copy link

@openjdk openjdk bot commented Apr 21, 2021

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

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

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

8265480: add basic JVMCI support for JEP 309: Dynamic Class-File Constants

Reviewed-by: kvn, psandoz

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 59 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

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

@openjdk openjdk bot added the ready label Apr 21, 2021
}
}

JVMCIObject result = JVMCIENV->call_PrimitiveConstant_forTypeChar(type2char(bt2), raw_value, JVMCI_CHECK_NULL);
Copy link
Member

@PaulSandoz PaulSandoz Apr 21, 2021

Given the above switch is total this part is unreachable? Did you mean for it to occur after the if (!is_reference_type(bt)) block?

Copy link
Member Author

@dougxc dougxc Apr 21, 2021

No - it should not be there at all: b70c7b1
Thanks for spotting.

Copy link
Member

@PaulSandoz PaulSandoz Apr 21, 2021

Oops, i think i need glasses, the switch has break statements that results in processing of the raw_value:

      switch (bt2) {
        case T_BOOLEAN: raw_value = value.z; break;
...

Copy link
Member Author

@dougxc dougxc Apr 22, 2021

I need more than glasses since I wrote this code! Thankfully the test I added also showed the problem with removing this "unreachable" code.

Copy link
Member

@PaulSandoz PaulSandoz left a comment

I am not an expert in HS/JVMCI code, but i can mostly follow it. Test looks good. I did wonder if there should be a test for a BSM with a ref type of say List rather than String given the latter can be represented directly in the constant pool (i don't know if that would exercise different code paths).

Why does a dynamic constant producing a primitive value need to be explicitly processed by resolvePossiblyCachedConstantInPool? Is that so specific certain primitive values can be identified and/or values normalized in some manner.

@dougxc
Copy link
Member Author

@dougxc dougxc commented Apr 22, 2021

I am not an expert in HS/JVMCI code, but i can mostly follow it. Test looks good. I did wonder if there should be a test for a BSM with a ref type of say List rather than String given the latter can be represented directly in the constant pool (i don't know if that would exercise different code paths).

I don't think it exercises different code paths but I added it anyway.

Why does a dynamic constant producing a primitive value need to be explicitly processed by resolvePossiblyCachedConstantInPool? Is that so specific certain primitive values can be identified and/or values normalized in some manner.

It's there to convert standard boxes (e.g. java.lang.Integer) to JVMCI boxes (e.g. jdk.vm.ci.meta.PrimitiveConstant)

* @test
* @requires vm.jvmci
* @summary Test CONSTANT_Dynamic resolution by HotSpotConstantPool.
* @modules java.base/jdk.internal.org.objectweb.asm
Copy link
Member Author

@dougxc dougxc Apr 22, 2021

Instead of ASM, I would have preferred to use test.java.lang.invoke.lib.InstructionHelper like CondyBSMInvocation does. However, I could not figure out how to use a test library from the test/jdk suite in the test/hotspot/jtreg suite. Do you know if that's possible @PaulSandoz ?

Copy link
Member

@PaulSandoz PaulSandoz Apr 22, 2021

It might be (depending of source locations). I would need to look in more detail. I can do that as a follow on investigation/fix if need be, rather than block this PR?

Copy link
Member Author

@dougxc dougxc Apr 22, 2021

No need to spend time on this - just thought you may know off the top of your head. I'll investigate further myself.
Thanks for the detailed review!

@PaulSandoz
Copy link
Member

@PaulSandoz PaulSandoz commented Apr 22, 2021

Why does a dynamic constant producing a primitive value need to be explicitly processed by resolvePossiblyCachedConstantInPool? Is that so specific certain primitive values can be identified and/or values normalized in some manner.

It's there to convert standard boxes (e.g. java.lang.Integer) to JVMCI boxes (e.g. jdk.vm.ci.meta.PrimitiveConstant)

Thanks, and now see it checks that in the test.

@dougxc
Copy link
Member Author

@dougxc dougxc commented Apr 22, 2021

/integrate

@openjdk openjdk bot closed this Apr 22, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Apr 22, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 22, 2021

@dougxc Since your change was applied there have been 59 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

Pushed as commit 7df0c10.

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

@dougxc dougxc deleted the JDK-8265480 branch May 2, 2021
@dougxc dougxc restored the JDK-8265480 branch May 2, 2021
@dougxc dougxc deleted the JDK-8265480 branch May 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants