James Gough

Distinguished Engineer, Java Champion, Speaker and Author
JDConf Day 2: Arm 64 on Windows

28 Oct 2020

I started to make general notes and decided to pull this talk out as it was extremely interesting. I’m looking forward to the longer version of this talk :).

Enabling Java: Windows on Arm64 – A Success Story! @mon_beck

What is The OpenJDK Project?

It is a free open source reference implementation Java SE standard, licensed under GNU GPL with classpath exception. In 2006-2010 100% of the JDK was Open Sourced. The Porters Group was created to extend the OpenJDK to different processor architectures and OSes. In 2013 the Microsoft and Java story began, though somewhat quietly in the background…

What is Arm?

Reduced Instruction Set Computer, highly optimized instruction set with a large number of registers available. The load/store architecture does not allow direct access to memory. Memory access is via specific instruction called memory access instructions. Data is first loaded into registers and is operated on in the register.

Architecture is 64 bit wide int, registers data and pointers. Before Arm v8 arm was not multiple copy atomic, meaning all threads were not guaranteed to see writes at the same time. In order to ensure access ordering we need to ensure fences and barriers. ISBs (Instruction Synchronized Barrier) is used for flushing the CPU buffers.

Usage of Java at Microsoft

Arm64 is growing in usage in third party systems, including eMAG and Thunder X2. The Microsoft Surface Pro X system is also also offered. In order to ensure testing each of these types of systems need to be in the test pipeline.

What is an OpenJDK Platform and HotSpot

Windows on Arm64 is a new platform for OpenJDK. Even if you are not building Java applications running Java applications is important for many services. HotSpot source repo has been improved over the last few years and effort has been made into cleaning up HotSpot C++ code. Most of the code is not OS specific, the rest is CPU and OS specific code. OS_CPU contains OS and architecture specific code where most of the port was done. RedHat had already created a Linux Arm64 port and Microsoft collaborated to build on their work for the Arm64 Window’s port.

HotSpot Layout

HotSpot has C1 and C2 compilers, using tiered compilation we go through the stages of compilation.

What did the team Learn whilst building the port?

Register R18 is a platform register which has a special meaning and needs to be marked as reserved and not used on both Windows and Mac. Invalidating the instruction cache is a Windows specific change. Optimizations can be applied when we know the target architecture, optimized routines for copying cache lines. Windows CPU detection features APIs are also used within the port.

MSVC offers atomic read-write barrier functions such as CompareExchange, these need to be coded against as the basis of concurrency on the platform. There are fundamental difference in the sizes of some underlying types and how longs and long longs are treated by windows.

Challenges of LLP64

The team has been working on the port since Feb 2020. Started with enabling C1 and Parallel GC, G1 GC bugs and JEPs fixed throughout the year and the JEP was entered to integrate into JDK 16.

Next steps

Keeping the port up to date and support AppleSi, JVMCI HotSpot and more.