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

7903923: Derive C_* layouts directly from the Linker #269

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nizarbenalla
Copy link
Member

@nizarbenalla nizarbenalla commented Dec 30, 2024

Depending on the platform, different C_* correspond to different JAVA_* types. We can get those values directly from the linker.

This patch can allows us to have a common class for different platforms.

Please review, and thanks in advance!


Progress

  • Change must not contain extraneous whitespace
  • Change must be properly reviewed (no review required)

Issue

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jextract.git pull/269/head:pull/269
$ git checkout pull/269

Update a local copy of the PR:
$ git checkout pull/269
$ git pull https://git.openjdk.org/jextract.git pull/269/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 269

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jextract/pull/269.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 30, 2024

👋 Welcome back nbenalla! 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 bot commented Dec 30, 2024

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

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

7903923: Derive C_* layouts directly from the Linker

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 1 new commit pushed to the master branch:

  • 360bdc9: Update gradle to version 8.11.1 and fix GitHub actions

Please see this link for an up-to-date comparison between the source branch of this pull request and 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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@nizarbenalla nizarbenalla marked this pull request as ready for review December 30, 2024 16:19
@openjdk openjdk bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 30, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 30, 2024

Webrevs

.withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE));
""");
if (TypeImpl.IS_WINDOWS) {
first.appendIndentedLines("public static final ValueLayout.OfInt C_LONG = ValueLayout.JAVA_INT;");
first.appendIndentedLines("public static final ValueLayout.OfDouble C_LONG_DOUBLE = ValueLayout.JAVA_DOUBLE;");
first.appendIndentedLines("public static final ValueLayout.OfInt C_LONG = (ValueLayout.OfInt) Linker.nativeLinker().canonicalLayouts().get(\"int\");");
Copy link
Contributor

@mcimadamore mcimadamore Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The canonical layout for this has name long. But the result is a ValueLayout.OfInt (because FFM uses int to model values of that type on Windows). In other words, the only thing that changes in Windows is the cast that should be to OfInt, not to OfLong.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining, will fix it.

first.appendIndentedLines("public static final ValueLayout.OfInt C_LONG = ValueLayout.JAVA_INT;");
first.appendIndentedLines("public static final ValueLayout.OfDouble C_LONG_DOUBLE = ValueLayout.JAVA_DOUBLE;");
first.appendIndentedLines("public static final ValueLayout.OfInt C_LONG = (ValueLayout.OfInt) Linker.nativeLinker().canonicalLayouts().get(\"int\");");
first.appendIndentedLines("public static final ValueLayout.OfDouble C_LONG_DOUBLE = (ValueLayout.OfDouble) Linker.nativeLinker().canonicalLayouts().get(\"double\");");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, there's no canonical layout for long double. (but what you did retains compatibility with what we had). But I wonder if FFM should add one? @JornVernee , @minborg ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be okay with adding long double as a canonical layout, just on Windows, if that's what you mean.

@nizarbenalla
Copy link
Member Author

I'm seeing multiple failures on windows (and only on windows), will need to investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Pull request is ready to be integrated rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants