Skip to content

Commit bbaceb2

Browse files
committed
Reserve platform-reserved register on Windows AArch64
1 parent 7bc06f8 commit bbaceb2

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

sdk/src/org.graalvm.nativeimage/snapshot.sigtest

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ innr public final static IOS_AARCH64
226226
innr public final static IOS_AMD64
227227
innr public final static LINUX_AARCH64
228228
innr public final static WINDOWS_AMD64
229+
innr public final static WINDOWS_AARCH64
229230
innr public static LINUX_AMD64
230231
meth public java.lang.String getArchitecture()
231232
meth public java.lang.String getOS()
@@ -327,6 +328,13 @@ intf org.graalvm.nativeimage.Platform$AMD64
327328
intf org.graalvm.nativeimage.Platform$WINDOWS
328329
supr java.lang.Object
329330

331+
CLSS public final static org.graalvm.nativeimage.Platform$WINDOWS_AARCH64
332+
outer org.graalvm.nativeimage.Platform
333+
cons public init()
334+
intf org.graalvm.nativeimage.Platform$AARCH64
335+
intf org.graalvm.nativeimage.Platform$WINDOWS
336+
supr java.lang.Object
337+
330338
CLSS public abstract interface !annotation org.graalvm.nativeimage.Platforms
331339
anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
332340
anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE, METHOD, CONSTRUCTOR, FIELD, PACKAGE])

sdk/src/org.graalvm.nativeimage/src/META-INF/services/org.graalvm.nativeimage.Platform

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ org.graalvm.nativeimage.Platform$DARWIN_AARCH64
66
org.graalvm.nativeimage.Platform$IOS_AMD64
77
org.graalvm.nativeimage.Platform$IOS_AARCH64
88
org.graalvm.nativeimage.Platform$WINDOWS_AMD64
9+
org.graalvm.nativeimage.Platform$WINDOWS_AARCH64

sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/Platform.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,23 @@ public WINDOWS_AMD64() {
369369

370370
}
371371

372+
/**
373+
* Supported leaf platform: Windows on AArch 64-bit.
374+
*
375+
* @since 22.0
376+
*/
377+
final class WINDOWS_AARCH64 implements WINDOWS, AARCH64 {
378+
379+
/**
380+
* Instantiates a marker instance of this platform.
381+
*
382+
* @since 22.0
383+
*/
384+
public WINDOWS_AARCH64() {
385+
}
386+
387+
}
388+
372389
/**
373390
* Marker for elements (types, methods, or fields) that are only visible during native image
374391
* generation and cannot be used at run time, regardless of the actual platform.

substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64RegisterConfig.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public class SubstrateAArch64RegisterConfig implements SubstrateRegisterConfig {
101101
private final TargetDescription target;
102102
private final int nativeParamsStackOffset;
103103
private final RegisterArray generalParameterRegs;
104-
private final RegisterArray simdParameterRegs;
104+
private final RegisterArray fpParameterRegs;
105105
private final RegisterArray allocatableRegs;
106106
private final RegisterArray calleeSaveRegisters;
107107
private final RegisterAttributes[] attributesMap;
@@ -114,9 +114,16 @@ public SubstrateAArch64RegisterConfig(ConfigKind config, MetaAccessProvider meta
114114
this.metaAccess = metaAccess;
115115
this.preserveFramePointer = preserveFramePointer;
116116

117-
// This is the Linux 64-bit ABI for parameters.
117+
/*
118+
* This is the Linux 64-bit ABI for parameters.
119+
*
120+
* Note the Darwin and Windows ABI are the same with the following exception:
121+
*
122+
* On Windows, when calling a method with variadic args, all fp parameters must be passed on
123+
* the stack. Currently, this is unsupported. Adding support is tracked by GR-34188.
124+
*/
118125
generalParameterRegs = new RegisterArray(r0, r1, r2, r3, r4, r5, r6, r7);
119-
simdParameterRegs = new RegisterArray(v0, v1, v2, v3, v4, v5, v6, v7);
126+
fpParameterRegs = new RegisterArray(v0, v1, v2, v3, v4, v5, v6, v7);
120127

121128
nativeParamsStackOffset = 0;
122129

@@ -141,10 +148,13 @@ public SubstrateAArch64RegisterConfig(ConfigKind config, MetaAccessProvider meta
141148
regs.remove(ReservedRegisters.singleton().getHeapBaseRegister());
142149
regs.remove(ReservedRegisters.singleton().getThreadRegister());
143150
/*
144-
* Darwin specifies that r18 is a platform-reserved register:
151+
* Darwin and Windows specify that r18 is a platform-reserved register:
152+
*
145153
* https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
154+
*
155+
* https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions
146156
*/
147-
if (OS.getCurrent() == OS.DARWIN) {
157+
if (OS.getCurrent() == OS.DARWIN || OS.getCurrent() == OS.WINDOWS) {
148158
regs.remove(r18);
149159
}
150160
allocatableRegs = new RegisterArray(regs);
@@ -229,7 +239,7 @@ public CallingConvention getCallingConvention(Type t, JavaType returnType, JavaT
229239
AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
230240

231241
int currentGeneral = 0;
232-
int currentSIMD = 0;
242+
int currentFP = 0;
233243

234244
/*
235245
* We have to reserve a slot between return address and outgoing parameters for the deopt
@@ -261,8 +271,8 @@ public CallingConvention getCallingConvention(Type t, JavaType returnType, JavaT
261271
break;
262272
case Float:
263273
case Double:
264-
if (currentSIMD < simdParameterRegs.size()) {
265-
register = simdParameterRegs.get(currentSIMD++);
274+
if (currentFP < fpParameterRegs.size()) {
275+
register = fpParameterRegs.get(currentFP++);
266276
}
267277
break;
268278
default:

0 commit comments

Comments
 (0)