JDK-8251280 : JEP 391: macOS/AArch64 Port
  • Type: JEP
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P2
  • Status: Closed
  • Resolution: Delivered
  • Fix Versions: 17
  • Submitted: 2020-08-07
  • Updated: 2024-07-04
  • Resolved: 2021-09-29
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8272213 :  
Description
Summary
-------

Port the JDK to macOS/AArch64.


Non-Goals
---------

* It is not a goal to implement all optional components (e.g., compiler
intrinsics), even if they are implemented in other AArch64 ports.

* It is not a goal to support the write-xor-execute (W^X)
memory-protection policy for targets other than macOS/AArch64.


Motivation
----------

Apple has announced a long-term plan to [transition their line of
Macintosh computers from x64 to AArch64][mac-transition]. We therefore
expect to see broad demand for a macOS/AArch64 port of the JDK.

Although it will be possible to run a macOS/x64 build of the JDK on
AArch64-based systems via macOS's built-in [Rosetta 2][rosetta-2]
translator, the translation will almost certainly introduce a significant
performance penalty.

[mac-transition]: https://en.wikipedia.org/wiki/Mac_transition_to_Apple_Silicon
[rosetta-2]: https://en.wikipedia.org/wiki/Rosetta_(software)#Rosetta_2


Description
-----------

An AArch64 port already exists for Linux ([JEP 237][jep-237]), and work
is underway on an AArch64 port for Windows ([JEP 388][jep-388]).  We
expect to reuse existing AArch64 code from these ports by employing
conditional compilation — as is usual in ports of the JDK — to
accommodate differences in low-level conventions such as the application
binary interface (ABI) and the set of reserved processor registers.

macOS/AArch64 forbids memory segments from being executable and writeable
at the same time, a policy known as [_write-xor-execute_ (W^X)][w-x].
The HotSpot VM routinely creates and modifies executable code, so this
JEP will implement W^X support in HotSpot for macOS/AArch64.

[jep-237]: https://openjdk.java.net/jeps/237
[jep-388]: https://openjdk.java.net/jeps/388
[w-x]: https://en.wikipedia.org/wiki/W%5EX


Testing
-------

Testing will include, but not be limited to, compatibility testing with
the TCK, regression testing with jtreg, and validation with applications.
The execution environment will include development platforms available
from Apple as well as consumer hardware, once it becomes available.


Risks and Assumptions
---------------------

* The changes for macOS/AArch64 risk breaking the existing Linux/AArch64,
Windows/AArch64, and macOS/x64 ports. This risk will be reduced via
extensive pre-integration testing.

* We expect to be able to implement the new ABI convention with
reasonably small changes in the shared AArch64 code.  We expect the
footprint of the macOS-specific code to be small.

* We expect the macOS/AArch64 and Windows/AArch64 ports to be similar in
some ways, allowing some code to be shared across these ports and further
reducing the macOS-specific AArch64 code.

* We assume that the new version of macOS will not differ substantially
from past versions, so that the amount of code change required for the
new version will be small.

* We expect that supporting the W^X policy will be aided by
operating-system services such as the
[`pthread_jit_write_protect_np`][write-protect] system call. If not, we
will develop alternative approaches. The first implementation will target
correctness with a possible performance penalty in uncommon cases, such
as deoptimizations.

[write-protect]: https://developer.apple.com/documentation/apple_silicon/porting_just-in-time_compilers_to_apple_silicon



Dependencies
-----------

The macOS/AArch64 port and the Windows/AArch64 port ([JEP 388][jep-388])
will likely share some code.  Some parts of this JEP will depend upon the
integration of JEP 388, while other parts can be developed in parallel.

Comments
Hello part 1 of testing: github actions for jdk were updated to support cross-building of macos-aarch64 on macos-x86 hosts. Now every change to upstream jdk will pass the build test part 2 (regression testing): update to follow
06-04-2021

Hello we still discussing the question "about testing" internally, will update when we have an answer.
05-04-2021

My understanding it is is for the case when you may have some subtasks to finish after code integration. And I see all subtask listed in JDK-8253795 are integrated. I think you can move it to `Complete` unless you have other not-listed subtasks you want to finish to make sure this port is fully functional and testable. Actually I don't see what is your plan for *regular* testing of this port.
25-03-2021

We have integrated PR/2200 to upstream and moved this jep to integrated state. There is one thing unclear to me, when we are supposed to move this jep to complete state ?
25-03-2021

Our engineering plan: Many folks have already looked into our PR and approved it. Small polishing might be required. We are ready to integrate it soon after it will be targeted.
12-03-2021

Mark, thank you! It looks great. Thanks for the information about the process of integration and targeting. It makes sense.
25-09-2020

I’ve edited this JEP to streamline the text, correct some terminology, and add some references. If this looks okay to you then assign the issue back to me and I’ll move it to Candidate. (Ignore the Markdown rendering artifacts on the JBS issue page; the text is rendered correctly here: https://openjdk.java.net/jeps/8251280 .) I removed the paragraph in which you wrote, “The proposed workflow for this JEP is to work on and integrate isolated patches, each reviewed individually.” JEPs are meant to be integrated in their entirety, once they’re ready. Once the JEP is targeted then you can merge more than one commit if that’s convenient, but no commit should be merged prior to targeting. Finally, per the JEP 2.0 Process Proposal (https://cr.openjdk.java.net/~mr/jep/jep-2.0-02.html) only a Committer to the JDK Project can propose to target a JEP to a JDK release, though it’s fine for any Contributor to propose a JEP. To propose to target this JEP, you’ll need to find a JDK Committer to serve as the owner on your behalf.
24-09-2020

Vladimir, thank you!
27-08-2020

Reviewed.
27-08-2020

Got it. There is no intention to change any public interface of java classes, it's only about private implementation, and only if necessary. To avoid possible confusion, I've removed "java classes" form the list, assuming minor changes to the implementation are implied. Thanks!
27-08-2020

Hi Anton. I understand that you want to make sure you can build it. And I agree that it would require JDK build changes and may need change to native JDK code. But it is still not clear why you concern about Java API. As far as I see Windows/AArch64 Port does not have such changes. Changes to "Java classes" have much high approval "bar" vs adding new port. We don't usually do that to just be able build on new platform. And it will be out of scope of this JEP which is HotSpot specific. You need to file a separate core-libs JEP for that.
27-08-2020

Vladimir, thanks! The goal should enable all efforts for OpenJDK that are not related to the hotspot itself. E.g. change build system, replace or workaround uses of deprecated API,... anything that would make the OpenJDK non-buildable or non-functional. I've made a change, is it better now?
27-08-2020

[~akozlov] Can you be more specific about "Introduce changes to Java classes"? Why it is needed?
26-08-2020

Andrew, thanks for review! Moving the JEP to Submitted state.
20-08-2020

Looks good to me.
17-08-2020

Thank you @Anton for drafting the JEP. We are very happy to see this. Please read about our thoughts on collaboration here: https://mail.openjdk.java.net/pipermail/hotspot-dev/2020-August/042677.html
11-08-2020