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

8308452: Extend internal Architecture enum with byte order and address size #14063

Closed

Conversation

RogerRiggs
Copy link
Contributor

@RogerRiggs RogerRiggs commented May 19, 2023

The internal enum jdk.internal.util.Architecture does not provide information about the big or little endianness or the address size (64 or 32 bits). The endian-ness and address size are intrinsic to the architecture.

The values of the enum are extended to separately identify the big endian and little-endian uses of the ISA.
For example, PPC64 and PPC64LE for the big and little-endian versions.
The enum values directly reflect the build-time artifacts and resulting executables.

This information about an architecture will make the enum more useful especially to identify a target platform in a cross-platform use case. A method is added to map well known aliases for the platforms to the Architecture enum.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8308452: Extend internal Architecture enum with byte order and address size (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14063

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14063.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 19, 2023

👋 Welcome back rriggs! 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 May 19, 2023

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

  • core-libs

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.

Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

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

I think this makes sense. Thanks for working on it! Most architectures have a fixed endianness.
For PPC64, I think using PPC64LE is fine to distinguish as it is a common name.
Another architecture which supports both endianness flavors is IA64. HPUX is big endian and linux little endian. I don't know how this should be handled. Fortunately, I don't think we need to support IA64. :-)

@RogerRiggs RogerRiggs marked this pull request as ready for review May 24, 2023 15:01
@openjdk openjdk bot added the rfr Pull request is ready for review label May 24, 2023
@mlbridge
Copy link

mlbridge bot commented May 24, 2023

Webrevs

Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

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

Mapping the arch to endianness seems okay for the current ports but I could imagine needing to re-visit that at some point.

@TheRealMDoerr
Copy link
Contributor

I think the mapping from ppc64le to ppc64 should get removed with the introduction of ppc64le as separate architecture:
https://github.com/openjdk/jdk/blob/64f6681cc7bb184112adcf2b4f2c313e1b0a5c4f/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Platform.java#LL55C5-L55C5
Would you mind removing it with your change?

Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! Unfortunately, there's still something going wrong on ppc64le:

  • jdk/internal/util/ArchTest.java: System property os.arch: "ppc64le", Architecture.current(): "PPC64"
  • tools/jlink/plugins/CDSPluginTest.java: Cannot generate CDS archives: target image platform linux-ppc64le is different from runtime platform linux-ppc64

Do you happen to know why Architecture.current() misses the "le"?

@RogerRiggs
Copy link
Contributor Author

Do you happen to know why Architecture.current() misses the "le"?

@TheRealMDoerr The makefile that does the substitution (in GensrcMisc.gmk) for the OPENJDK_TARGET_CPU is using the _CANONICAL form of the architecture (that maps ppc64le to ppc64).
I'll work up a fix; note that we do want the canonical form for s390x and amd/x86_64.

Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! LGTM.

@openjdk
Copy link

openjdk bot commented Jun 1, 2023

@RogerRiggs 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:

8308452: Extend internal Architecture enum with byte order and address size

Reviewed-by: mdoerr, jpai, mchung, amitkumar

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

  • 1587836: 8310425: [JVMCI] compiler/runtime/TestConstantDynamic: lookupConstant returned an object of incorrect type: null
  • 73d7aa1: 8301489: C1: ShortLoopOptimizer might lift instructions before their inputs
  • 990e3a7: 8308899: Introduce Classfile context and improve Classfile options
  • 79c056e: 8006421: GraphicsConfiguration of a frame is changed when the frame is moved to another screen
  • 45b581b: 8309583: AArch64: Optimize firstTrue() when amount of elements < 8
  • 87e6fab: 8310873: Re-enable locked_create_entry symbol check in runtime/NMT/CheckForProperDetailStackTrace.java for RISC-V
  • 39fa4e6: 8310489: New test runtime/ClassInitErrors/TestStackOverflowDuringInit.java failed
  • 46add3f: 8310909: java.io.InvalidObjectException has redundant @since tag
  • 8f5b677: 8310908: Non-standard @since tag in com.sun.java.accessibility.util.package-info
  • a197ee7: 8310838: Correct range notations in MethodTypeDesc specification
  • ... and 56 more: https://git.openjdk.org/jdk/compare/72501cf76703352800eb8979a53d59a83791d626...master

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 Pull request is ready to be integrated label Jun 1, 2023
private final ByteOrder byteOrder;

/**
* Construct an Arctecture with number of address bits and byte order.
Copy link
Member

Choose a reason for hiding this comment

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

Hello Roger, there is a typo here "Arctecture" instead of "Architecture"

Copy link
Member

@jaikiran jaikiran left a comment

Choose a reason for hiding this comment

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

The changes in this PR look OK to me. The introduction of instance method byteOrder() in the Architecture enum, as proposed in this PR, will help with the changes being proposed in #11943. That way jlink won't have to have its own mapping of osname-architecture to endianness.
Once this PR is integrated, I'll update that other PR to use this new API and remove the endianness mappings being proposed in that PR.

@RogerRiggs
Copy link
Contributor Author

I think this has settled down.
If anyone would care to test it on S390, PPC, LOONGARCH64, or MIPS that would be appreciated.

Copy link
Member

@mlchung mlchung left a comment

Choose a reason for hiding this comment

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

This change looks fine to me.

@TheRealMDoerr
Copy link
Contributor

Still good on PPC64.

Copy link
Member

@offamitkumar offamitkumar left a comment

Choose a reason for hiding this comment

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

Looks good for s390.

@RogerRiggs
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 27, 2023

Going to push as commit d6dd0dc.
Since your change was applied there have been 73 commits pushed to the master branch:

  • fb283df: 8310828: java.sql java.sql.rowset packages have no @since info
  • ec45bd6: 8310182: DateTimeFormatter date formats (ISO_LOCAL_DATE) separated with hyphen, not dash
  • 2bd4136: 8310849: Pattern matching for instanceof and arrayType cleanup in j.l.invoke and j.l.reflect
  • 7ce967a: 8281455: Change JVM options with small ranges from 64 to 32 bits, for gc_globals.hpp
  • f6133ed: 8310890: Normalize identifier names
  • 58bb655: 8222329: Readable read(CharBuffer) does not specify that 0 is returned when there is no remaining space in buffer
  • 05e9c41: 8310731: Configure a javax.net.ssl.SNIMatcher for the HTTP/1.1 test servers in java/net/httpclient tests
  • 1587836: 8310425: [JVMCI] compiler/runtime/TestConstantDynamic: lookupConstant returned an object of incorrect type: null
  • 73d7aa1: 8301489: C1: ShortLoopOptimizer might lift instructions before their inputs
  • 990e3a7: 8308899: Introduce Classfile context and improve Classfile options
  • ... and 63 more: https://git.openjdk.org/jdk/compare/72501cf76703352800eb8979a53d59a83791d626...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 27, 2023
@openjdk openjdk bot closed this Jun 27, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 27, 2023
@openjdk
Copy link

openjdk bot commented Jun 27, 2023

@RogerRiggs Pushed as commit d6dd0dc.

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

@RogerRiggs RogerRiggs deleted the 8308452-cross-platform-arch branch December 11, 2023 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
7 participants