Skip to content

Commit ec86d68

Browse files
committed
[GR-64956] Introduce WINDOWS_BASE platform without JNI or registering providers.
PullRequest: graal/20872
2 parents 0614a73 + 2de9d17 commit ec86d68

File tree

33 files changed

+98
-95
lines changed

33 files changed

+98
-95
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,16 @@ CLSS public abstract interface static org.graalvm.nativeimage.Platform$RISCV64
421421
intf org.graalvm.nativeimage.Platform
422422
meth public java.lang.String getArchitecture()
423423

424-
CLSS public abstract interface static org.graalvm.nativeimage.Platform$WINDOWS
424+
CLSS public abstract interface static org.graalvm.nativeimage.impl.InternalPlatform$WINDOWS_BASE
425425
outer org.graalvm.nativeimage.Platform
426426
intf org.graalvm.nativeimage.impl.InternalPlatform$NATIVE_ONLY
427-
intf org.graalvm.nativeimage.impl.InternalPlatform$PLATFORM_JNI
428427
meth public java.lang.String getOS()
429428

429+
CLSS public abstract interface static org.graalvm.nativeimage.Platform$WINDOWS
430+
outer org.graalvm.nativeimage.Platform
431+
intf org.graalvm.nativeimage.impl.InternalPlatform$WINDOWS_BASE
432+
intf org.graalvm.nativeimage.impl.InternalPlatform$PLATFORM_JNI
433+
430434
CLSS public final static org.graalvm.nativeimage.Platform$WINDOWS_AARCH64
431435
outer org.graalvm.nativeimage.Platform
432436
cons public init()

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -247,16 +247,7 @@ default String getOS() {
247247
*
248248
* @since 19.0
249249
*/
250-
interface WINDOWS extends InternalPlatform.PLATFORM_JNI, InternalPlatform.NATIVE_ONLY {
251-
252-
/**
253-
* Returns string representing WINDOWS OS.
254-
*
255-
* @since 21.0
256-
*/
257-
default String getOS() {
258-
return "windows";
259-
}
250+
interface WINDOWS extends InternalPlatform.WINDOWS_BASE, InternalPlatform.PLATFORM_JNI {
260251
}
261252

262253
/**

sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/InternalPlatform.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -60,4 +60,21 @@ interface PLATFORM_JNI extends Platform {
6060
interface NATIVE_ONLY extends Platform {
6161

6262
}
63+
64+
/**
65+
* Supported operating system: Windows, without registering OS-specific providers or making use
66+
* of (or support for) JNI libraries.
67+
*
68+
* @since 25.0
69+
*/
70+
interface WINDOWS_BASE extends NATIVE_ONLY {
71+
/**
72+
* Returns string representing WINDOWS OS.
73+
*
74+
* @since 21.0
75+
*/
76+
default String getOS() {
77+
return "windows";
78+
}
79+
}
6380
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
import java.util.Set;
7373

7474
import org.graalvm.nativeimage.Platform;
75+
import org.graalvm.nativeimage.impl.InternalPlatform;
7576

7677
import com.oracle.svm.core.ReservedRegisters;
7778
import com.oracle.svm.core.aarch64.SubstrateAArch64MacroAssembler;
@@ -163,7 +164,7 @@ public SubstrateAArch64RegisterConfig(ConfigKind config, MetaAccessProvider meta
163164
*
164165
* https://developer.android.com/ndk/guides/abis#arm64-v8a
165166
*/
166-
if (Platform.includedIn(Platform.DARWIN.class) || Platform.includedIn(Platform.WINDOWS.class) || Platform.includedIn(Platform.ANDROID.class)) {
167+
if (Platform.includedIn(Platform.DARWIN.class) || Platform.includedIn(InternalPlatform.WINDOWS_BASE.class) || Platform.includedIn(Platform.ANDROID.class)) {
167168
regs.remove(r18);
168169
}
169170
allocatableRegs = List.copyOf(regs);

substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64InterpreterStubs.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.graalvm.nativeimage.c.struct.RawField;
3535
import org.graalvm.nativeimage.c.struct.RawStructure;
3636
import org.graalvm.nativeimage.c.struct.SizeOf;
37+
import org.graalvm.nativeimage.impl.InternalPlatform;
3738
import org.graalvm.word.Pointer;
3839
import org.graalvm.word.PointerBase;
3940

@@ -119,7 +120,7 @@ public void enter(CompilationResultBuilder crb) {
119120
masm.movq(createAddress(offsetAbiFpArg6()), fps.get(6));
120121
masm.movq(createAddress(offsetAbiFpArg7()), fps.get(7));
121122
} else {
122-
assert Platform.includedIn(Platform.WINDOWS.class);
123+
assert Platform.includedIn(InternalPlatform.WINDOWS_BASE.class);
123124
VMError.guarantee(fps.size() == 4);
124125
}
125126

@@ -558,7 +559,7 @@ public long setGpArgumentAt(AllocatableValue ccArg, Pointer data, int pos, long
558559

559560
private static int upperFpEnd() {
560561
/* only 4 floating point regs on Windows, 8 otherwise */
561-
return Platform.includedIn(Platform.WINDOWS.class) ? 3 : 7;
562+
return Platform.includedIn(InternalPlatform.WINDOWS_BASE.class) ? 3 : 7;
562563
}
563564

564565
@Override

substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64RegisterConfig.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import java.util.Set;
7474

7575
import org.graalvm.nativeimage.Platform;
76+
import org.graalvm.nativeimage.impl.InternalPlatform;
7677

7778
import com.oracle.svm.core.ReservedRegisters;
7879
import com.oracle.svm.core.SubstrateUtil;
@@ -146,7 +147,7 @@ public SubstrateAMD64RegisterConfig(ConfigKind config, MetaAccessProvider metaAc
146147
}
147148
}
148149

149-
if (Platform.includedIn(Platform.WINDOWS.class)) {
150+
if (Platform.includedIn(InternalPlatform.WINDOWS_BASE.class)) {
150151
// This is the Windows 64-bit ABI for parameters.
151152
// Note that float parameters also "consume" a general register and vice versa in the
152153
// native ABI.
@@ -195,7 +196,7 @@ public SubstrateAMD64RegisterConfig(ConfigKind config, MetaAccessProvider metaAc
195196
* rbp must be last in the list, so that it gets the location closest to the saved
196197
* return address.
197198
*/
198-
if (Platform.includedIn(Platform.WINDOWS.class)) {
199+
if (Platform.includedIn(InternalPlatform.WINDOWS_BASE.class)) {
199200
calleeSaveRegisters = List.of(rbx, rdi, rsi, r12, r13, r14, r15, rbp,
200201
xmm6, xmm7, xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15);
201202
} else {
@@ -243,7 +244,7 @@ public List<Register> getCalleeSaveRegisters() {
243244

244245
@Override
245246
public PlatformKind getCalleeSaveRegisterStorageKind(Architecture arch, Register calleeSaveRegister) {
246-
if (Platform.includedIn(Platform.WINDOWS.class) && AMD64.XMM.equals(calleeSaveRegister.getRegisterCategory())) {
247+
if (Platform.includedIn(InternalPlatform.WINDOWS_BASE.class) && AMD64.XMM.equals(calleeSaveRegister.getRegisterCategory())) {
247248
VMError.guarantee(calleeSaveRegister.encoding() >= xmm6.encoding() && calleeSaveRegister.encoding() <= xmm15.encoding(), "unexpected callee saved register");
248249
return V128_QWORD;
249250
}
@@ -321,7 +322,7 @@ public CallingConvention getCallingConvention(Type t, JavaType returnType, JavaT
321322
JavaKind kind = ObjectLayout.getCallSignatureKind(isEntryPoint, parameterTypes[i], metaAccess, target);
322323
kinds[i] = kind;
323324

324-
if (type.nativeABI() && Platform.includedIn(Platform.WINDOWS.class)) {
325+
if (type.nativeABI() && Platform.includedIn(InternalPlatform.WINDOWS_BASE.class)) {
325326
// Strictly positional: float parameters consume a general register and vice
326327
// versa
327328
currentGeneral = i;

substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsJavaLangSubstitutions.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,16 @@
2727
import java.io.Console;
2828
import java.util.Objects;
2929

30-
import jdk.graal.compiler.word.Word;
31-
import org.graalvm.nativeimage.Platform;
32-
import org.graalvm.nativeimage.Platforms;
33-
3430
import com.oracle.svm.core.Uninterruptible;
3531
import com.oracle.svm.core.annotate.Alias;
3632
import com.oracle.svm.core.annotate.RecomputeFieldValue;
3733
import com.oracle.svm.core.annotate.Substitute;
3834
import com.oracle.svm.core.annotate.TargetClass;
3935
import com.oracle.svm.core.jdk.Jvm;
4036

37+
import jdk.graal.compiler.word.Word;
38+
4139
@TargetClass(java.lang.System.class)
42-
@Platforms(Platform.WINDOWS.class)
4340
final class Target_java_lang_System {
4441

4542
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) static volatile Console cons;
@@ -64,7 +61,6 @@ public static long currentTimeMillis() {
6461
}
6562

6663
/** Dummy class to have a class with the file's name. */
67-
@Platforms(Platform.WINDOWS.class)
6864
public final class WindowsJavaLangSubstitutions {
6965

7066
/** Private constructor: No instances. */

substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsJavaNIOSubstitutions.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,13 @@
2424
*/
2525
package com.oracle.svm.core.windows;
2626

27-
import org.graalvm.nativeimage.Platform;
28-
import org.graalvm.nativeimage.Platforms;
29-
3027
import com.oracle.svm.core.annotate.Alias;
3128
import com.oracle.svm.core.annotate.RecomputeFieldValue;
3229
import com.oracle.svm.core.annotate.TargetClass;
3330

34-
@Platforms(Platform.WINDOWS.class)
3531
public final class WindowsJavaNIOSubstitutions {
3632

3733
@TargetClass(className = "sun.nio.fs.Cancellable")
38-
@Platforms({Platform.WINDOWS.class})
3934
static final class Target_sun_nio_fs_Cancellable {
4035
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Manual)//
4136
private long pollingAddress;

substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsNativeLibrarySupport.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626

2727
import java.io.FileDescriptor;
2828

29-
import jdk.graal.compiler.word.Word;
30-
import org.graalvm.nativeimage.Platform;
31-
import org.graalvm.nativeimage.Platforms;
3229
import org.graalvm.nativeimage.c.type.CCharPointer;
3330
import org.graalvm.nativeimage.c.type.CTypeConversion;
3431
import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder;
@@ -50,8 +47,9 @@
5047
import com.oracle.svm.core.windows.headers.WinBase.HMODULE;
5148
import com.oracle.svm.core.windows.headers.WinSock;
5249

50+
import jdk.graal.compiler.word.Word;
51+
5352
@AutomaticallyRegisteredFeature
54-
@Platforms(Platform.WINDOWS.class)
5553
class WindowsNativeLibraryFeature implements InternalFeature {
5654
@Override
5755
public void duringSetup(DuringSetupAccess access) {
@@ -198,7 +196,6 @@ public PointerBase findSymbol(String name) {
198196
}
199197

200198
@TargetClass(className = "java.io.WinNTFileSystem")
201-
@Platforms(Platform.WINDOWS.class)
202199
final class Target_java_io_WinNTFileSystem {
203200
@Alias
204201
static native void initIDs();

substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
*/
2525
package com.oracle.svm.core.windows;
2626

27-
import jdk.graal.compiler.word.Word;
28-
import org.graalvm.nativeimage.Platform;
2927
import org.graalvm.nativeimage.Platform.HOSTED_ONLY;
3028
import org.graalvm.nativeimage.Platforms;
3129
import org.graalvm.nativeimage.c.function.CFunctionPointer;
@@ -51,9 +49,9 @@
5149
import com.oracle.svm.core.windows.headers.WinBase;
5250

5351
import jdk.graal.compiler.core.common.NumUtil;
52+
import jdk.graal.compiler.word.Word;
5453

5554
@AutomaticallyRegisteredImageSingleton(PlatformThreads.class)
56-
@Platforms(Platform.WINDOWS.class)
5755
public final class WindowsPlatformThreads extends PlatformThreads {
5856
@Platforms(HOSTED_ONLY.class)
5957
WindowsPlatformThreads() {
@@ -180,7 +178,6 @@ protected void yieldCurrent() {
180178
}
181179
}
182180

183-
@Platforms(Platform.WINDOWS.class)
184181
class WindowsParker extends Parker {
185182
private static final long MAX_DWORD = (1L << 32) - 1;
186183

@@ -276,7 +273,6 @@ protected void release() {
276273
}
277274

278275
@AutomaticallyRegisteredImageSingleton(ParkerFactory.class)
279-
@Platforms(Platform.WINDOWS.class)
280276
class WindowsParkerFactory implements ParkerFactory {
281277
@Override
282278
public Parker acquire() {

0 commit comments

Comments
 (0)