From 6c2c81b3b2b6e109ff04f367f8729a03d1038f87 Mon Sep 17 00:00:00 2001 From: Sacha Coppey Date: Fri, 10 Oct 2025 15:27:42 +0200 Subject: [PATCH] Singleton labeling third batch --- .../genscavenge/GenScavengeGCFeature.java | 6 +- .../AArch64NativePatchConsumerFactory.java | 16 ++-- .../aarch64/SubstrateAArch64Feature.java | 30 +++++--- ...SubstrateAArch64SuitesCreatorProvider.java | 9 ++- .../graal/amd64/AMD64NativeImagePatcher.java | 16 ++-- .../graal/amd64/SubstrateAMD64Feature.java | 30 +++++--- .../SubstrateAMD64SuitesCreatorProvider.java | 9 ++- .../svm/core/graal/llvm/LLVMFeature.java | 55 ++++++++------ .../riscv64/SubstrateRISCV64Feature.java | 21 ++++-- .../PosixSubstrateGlobalSigprofHandler.java | 3 +- .../PosixSubstrateSigprofHandlerFeature.java | 6 ++ .../darwin/DarwinSystemPropertiesSupport.java | 7 ++ .../posix/darwin/DarwinVMLockSupport.java | 5 ++ .../linux/LinuxSubstrateSigprofHandler.java | 8 +- .../linux/LinuxSystemPropertiesSupport.java | 14 ++++ .../core/posix/linux/LinuxVMLockSupport.java | 13 +++- .../posix/pthread/PthreadVMLockSupport.java | 11 ++- .../posix/thread/PosixPlatformThreads.java | 7 +- .../core/windows/WindowsPlatformThreads.java | 5 ++ .../WindowsSystemPropertiesSupport.java | 7 ++ .../core/windows/WindowsVMLockSupport.java | 5 ++ .../PinnedPrimitiveArrayViewSupportImpl.java | 14 ++++ .../svm/core/jdk/JavaNetHttpFeature.java | 6 ++ .../svm/core/jdk/TimeZoneSubstitutions.java | 14 ++++ .../LoadedLayeredImageSingletonInfo.java | 11 ++- .../oracle/svm/core/locks/VMLockSupport.java | 5 ++ .../memory/UnmanagedMemorySupportImpl.java | 16 +++- .../svm/core/metadata/MetadataTracer.java | 5 ++ .../svm/core/monitor/MonitorFeature.java | 10 ++- .../monitor/MultiThreadedMonitorSupport.java | 5 ++ .../svm/core/thread/ContinuationSupport.java | 7 +- .../svm/core/thread/ContinuationsFeature.java | 44 ++++++++++- .../svm/hosted/HostedConfiguration.java | 30 +++++--- .../hosted/ImageSingletonsSupportImpl.java | 4 + .../code/RuntimeMetadataEncoderImpl.java | 2 + .../aarch64/AArch64HostedPatcherFeature.java | 45 ++++++----- .../code/amd64/AMD64HostedPatcherFeature.java | 35 +++++---- .../heap/ImageHeapCollectionFeature.java | 5 ++ .../ObservableImageHeapMapProviderImpl.java | 5 ++ .../DisallowedImageHeapObjectFeature.java | 5 ++ .../image/ImageHeapFillerObjectsFeature.java | 5 ++ .../MethodPointerRelocationProvider.java | 6 ++ .../oracle/svm/hosted/image/NativeImage.java | 5 ++ .../NativeImageDebugInfoStripFeature.java | 5 ++ .../hosted/jdk/AtomicFieldUpdaterFeature.java | 5 ++ .../svm/hosted/meta/UniverseBuilder.java | 14 +++- .../hosted/option/RuntimeOptionFeature.java | 5 ++ .../svm/hosted/phases/EnumSwitchPlugin.java | 74 ++++++++++++++++++- ...itExceptionStackTraceInformationPhase.java | 5 ++ .../reflect/proxy/DynamicProxyFeature.java | 7 +- .../hosted/reflect/proxy/ProxyRegistry.java | 5 ++ .../svm/hosted/webimage/WebImageFeature.java | 5 ++ .../webimage/WebImageHostedConfiguration.java | 27 ++++--- .../hosted/webimage/WebImageJSFeature.java | 33 +++++++-- .../WebImageJSSuitesCreatorProvider.java | 5 ++ .../webimage/wasm/WebImageWasmLMFeature.java | 33 +++++++-- .../WebImageWasmLMSuitesCreatorProvider.java | 5 ++ .../wasmgc/WebImageWasmGCFeature.java | 33 +++++++-- .../WebImageWasmGCSuitesCreatorProvider.java | 5 ++ .../threads/WebImageMonitorFeature.java | 5 ++ .../WebImageSingleThreadedMonitorSupport.java | 5 ++ .../WebImageSingleThreadedVMLockSupport.java | 5 ++ 62 files changed, 680 insertions(+), 168 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GenScavengeGCFeature.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GenScavengeGCFeature.java index f8ec2daeda8e..e7205d08a5eb 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GenScavengeGCFeature.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GenScavengeGCFeature.java @@ -144,8 +144,10 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { ImageSingletons.add(CommittedMemoryProvider.class, createCommittedMemoryProvider()); } - // If building libgraal, set system property showing gc algorithm - SystemPropertiesSupport.singleton().setLibGraalRuntimeProperty("gc", Heap.getHeap().getGC().getName()); + if (ImageLayerBuildingSupport.firstImageBuild()) { + // If building libgraal, set system property showing gc algorithm + SystemPropertiesSupport.singleton().setLibGraalRuntimeProperty("gc", Heap.getHeap().getGC().getName()); + } // Needed for the barrier set. access.registerAsUsed(Object[].class); diff --git a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64NativePatchConsumerFactory.java b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64NativePatchConsumerFactory.java index 9dd44b34ccc6..963d3eb5e59f 100644 --- a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64NativePatchConsumerFactory.java +++ b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64NativePatchConsumerFactory.java @@ -26,20 +26,26 @@ import java.util.function.Consumer; -import jdk.graal.compiler.asm.Assembler; -import jdk.graal.compiler.asm.aarch64.AArch64Assembler.SingleInstructionAnnotation; -import jdk.graal.compiler.asm.aarch64.AArch64MacroAssembler; -import jdk.graal.compiler.code.CompilationResult; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.graal.code.NativeImagePatcher; import com.oracle.svm.core.graal.code.PatchConsumerFactory; -import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; +import jdk.graal.compiler.asm.Assembler; +import jdk.graal.compiler.asm.aarch64.AArch64Assembler.SingleInstructionAnnotation; +import jdk.graal.compiler.asm.aarch64.AArch64MacroAssembler; +import jdk.graal.compiler.code.CompilationResult; + @AutomaticallyRegisteredImageSingleton(PatchConsumerFactory.NativePatchConsumerFactory.class) @Platforms(Platform.AARCH64.class) +@SingletonTraits(access = AllAccess.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) final class AArch64NativePatchConsumerFactory extends PatchConsumerFactory.NativePatchConsumerFactory { @Override public Consumer newConsumer(CompilationResult compilationResult) { diff --git a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64Feature.java b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64Feature.java index 916902f82319..386d2f36c950 100644 --- a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64Feature.java +++ b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64Feature.java @@ -67,23 +67,13 @@ class SubstrateAArch64Feature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(SubstrateRegisterConfigFactory.class, new SubstrateRegisterConfigFactory() { - @Override - public RegisterConfig newRegisterFactory(ConfigKind config, MetaAccessProvider metaAccess, TargetDescription target, Boolean preserveFramePointer) { - return new SubstrateAArch64RegisterConfig(config, metaAccess, target, preserveFramePointer); - } - }); + ImageSingletons.add(SubstrateRegisterConfigFactory.class, new SubstrateAArch64RegisterConfigFactory()); ImageSingletons.add(ReservedRegisters.class, new AArch64ReservedRegisters()); if (!SubstrateOptions.useLLVMBackend()) { - ImageSingletons.add(SubstrateBackendFactory.class, new SubstrateBackendFactory() { - @Override - public SubstrateBackend newBackend(Providers newProviders) { - return new SubstrateAArch64Backend(newProviders); - } - }); + ImageSingletons.add(SubstrateBackendFactory.class, new SubstrateAArch64BackendFactory()); ImageSingletons.add(SubstrateLoweringProviderFactory.class, new SubstrateAArch64LoweringProviderFactory()); @@ -100,6 +90,22 @@ public void duringSetup(DuringSetupAccess access) { } } +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) +class SubstrateAArch64RegisterConfigFactory implements SubstrateRegisterConfigFactory { + @Override + public RegisterConfig newRegisterFactory(ConfigKind config, MetaAccessProvider metaAccess, TargetDescription target, Boolean preserveFramePointer) { + return new SubstrateAArch64RegisterConfig(config, metaAccess, target, preserveFramePointer); + } +} + +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) +class SubstrateAArch64BackendFactory extends SubstrateBackendFactory { + @Override + public SubstrateBackend newBackend(Providers newProviders) { + return new SubstrateAArch64Backend(newProviders); + } +} + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) class SubstrateAArch64LoweringProviderFactory extends SubstrateVectorArchitectureFactory implements SubstrateLoweringProviderFactory { diff --git a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64SuitesCreatorProvider.java b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64SuitesCreatorProvider.java index 3e2cbb1b038b..d8a7cec23af0 100644 --- a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64SuitesCreatorProvider.java +++ b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64SuitesCreatorProvider.java @@ -25,10 +25,15 @@ */ package com.oracle.svm.core.graal.aarch64; -import jdk.graal.compiler.core.phases.EconomyCompilerConfiguration; - import com.oracle.svm.core.graal.code.SubstrateSuitesCreatorProvider; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; + +import jdk.graal.compiler.core.phases.EconomyCompilerConfiguration; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public class SubstrateAArch64SuitesCreatorProvider extends SubstrateSuitesCreatorProvider { public SubstrateAArch64SuitesCreatorProvider() { super(new AArch64SubstrateSuitesCreator(getHostedCompilerConfiguration()), diff --git a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64NativeImagePatcher.java b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64NativeImagePatcher.java index f6a19963f955..b50222e5bf67 100644 --- a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64NativeImagePatcher.java +++ b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64NativeImagePatcher.java @@ -26,20 +26,26 @@ import java.util.function.Consumer; -import jdk.graal.compiler.asm.Assembler; -import jdk.graal.compiler.asm.amd64.AMD64BaseAssembler.AddressDisplacementAnnotation; -import jdk.graal.compiler.asm.amd64.AMD64BaseAssembler.OperandDataAnnotation; -import jdk.graal.compiler.code.CompilationResult; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.graal.code.NativeImagePatcher; import com.oracle.svm.core.graal.code.PatchConsumerFactory; -import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; +import jdk.graal.compiler.asm.Assembler; +import jdk.graal.compiler.asm.amd64.AMD64BaseAssembler.AddressDisplacementAnnotation; +import jdk.graal.compiler.asm.amd64.AMD64BaseAssembler.OperandDataAnnotation; +import jdk.graal.compiler.code.CompilationResult; + @AutomaticallyRegisteredImageSingleton(PatchConsumerFactory.NativePatchConsumerFactory.class) @Platforms(Platform.AMD64.class) +@SingletonTraits(access = AllAccess.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) final class AMD64NativePatchConsumerFactory extends PatchConsumerFactory.NativePatchConsumerFactory { @Override public Consumer newConsumer(CompilationResult compilationResult) { diff --git a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64Feature.java b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64Feature.java index d6c7f1fc8949..c52745299d2e 100644 --- a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64Feature.java +++ b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64Feature.java @@ -68,23 +68,13 @@ class SubstrateAMD64Feature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(SubstrateRegisterConfigFactory.class, new SubstrateRegisterConfigFactory() { - @Override - public RegisterConfig newRegisterFactory(ConfigKind config, MetaAccessProvider metaAccess, TargetDescription target, Boolean preserveFramePointer) { - return new SubstrateAMD64RegisterConfig(config, metaAccess, target, preserveFramePointer); - } - }); + ImageSingletons.add(SubstrateRegisterConfigFactory.class, new SubstrateAMD64RegisterConfigFactory()); ImageSingletons.add(ReservedRegisters.class, new AMD64ReservedRegisters()); if (!SubstrateOptions.useLLVMBackend()) { - ImageSingletons.add(SubstrateBackendFactory.class, new SubstrateBackendFactory() { - @Override - public SubstrateBackend newBackend(Providers newProviders) { - return new SubstrateAMD64Backend(newProviders); - } - }); + ImageSingletons.add(SubstrateBackendFactory.class, new SubstrateAMD64BackendFactory()); ImageSingletons.add(SubstrateLoweringProviderFactory.class, new SubstrateAMD64LoweringProviderFactory()); @@ -101,6 +91,22 @@ public void duringSetup(DuringSetupAccess access) { } } +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) +class SubstrateAMD64RegisterConfigFactory implements SubstrateRegisterConfigFactory { + @Override + public RegisterConfig newRegisterFactory(ConfigKind config, MetaAccessProvider metaAccess, TargetDescription target, Boolean preserveFramePointer) { + return new SubstrateAMD64RegisterConfig(config, metaAccess, target, preserveFramePointer); + } +} + +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) +class SubstrateAMD64BackendFactory extends SubstrateBackendFactory { + @Override + public SubstrateBackend newBackend(Providers newProviders) { + return new SubstrateAMD64Backend(newProviders); + } +} + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) class SubstrateAMD64LoweringProviderFactory extends SubstrateVectorArchitectureFactory implements SubstrateLoweringProviderFactory { diff --git a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64SuitesCreatorProvider.java b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64SuitesCreatorProvider.java index 32cefd1e630f..86d571416b3b 100644 --- a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64SuitesCreatorProvider.java +++ b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64SuitesCreatorProvider.java @@ -24,10 +24,15 @@ */ package com.oracle.svm.core.graal.amd64; -import jdk.graal.compiler.core.phases.EconomyCompilerConfiguration; - import com.oracle.svm.core.graal.code.SubstrateSuitesCreatorProvider; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; + +import jdk.graal.compiler.core.phases.EconomyCompilerConfiguration; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class SubstrateAMD64SuitesCreatorProvider extends SubstrateSuitesCreatorProvider { public SubstrateAMD64SuitesCreatorProvider() { super(new AMD64SubstrateSuitesCreator(getHostedCompilerConfiguration()), diff --git a/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMFeature.java b/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMFeature.java index b10147238798..1b77846b84ea 100644 --- a/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMFeature.java +++ b/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMFeature.java @@ -105,32 +105,13 @@ public void afterRegistration(AfterRegistrationAccess access) { ModuleSupport.accessPackagesToClass(ModuleSupport.Access.EXPORT, LLVMFeature.class, false, "jdk.internal.vm.ci", "jdk.vm.ci.code.site", "jdk.vm.ci.code", "jdk.vm.ci.meta"); - ImageSingletons.add(SubstrateBackendFactory.class, new SubstrateBackendFactory() { - @Override - public SubstrateBackend newBackend(Providers newProviders) { - return new SubstrateLLVMBackend(newProviders); - } - }); + ImageSingletons.add(SubstrateBackendFactory.class, new LLVMSubstrateBackendFactory()); ImageSingletons.add(SubstrateLoweringProviderFactory.class, SubstrateLLVMLoweringProvider::new); - ImageSingletons.add(NativeImageCodeCacheFactory.class, new NativeImageCodeCacheFactory() { - @Override - public NativeImageCodeCache newCodeCache(CompileQueue compileQueue, NativeImageHeap heap, Platform platform, Path tempDir) { - return new LLVMNativeImageCodeCache(compileQueue.getCompilationResults(), heap, platform, tempDir); - } - }); - - ImageSingletons.add(ObjectFileFactory.class, new ObjectFileFactory() { - @Override - public ObjectFile newObjectFile(int pageSize, Path tempDir, BigBang bb) { - if (LLVMOptions.UseLLVMDataSection.getValue()) { - return new LLVMObjectFile(pageSize, tempDir, bb); - } else { - return ObjectFile.getNativeObjectFile(pageSize); - } - } - }); + ImageSingletons.add(NativeImageCodeCacheFactory.class, new LLVMCodeCacheFactory()); + + ImageSingletons.add(ObjectFileFactory.class, new LLVMObjectFileFactory()); if (LLVMOptions.UseLLVMDataSection.getValue()) { ImageSingletons.add(CCompilerInvoker.class, new LLVMCCompilerInvoker(ImageSingletons.lookup(TemporaryBuildDirectoryProvider.class).getTemporaryBuildDirectory())); @@ -187,4 +168,32 @@ private static int getLLVMVersion() { return version; } } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) + private static final class LLVMSubstrateBackendFactory extends SubstrateBackendFactory { + @Override + public SubstrateBackend newBackend(Providers newProviders) { + return new SubstrateLLVMBackend(newProviders); + } + } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) + private static final class LLVMCodeCacheFactory extends NativeImageCodeCacheFactory { + @Override + public NativeImageCodeCache newCodeCache(CompileQueue compileQueue, NativeImageHeap heap, Platform platform, Path tempDir) { + return new LLVMNativeImageCodeCache(compileQueue.getCompilationResults(), heap, platform, tempDir); + } + } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) + private static final class LLVMObjectFileFactory implements ObjectFileFactory { + @Override + public ObjectFile newObjectFile(int pageSize, Path tempDir, BigBang bb) { + if (LLVMOptions.UseLLVMDataSection.getValue()) { + return new LLVMObjectFile(pageSize, tempDir, bb); + } else { + return ObjectFile.getNativeObjectFile(pageSize); + } + } + } } diff --git a/substratevm/src/com.oracle.svm.core.graal.riscv64/src/com/oracle/svm/core/graal/riscv64/SubstrateRISCV64Feature.java b/substratevm/src/com.oracle.svm.core.graal.riscv64/src/com/oracle/svm/core/graal/riscv64/SubstrateRISCV64Feature.java index bc3659f5a8e6..0949de1e9315 100644 --- a/substratevm/src/com.oracle.svm.core.graal.riscv64/src/com/oracle/svm/core/graal/riscv64/SubstrateRISCV64Feature.java +++ b/substratevm/src/com.oracle.svm.core.graal.riscv64/src/com/oracle/svm/core/graal/riscv64/SubstrateRISCV64Feature.java @@ -24,7 +24,6 @@ */ package com.oracle.svm.core.graal.riscv64; -import jdk.graal.compiler.debug.GraalError; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -35,7 +34,12 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.code.SubstrateRegisterConfigFactory; import com.oracle.svm.core.graal.meta.SubstrateRegisterConfig.ConfigKind; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; +import jdk.graal.compiler.debug.GraalError; import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.meta.MetaAccessProvider; @@ -47,12 +51,7 @@ class SubstrateRISCV64Feature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(SubstrateRegisterConfigFactory.class, new SubstrateRegisterConfigFactory() { - @Override - public RegisterConfig newRegisterFactory(ConfigKind config, MetaAccessProvider metaAccess, TargetDescription target, Boolean preserveFramePointer) { - return new SubstrateRISCV64RegisterConfig(config, metaAccess, target, preserveFramePointer); - } - }); + ImageSingletons.add(SubstrateRegisterConfigFactory.class, new SubstrateRISCV64RegisterConfigFactory()); ImageSingletons.add(ReservedRegisters.class, new RISCV64ReservedRegisters()); @@ -61,3 +60,11 @@ public RegisterConfig newRegisterFactory(ConfigKind config, MetaAccessProvider m } } } + +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) +class SubstrateRISCV64RegisterConfigFactory implements SubstrateRegisterConfigFactory { + @Override + public RegisterConfig newRegisterFactory(ConfigKind config, MetaAccessProvider metaAccess, TargetDescription target, Boolean preserveFramePointer) { + return new SubstrateRISCV64RegisterConfig(config, metaAccess, target, preserveFramePointer); + } +} diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateGlobalSigprofHandler.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateGlobalSigprofHandler.java index 42b717c03967..6af15abf5960 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateGlobalSigprofHandler.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateGlobalSigprofHandler.java @@ -27,7 +27,6 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -37,6 +36,8 @@ import com.oracle.svm.core.posix.headers.Time; import com.oracle.svm.core.util.TimeUtils; +import jdk.graal.compiler.word.Word; + /** * Support for POSIX global timer (see {@link PosixSubstrateSigprofHandler}). */ diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateSigprofHandlerFeature.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateSigprofHandlerFeature.java index 3ccb53d92821..1c59d8a2877f 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateSigprofHandlerFeature.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateSigprofHandlerFeature.java @@ -37,6 +37,7 @@ import com.oracle.svm.core.IsolateListenerSupportFeature; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.jfr.HasJfrSupport; import com.oracle.svm.core.jfr.JfrExecutionSamplerSupported; import com.oracle.svm.core.jfr.JfrFeature; @@ -58,6 +59,11 @@ @AutomaticallyRegisteredFeature public class PosixSubstrateSigprofHandlerFeature implements InternalFeature { + @Override + public boolean isInConfiguration(IsInConfigurationAccess access) { + return !ImageLayerBuildingSupport.buildingImageLayer(); + } + @Override public List> getRequiredFeatures() { return List.of(ThreadListenerSupportFeature.class, IsolateListenerSupportFeature.class, JfrFeature.class); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java index a3e2f2e7b989..615b4d7f11f5 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java @@ -43,9 +43,15 @@ import com.oracle.svm.core.posix.headers.Stdlib; import com.oracle.svm.core.posix.headers.Unistd; import com.oracle.svm.core.posix.headers.darwin.Foundation; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import jdk.graal.compiler.word.Word; +@SingletonTraits(access = AllAccess.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) @CLibrary(value = "darwin", requireStatic = true) public class DarwinSystemPropertiesSupport extends PosixSystemPropertiesSupport { @@ -128,6 +134,7 @@ protected String osVersionValue() { } } +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) @AutomaticallyRegisteredFeature class DarwinSystemPropertiesFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinVMLockSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinVMLockSupport.java index 00af899059df..698594bbf1f4 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinVMLockSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinVMLockSupport.java @@ -37,8 +37,13 @@ import com.oracle.svm.core.locks.VMSemaphore; import com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory; import com.oracle.svm.core.posix.pthread.PthreadVMLockSupport; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; @AutomaticallyRegisteredImageSingleton(VMLockSupport.class) +@SingletonTraits(access = AllAccess.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) final class DarwinVMLockSupport extends PthreadVMLockSupport { @Override diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSubstrateSigprofHandler.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSubstrateSigprofHandler.java index 792b53ec5766..243b46b86f37 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSubstrateSigprofHandler.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSubstrateSigprofHandler.java @@ -27,7 +27,6 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; @@ -47,13 +46,20 @@ import com.oracle.svm.core.thread.VMThreads; import com.oracle.svm.core.threadlocal.FastThreadLocalFactory; import com.oracle.svm.core.threadlocal.FastThreadLocalWord; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.TimeUtils; +import jdk.graal.compiler.word.Word; + /** * Linux supports both types of timers (see {@link PosixSubstrateSigprofHandler}). We use the * per-thread timer as it increases the number of recorded samples and provides more reliable * sampling. */ +@SingletonTraits(access = AllAccess.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public final class LinuxSubstrateSigprofHandler extends PosixSubstrateSigprofHandler { /* diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java index 00c32f6606ac..d061c94194f5 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java @@ -33,11 +33,19 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue; +import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.jdk.SystemPropertiesSupport; import com.oracle.svm.core.posix.PosixSystemPropertiesSupport; import com.oracle.svm.core.posix.headers.Stdlib; import com.oracle.svm.core.posix.headers.Utsname; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; +import com.oracle.svm.core.traits.SingletonTraits; +@SingletonTraits(access = AllAccess.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class) public class LinuxSystemPropertiesSupport extends PosixSystemPropertiesSupport { @Override @@ -88,9 +96,15 @@ protected String osVersionValue() { } } +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class LinuxSystemPropertiesFeature implements InternalFeature { + @Override + public boolean isInConfiguration(IsInConfigurationAccess access) { + return ImageLayerBuildingSupport.firstImageBuild(); + } + @Override public void duringSetup(DuringSetupAccess access) { ImageSingletons.add(RuntimeSystemPropertiesSupport.class, new LinuxSystemPropertiesSupport()); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxVMLockSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxVMLockSupport.java index 15ca7eb2eef8..60bfddaa5368 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxVMLockSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxVMLockSupport.java @@ -24,7 +24,6 @@ */ package com.oracle.svm.core.posix.linux; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -32,17 +31,29 @@ import com.oracle.svm.core.c.CIsolateData; import com.oracle.svm.core.c.CIsolateDataFactory; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.locks.VMLockSupport; import com.oracle.svm.core.locks.VMSemaphore; import com.oracle.svm.core.posix.headers.Semaphore; import com.oracle.svm.core.posix.pthread.PthreadVMLockSupport; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; +import com.oracle.svm.core.traits.SingletonTraits; +import com.oracle.svm.core.util.VMError; + +import jdk.graal.compiler.word.Word; @AutomaticallyRegisteredImageSingleton(VMLockSupport.class) +@SingletonTraits(access = AllAccess.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class) final class LinuxVMLockSupport extends PthreadVMLockSupport { @Override @Platforms(Platform.HOSTED_ONLY.class) protected VMSemaphore replaceSemaphore(VMSemaphore source) { + if (ImageLayerBuildingSupport.buildingExtensionLayer()) { + throw VMError.shouldNotReachHere("A VM semaphore is added in an extension layer, which is unsupported", source); + } return new LinuxVMSemaphore(source.getName()); } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadVMLockSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadVMLockSupport.java index 612b5753b375..ae0f3c4c0376 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadVMLockSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadVMLockSupport.java @@ -26,7 +26,6 @@ import static com.oracle.svm.core.heap.RestrictHeapAccess.Access.NO_ALLOCATION; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.LogHandler; import org.graalvm.nativeimage.Platform; @@ -37,6 +36,7 @@ import com.oracle.svm.core.c.CIsolateDataFactory; import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue; import com.oracle.svm.core.heap.RestrictHeapAccess; +import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.jdk.UninterruptibleUtils; import com.oracle.svm.core.locks.VMCondition; import com.oracle.svm.core.locks.VMLockSupport; @@ -47,18 +47,27 @@ import com.oracle.svm.core.posix.headers.Time; import com.oracle.svm.core.stack.StackOverflowCheck; import com.oracle.svm.core.thread.VMThreads.SafepointBehavior; +import com.oracle.svm.core.util.VMError; + +import jdk.graal.compiler.word.Word; public abstract class PthreadVMLockSupport extends VMLockSupport { @Override @Platforms(Platform.HOSTED_ONLY.class) protected VMMutex replaceVMMutex(VMMutex source) { + if (ImageLayerBuildingSupport.buildingExtensionLayer()) { + throw VMError.shouldNotReachHere("A VM mutex is added in an extension layer, which is unsupported", source); + } return new PthreadVMMutex(source.getName()); } @Override @Platforms(Platform.HOSTED_ONLY.class) protected VMCondition replaceVMCondition(VMCondition source) { + if (ImageLayerBuildingSupport.buildingExtensionLayer()) { + throw VMError.shouldNotReachHere("A VM condition is added in an extension layer, which is unsupported", source); + } return new PthreadVMCondition((PthreadVMMutex) mutexReplacer.apply(source.getMutex()), source.getConditionName()); } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java index 80dca1fbd70f..107f0cb04376 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java @@ -24,7 +24,6 @@ */ package com.oracle.svm.core.posix.thread; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platform.HOSTED_ONLY; @@ -67,11 +66,16 @@ import com.oracle.svm.core.thread.Parker.ParkerFactory; import com.oracle.svm.core.thread.PlatformThreads; import com.oracle.svm.core.thread.VMThreads.OSThreadHandle; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.BasedOnJDKFile; import com.oracle.svm.core.util.UnsignedUtils; import com.oracle.svm.core.util.VMError; import jdk.graal.compiler.core.common.SuppressFBWarnings; +import jdk.graal.compiler.word.Word; import jdk.internal.misc.Unsafe; @AutomaticallyRegisteredImageSingleton(PlatformThreads.class) @@ -442,6 +446,7 @@ protected void release() { } } +@SingletonTraits(access = AllAccess.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class) @AutomaticallyRegisteredImageSingleton(ParkerFactory.class) class PosixParkerFactory implements Parker.ParkerFactory { @Override diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java index 50f83e9fb913..57b2d4b0ca39 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java @@ -41,6 +41,10 @@ import com.oracle.svm.core.thread.Parker.ParkerFactory; import com.oracle.svm.core.thread.PlatformThreads; import com.oracle.svm.core.thread.VMThreads.OSThreadHandle; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.BasedOnJDKFile; import com.oracle.svm.core.util.TimeUtils; import com.oracle.svm.core.util.VMError; @@ -272,6 +276,7 @@ protected void release() { } } +@SingletonTraits(access = AllAccess.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) @AutomaticallyRegisteredImageSingleton(ParkerFactory.class) class WindowsParkerFactory implements ParkerFactory { @Override diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java index 14649c53a57f..ef2af1e016b3 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java @@ -45,6 +45,11 @@ import com.oracle.svm.core.jdk.SystemPropertiesSupport; import com.oracle.svm.core.memory.NullableNativeMemory; import com.oracle.svm.core.nmt.NmtCategory; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.core.windows.headers.FileAPI; import com.oracle.svm.core.windows.headers.LibLoaderAPI; @@ -58,6 +63,7 @@ import jdk.graal.compiler.word.Word; +@SingletonTraits(access = AllAccess.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public class WindowsSystemPropertiesSupport extends SystemPropertiesSupport { /* Null-terminated wide-character string constants. */ @@ -391,6 +397,7 @@ private void computeOsNameAndVersion() { } } +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) @AutomaticallyRegisteredFeature class WindowsSystemPropertiesFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMLockSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMLockSupport.java index da6c58b309d4..1bcd553f189f 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMLockSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMLockSupport.java @@ -43,6 +43,10 @@ import com.oracle.svm.core.log.Log; import com.oracle.svm.core.stack.StackOverflowCheck; import com.oracle.svm.core.thread.VMThreads.SafepointBehavior; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.windows.headers.Process; import com.oracle.svm.core.windows.headers.SynchAPI; import com.oracle.svm.core.windows.headers.WinBase; @@ -50,6 +54,7 @@ import jdk.graal.compiler.word.Word; @AutomaticallyRegisteredImageSingleton(VMLockSupport.class) +@SingletonTraits(access = AllAccess.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public final class WindowsVMLockSupport extends VMLockSupport { @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/PinnedPrimitiveArrayViewSupportImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/PinnedPrimitiveArrayViewSupportImpl.java index c92b455b9d95..27fc02957e51 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/PinnedPrimitiveArrayViewSupportImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/PinnedPrimitiveArrayViewSupportImpl.java @@ -30,9 +30,22 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.RuntimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; +import com.oracle.svm.core.traits.SingletonTraits; @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) final class PinnedPrimitiveArrayViewFeature implements InternalFeature { + @Override + public boolean isInConfiguration(IsInConfigurationAccess access) { + return ImageLayerBuildingSupport.firstImageBuild(); + } + @Override public void beforeAnalysis(BeforeAnalysisAccess access) { if (!ImageSingletons.contains(PrimitiveArrayViewSupport.class)) { @@ -41,6 +54,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { } } +@SingletonTraits(access = RuntimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class) final class PinnedPrimitiveArrayViewSupportImpl implements PrimitiveArrayViewSupport { static final class PinnedPrimitiveElementArrayReferenceImpl implements PrimitiveArrayView { private final PinnedObject pinnedObject; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetHttpFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetHttpFeature.java index c29a02a92b74..d6d304065dc7 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetHttpFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetHttpFeature.java @@ -34,8 +34,13 @@ import com.oracle.svm.configure.ResourcesRegistry; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class JavaNetHttpFeature extends JNIRegistrationUtil implements InternalFeature { private static Optional requiredModule() { @@ -72,6 +77,7 @@ private static void registerInitFiltersAccess(DuringAnalysisAccess a) { } @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) class SimpleWebServerFeature implements InternalFeature { private static Optional requiredModule() { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java index 610fe370d688..006650bf26cf 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java @@ -48,7 +48,14 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.handles.PrimitiveArrayView; import com.oracle.svm.core.headers.LibC; +import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.option.HostedOptionKey; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.RuntimeAccessOnly; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import jdk.graal.compiler.options.Option; @@ -114,6 +121,7 @@ private static String getSystemTimeZoneID(String javaHome) { /** * Holds time zone mapping data. */ +@SingletonTraits(access = RuntimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) final class TimeZoneSupport { final byte[] tzMappingsContent; @@ -130,6 +138,7 @@ public byte[] getTzMappingsContent() { * Reads time zone mappings data and stores in the image heap, if necessary. */ @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) final class TimeZoneFeature implements InternalFeature { static class Options { @Option(help = "When true, all time zones will be pre-initialized in the image.")// @@ -156,6 +165,11 @@ private static void printWarning() { } } + @Override + public boolean isInConfiguration(IsInConfigurationAccess access) { + return ImageLayerBuildingSupport.lastImageBuild(); + } + private static byte[] cleanCR(byte[] buffer) { byte[] scratch = new byte[buffer.length]; int copied = 0; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/layeredimagesingleton/LoadedLayeredImageSingletonInfo.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/layeredimagesingleton/LoadedLayeredImageSingletonInfo.java index e352a954db11..2d084710039e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/layeredimagesingleton/LoadedLayeredImageSingletonInfo.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/layeredimagesingleton/LoadedLayeredImageSingletonInfo.java @@ -24,10 +24,19 @@ */ package com.oracle.svm.core.layeredimagesingleton; +import java.util.Set; + import org.graalvm.nativeimage.ImageSingletons; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; -import java.util.Set; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; +@Platforms(Platform.HOSTED_ONLY.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class LoadedLayeredImageSingletonInfo { private final Set> loadedKeys; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMLockSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMLockSupport.java index c0293a87e1bf..ea2ac30e687d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMLockSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMLockSupport.java @@ -39,11 +39,16 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.log.Log; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.ImageHeapList; import jdk.graal.compiler.api.replacements.Fold; @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) final class VMLockFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/UnmanagedMemorySupportImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/UnmanagedMemorySupportImpl.java index 602dfb7f4876..dc576d7dce21 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/UnmanagedMemorySupportImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/UnmanagedMemorySupportImpl.java @@ -24,7 +24,6 @@ */ package com.oracle.svm.core.memory; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.impl.UnmanagedMemorySupport; import org.graalvm.word.PointerBase; @@ -34,14 +33,23 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.headers.LibCSupport; +import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.UnsignedUtils; import jdk.graal.compiler.api.replacements.Fold; +import jdk.graal.compiler.word.Word; /** * Delegates to the libc-specific memory management functions. Some platforms use a different * implementation. */ +@SingletonTraits(access = AllAccess.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class) class UnmanagedMemorySupportImpl implements UnmanagedMemorySupport { @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -79,7 +87,13 @@ static LibCSupport libc() { } @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) class UnmanagedMemorySupportFeature implements InternalFeature { + @Override + public boolean isInConfiguration(IsInConfigurationAccess access) { + return ImageLayerBuildingSupport.firstImageBuild(); + } + @Override public void duringSetup(DuringSetupAccess access) { if (!ImageSingletons.contains(UnmanagedMemorySupport.class)) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/metadata/MetadataTracer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/metadata/MetadataTracer.java index 383eb8dd15f6..ed6ff484bc24 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/metadata/MetadataTracer.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/metadata/MetadataTracer.java @@ -59,6 +59,10 @@ import com.oracle.svm.core.option.RuntimeOptionKey; import com.oracle.svm.core.option.SubstrateOptionsParser; import com.oracle.svm.core.thread.VMOperation; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import jdk.graal.compiler.options.Option; @@ -70,6 +74,7 @@ * reachability metadata, and then the run-time option {@link Options#TraceMetadata} enables * tracing. */ +@SingletonTraits(access = AllAccess.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public final class MetadataTracer { public static class Options { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MonitorFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MonitorFeature.java index 9a948b6b6729..6e5f98f25372 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MonitorFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MonitorFeature.java @@ -35,6 +35,11 @@ import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; +import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import jdk.graal.compiler.graph.Node; import jdk.graal.compiler.options.OptionValues; @@ -42,11 +47,14 @@ @AutomaticallyRegisteredFeature @Platforms(InternalPlatform.NATIVE_ONLY.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class MonitorFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(MonitorSupport.class, new MultiThreadedMonitorSupport()); + if (ImageLayerBuildingSupport.firstImageBuild()) { + ImageSingletons.add(MonitorSupport.class, new MultiThreadedMonitorSupport()); + } } @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MultiThreadedMonitorSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MultiThreadedMonitorSupport.java index 11d43bf3a7f7..b1e387b76e1b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MultiThreadedMonitorSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MultiThreadedMonitorSupport.java @@ -52,6 +52,10 @@ import com.oracle.svm.core.thread.JavaThreads; import com.oracle.svm.core.thread.ThreadStatus; import com.oracle.svm.core.thread.VMOperationControl; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import jdk.graal.compiler.core.common.SuppressFBWarnings; @@ -93,6 +97,7 @@ * object monitor needs a condition object, it is atomically swapped into its * {@link JavaMonitorConditionObject} field. */ +@SingletonTraits(access = AllAccess.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class) public class MultiThreadedMonitorSupport extends MonitorSupport { private static final Unsafe UNSAFE = Unsafe.getUnsafe(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationSupport.java index 4036379d99bf..95c205743023 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationSupport.java @@ -24,7 +24,6 @@ */ package com.oracle.svm.core.thread; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -40,11 +39,17 @@ import com.oracle.svm.core.heap.StoredContinuationAccess; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.snippets.KnownIntrinsics; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; +import com.oracle.svm.core.traits.SingletonTraits; import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.options.Option; import jdk.graal.compiler.options.OptionType; +import jdk.graal.compiler.word.Word; +@SingletonTraits(access = AllAccess.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class) public class ContinuationSupport { static final class Options { @Option(type = OptionType.Expert, help = "Support for continuations which are used by virtual threads. " + diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationsFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationsFeature.java index 111b092ca164..7d916e4d1f2d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationsFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationsFeature.java @@ -39,13 +39,26 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heap.StoredContinuation; import com.oracle.svm.core.heap.StoredContinuationAccess; +import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; +import com.oracle.svm.core.layeredimagesingleton.ImageSingletonLoader; +import com.oracle.svm.core.layeredimagesingleton.ImageSingletonWriter; +import com.oracle.svm.core.layeredimagesingleton.LayeredPersistFlags; +import com.oracle.svm.core.thread.ContinuationsFeature.LayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.SingletonLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredCallbacksSupplier; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTrait; +import com.oracle.svm.core.traits.SingletonTraitKind; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = LayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class ContinuationsFeature implements InternalFeature { - private Boolean supported; + private boolean supported; public static boolean isSupported() { return ImageSingletons.lookup(ContinuationsFeature.class).supported; @@ -58,6 +71,8 @@ public List> getRequiredFeatures() { @Override public void afterRegistration(AfterRegistrationAccess access) { + boolean previousLayerSupported = supported; + /* If continuations are not supported, "virtual" threads are bound to platform threads. */ if (ContinuationSupport.Options.VMContinuations.getValue()) { boolean hostSupport = jdk.internal.vm.ContinuationSupport.isSupported(); @@ -76,12 +91,16 @@ public void afterRegistration(AfterRegistrationAccess access) { } else { supported = false; } + + if (ImageLayerBuildingSupport.buildingExtensionLayer()) { + VMError.guarantee(supported == previousLayerSupported, "The previous layer supported value was %b, but the one from the current layer is %b", previousLayerSupported, supported); + } } @Override public void beforeAnalysis(BeforeAnalysisAccess access) { if (isSupported()) { - if (!ImageSingletons.contains(ContinuationSupport.class)) { + if (!ImageSingletons.contains(ContinuationSupport.class) && ImageLayerBuildingSupport.firstImageBuild()) { ImageSingletons.add(ContinuationSupport.class, new ContinuationSupport()); } @@ -97,10 +116,29 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { @Override public void beforeCompilation(BeforeCompilationAccess access) { - if (isSupported()) { + if (isSupported() && ImageLayerBuildingSupport.firstImageBuild()) { Field ipField = ReflectionUtil.lookupField(StoredContinuation.class, "ip"); long offset = access.objectFieldOffset(ipField); ContinuationSupport.singleton().setIPOffset(offset); } } + + static class LayeredCallbacks extends SingletonLayeredCallbacksSupplier { + @Override + public SingletonTrait getLayeredCallbacksTrait() { + var action = new SingletonLayeredCallbacks() { + @Override + public LayeredPersistFlags doPersist(ImageSingletonWriter writer, ContinuationsFeature singleton) { + writer.writeInt("supported", ContinuationsFeature.isSupported() ? 1 : 0); + return LayeredPersistFlags.CALLBACK_ON_REGISTRATION; + } + + @Override + public void onSingletonRegistration(ImageSingletonLoader loader, ContinuationsFeature singleton) { + singleton.supported = loader.readInt("supported") == 1; + } + }; + return new SingletonTrait(SingletonTraitKind.LAYERED_CALLBACKS, action); + } + } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HostedConfiguration.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HostedConfiguration.java index 4a6ae9e2451f..b7ee7ad14f8c 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HostedConfiguration.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HostedConfiguration.java @@ -364,24 +364,30 @@ private static void setMonitorField(HostedUniverse hUniverse, AnalysisType type) } public NativeImageCodeCacheFactory newCodeCacheFactory() { - return new NativeImageCodeCacheFactory() { - @Override - public NativeImageCodeCache newCodeCache(CompileQueue compileQueue, NativeImageHeap heap, Platform targetPlatform, Path tempDir) { - return new LIRNativeImageCodeCache(compileQueue.getCompilationResults(), heap); - } - }; + return new DefaultNativeImageCodeCacheFactory(); } public ObjectFileFactory newObjectFileFactory() { - return new ObjectFileFactory() { - @Override - public ObjectFile newObjectFile(int pageSize, Path tempDir, BigBang bb) { - return ObjectFile.getNativeObjectFile(pageSize); - } - }; + return new DefaultObjectFileFactory(); } public HeapBreakdownProvider createHeapBreakdownProvider() { return new HeapBreakdownProvider(); } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) + private static final class DefaultNativeImageCodeCacheFactory extends NativeImageCodeCacheFactory { + @Override + public NativeImageCodeCache newCodeCache(CompileQueue compileQueue, NativeImageHeap heap, Platform targetPlatform, Path tempDir) { + return new LIRNativeImageCodeCache(compileQueue.getCompilationResults(), heap); + } + } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) + private static final class DefaultObjectFileFactory implements ObjectFileFactory { + @Override + public ObjectFile newObjectFile(int pageSize, Path tempDir, BigBang bb) { + return ObjectFile.getNativeObjectFile(pageSize); + } + } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ImageSingletonsSupportImpl.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ImageSingletonsSupportImpl.java index bcbf20c26485..2c144af4a62a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ImageSingletonsSupportImpl.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ImageSingletonsSupportImpl.java @@ -51,11 +51,14 @@ import com.oracle.svm.core.layeredimagesingleton.LayeredPersistFlags; import com.oracle.svm.core.layeredimagesingleton.LoadedLayeredImageSingletonInfo; import com.oracle.svm.core.layeredimagesingleton.SingletonAccessFlags; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; import com.oracle.svm.core.traits.SingletonAccess; import com.oracle.svm.core.traits.SingletonAccessSupplier; import com.oracle.svm.core.traits.SingletonLayeredCallbacks; import com.oracle.svm.core.traits.SingletonLayeredCallbacksSupplier; import com.oracle.svm.core.traits.SingletonLayeredInstallationKind; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; import com.oracle.svm.core.traits.SingletonLayeredInstallationKindSupplier; import com.oracle.svm.core.traits.SingletonTrait; import com.oracle.svm.core.traits.SingletonTraitKind; @@ -71,6 +74,7 @@ import jdk.graal.compiler.debug.Assertions; import jdk.vm.ci.meta.JavaConstant; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public final class ImageSingletonsSupportImpl extends ImageSingletonsSupport implements LayeredImageSingletonSupport { @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/RuntimeMetadataEncoderImpl.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/RuntimeMetadataEncoderImpl.java index 9ea32bc94215..c3da631ef083 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/RuntimeMetadataEncoderImpl.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/RuntimeMetadataEncoderImpl.java @@ -97,6 +97,7 @@ import com.oracle.svm.core.reflect.target.EncodedRuntimeMetadataSupplier; import com.oracle.svm.core.reflect.target.Target_jdk_internal_reflect_ConstantPool; import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; import com.oracle.svm.core.traits.SingletonLayeredCallbacks; import com.oracle.svm.core.traits.SingletonLayeredCallbacksSupplier; import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; @@ -154,6 +155,7 @@ public class RuntimeMetadataEncoderImpl implements RuntimeMetadataEncoder { @AutomaticallyRegisteredImageSingleton(ReflectionMetadataEncoderFactory.class) + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) static class Factory implements ReflectionMetadataEncoderFactory { @Override public RuntimeMetadataEncoder create(SnippetReflectionProvider snippetReflection, CodeInfoEncoder.Encoders encoders) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedPatcherFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedPatcherFeature.java index 892d6bf3fcf0..0195ba4e274c 100755 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedPatcherFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedPatcherFeature.java @@ -26,7 +26,6 @@ import java.util.function.Consumer; -import com.oracle.svm.util.ClassUtil; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -39,10 +38,15 @@ import com.oracle.svm.core.graal.code.PatchConsumerFactory; import com.oracle.svm.core.meta.MethodPointer; import com.oracle.svm.core.meta.SubstrateMethodPointerConstant; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.code.HostedPatcher; import com.oracle.svm.hosted.image.RelocatableBuffer; import com.oracle.svm.hosted.meta.HostedMethod; +import com.oracle.svm.util.ClassUtil; import jdk.graal.compiler.asm.Assembler.CodeAnnotation; import jdk.graal.compiler.asm.aarch64.AArch64Assembler.SingleInstructionAnnotation; @@ -59,25 +63,28 @@ public class AArch64HostedPatcherFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(PatchConsumerFactory.HostedPatchConsumerFactory.class, new PatchConsumerFactory.HostedPatchConsumerFactory() { - @Override - public Consumer newConsumer(CompilationResult compilationResult) { - return new Consumer<>() { - @Override - public void accept(CodeAnnotation annotation) { - if (annotation instanceof SingleInstructionAnnotation) { - compilationResult.addAnnotation(new SingleInstructionHostedPatcher((SingleInstructionAnnotation) annotation)); - } else if (annotation instanceof AArch64MacroAssembler.MovSequenceAnnotation) { - compilationResult.addAnnotation(new MovSequenceHostedPatcher((AArch64MacroAssembler.MovSequenceAnnotation) annotation)); - } else if (annotation instanceof AArch64MacroAssembler.AdrpLdrMacroInstruction) { - compilationResult.addAnnotation(new AdrpLdrMacroInstructionHostedPatcher((AArch64MacroAssembler.AdrpLdrMacroInstruction) annotation)); - } else if (annotation instanceof AArch64MacroAssembler.AdrpAddMacroInstruction) { - compilationResult.addAnnotation(new AdrpAddMacroInstructionHostedPatcher((AArch64MacroAssembler.AdrpAddMacroInstruction) annotation)); - } + ImageSingletons.add(PatchConsumerFactory.HostedPatchConsumerFactory.class, new AArch64HostedPatchConsumerFactory()); + } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) + private static final class AArch64HostedPatchConsumerFactory extends PatchConsumerFactory.HostedPatchConsumerFactory { + @Override + public Consumer newConsumer(CompilationResult compilationResult) { + return new Consumer<>() { + @Override + public void accept(CodeAnnotation annotation) { + if (annotation instanceof SingleInstructionAnnotation) { + compilationResult.addAnnotation(new SingleInstructionHostedPatcher((SingleInstructionAnnotation) annotation)); + } else if (annotation instanceof AArch64MacroAssembler.MovSequenceAnnotation) { + compilationResult.addAnnotation(new MovSequenceHostedPatcher((AArch64MacroAssembler.MovSequenceAnnotation) annotation)); + } else if (annotation instanceof AArch64MacroAssembler.AdrpLdrMacroInstruction) { + compilationResult.addAnnotation(new AdrpLdrMacroInstructionHostedPatcher((AArch64MacroAssembler.AdrpLdrMacroInstruction) annotation)); + } else if (annotation instanceof AArch64MacroAssembler.AdrpAddMacroInstruction) { + compilationResult.addAnnotation(new AdrpAddMacroInstructionHostedPatcher((AArch64MacroAssembler.AdrpAddMacroInstruction) annotation)); } - }; - } - }); + } + }; + } } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedPatcherFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedPatcherFeature.java index de484b72408d..db0aa2b0747b 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedPatcherFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedPatcherFeature.java @@ -49,7 +49,7 @@ import com.oracle.svm.hosted.meta.HostedMethod; import com.oracle.svm.util.ClassUtil; -import jdk.graal.compiler.asm.Assembler; +import jdk.graal.compiler.asm.Assembler.CodeAnnotation; import jdk.graal.compiler.asm.amd64.AMD64BaseAssembler.AddressDisplacementAnnotation; import jdk.graal.compiler.asm.amd64.AMD64BaseAssembler.OperandDataAnnotation; import jdk.graal.compiler.code.CompilationResult; @@ -65,23 +65,26 @@ class AMD64HostedPatcherFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(PatchConsumerFactory.HostedPatchConsumerFactory.class, new PatchConsumerFactory.HostedPatchConsumerFactory() { - @Override - public Consumer newConsumer(CompilationResult compilationResult) { - return new Consumer<>() { - @Override - public void accept(Assembler.CodeAnnotation annotation) { - if (annotation instanceof OperandDataAnnotation) { - compilationResult.addAnnotation(new AMD64HostedPatcher((OperandDataAnnotation) annotation)); + ImageSingletons.add(PatchConsumerFactory.HostedPatchConsumerFactory.class, new AMD64HostedPatchConsumerFactory()); + } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) + private static final class AMD64HostedPatchConsumerFactory extends PatchConsumerFactory.HostedPatchConsumerFactory { + @Override + public Consumer newConsumer(CompilationResult compilationResult) { + return new Consumer<>() { + @Override + public void accept(CodeAnnotation annotation) { + if (annotation instanceof OperandDataAnnotation) { + compilationResult.addAnnotation(new AMD64HostedPatcher((OperandDataAnnotation) annotation)); - } else if (annotation instanceof AddressDisplacementAnnotation) { - AddressDisplacementAnnotation dispAnnotation = (AddressDisplacementAnnotation) annotation; - compilationResult.addAnnotation(new HostedImageHeapConstantPatch(dispAnnotation.operandPosition, (JavaConstant) dispAnnotation.annotation)); - } + } else if (annotation instanceof AddressDisplacementAnnotation) { + AddressDisplacementAnnotation dispAnnotation = (AddressDisplacementAnnotation) annotation; + compilationResult.addAnnotation(new HostedImageHeapConstantPatch(dispAnnotation.operandPosition, (JavaConstant) dispAnnotation.annotation)); } - }; - } - }); + } + }; + } } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/ImageHeapCollectionFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/ImageHeapCollectionFeature.java index 49febaf7be67..c6a1126626dc 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/ImageHeapCollectionFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/ImageHeapCollectionFeature.java @@ -34,6 +34,10 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.ImageHeapList.HostedImageHeapList; import com.oracle.svm.core.util.ImageHeapMap.HostedImageHeapMap; import com.oracle.svm.core.util.LayeredHostedImageHeapMapCollector; @@ -42,6 +46,7 @@ import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) final class ImageHeapCollectionFeature implements InternalFeature { private final Set> allMaps = ConcurrentHashMap.newKeySet(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/ObservableImageHeapMapProviderImpl.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/ObservableImageHeapMapProviderImpl.java index 74db0497fb95..f6b5e0148ae9 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/ObservableImageHeapMapProviderImpl.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/ObservableImageHeapMapProviderImpl.java @@ -34,6 +34,10 @@ import com.oracle.graal.pointsto.heap.ImageHeapScanner; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.ObservableImageHeapMapProvider; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import com.oracle.svm.hosted.util.ObservableMap; @@ -78,6 +82,7 @@ private void registerWithScanner(ObservableMap map) { } @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) final class ObservableHeapMapFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/DisallowedImageHeapObjectFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/DisallowedImageHeapObjectFeature.java index 6f17f80943aa..3bc2a633b64a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/DisallowedImageHeapObjectFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/DisallowedImageHeapObjectFeature.java @@ -56,6 +56,10 @@ import com.oracle.svm.core.image.DisallowedImageHeapObjects; import com.oracle.svm.core.jdk.management.ManagementSupport; import com.oracle.svm.core.option.SubstrateOptionsParser; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.classinitialization.ClassInitializationOptions; import com.oracle.svm.hosted.classinitialization.ClassInitializationSupport; @@ -64,6 +68,7 @@ * Complain if there are types that can not move from the image generator heap to the image heap. */ @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class DisallowedImageHeapObjectFeature implements InternalFeature { private ClassInitializationSupport classInitialization; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/ImageHeapFillerObjectsFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/ImageHeapFillerObjectsFeature.java index be83a9750f1d..da3e5877d04c 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/ImageHeapFillerObjectsFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/ImageHeapFillerObjectsFeature.java @@ -27,10 +27,15 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heap.FillerObject; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import com.oracle.svm.util.ReflectionUtil; @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) class ImageHeapFillerObjectsFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess arg) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/MethodPointerRelocationProvider.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/MethodPointerRelocationProvider.java index ab1325d94799..d205449752ef 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/MethodPointerRelocationProvider.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/MethodPointerRelocationProvider.java @@ -32,10 +32,15 @@ import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.meta.MethodOffset; import com.oracle.svm.core.meta.MethodPointer; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.imagelayer.LayeredDispatchTableFeature; import com.oracle.svm.hosted.meta.HostedMethod; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class MethodPointerRelocationProvider { private final boolean imageLayer = ImageLayerBuildingSupport.buildingImageLayer(); @@ -70,6 +75,7 @@ public void markMethodOffsetRelocation(ObjectFile.ProgbitsSectionImpl section, i } } +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class MethodPointerRelocationProviderFeature implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java index ddee04590a95..244fb9b0d9a9 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java @@ -103,6 +103,10 @@ import com.oracle.svm.core.option.SubstrateOptionsParser; import com.oracle.svm.core.os.ImageHeapProvider; import com.oracle.svm.core.reflect.SubstrateAccessor; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.ByteFormattingUtil; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; @@ -1107,6 +1111,7 @@ protected NativeTextSectionImpl(RelocatableBuffer relocatableBuffer, ObjectFile } } +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature final class MethodPointerInvalidHandlerFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoStripFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoStripFeature.java index 789851a1644b..1932cc851687 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoStripFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoStripFeature.java @@ -36,6 +36,10 @@ import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.InterruptImageBuilding; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; @@ -47,6 +51,7 @@ import jdk.graal.compiler.debug.Indent; @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class NativeImageDebugInfoStripFeature implements InternalFeature { private Boolean hasStrippedSuccessfully = null; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/AtomicFieldUpdaterFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/AtomicFieldUpdaterFeature.java index aa5a985cdc94..ceb4286e3f9a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/AtomicFieldUpdaterFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/AtomicFieldUpdaterFeature.java @@ -33,6 +33,10 @@ import com.oracle.graal.pointsto.ObjectScanner; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.util.ReflectionUtil; @@ -45,6 +49,7 @@ * offset) and mark it as unsafe accessed. */ @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) class AtomicFieldUpdaterFeature implements InternalFeature { private boolean sealed = false; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/UniverseBuilder.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/UniverseBuilder.java index 2d116b943341..020aaf1a12bd 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/UniverseBuilder.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/UniverseBuilder.java @@ -96,6 +96,10 @@ import com.oracle.svm.core.meta.MethodRef; import com.oracle.svm.core.reflect.SubstrateConstructorAccessor; import com.oracle.svm.core.reflect.SubstrateMethodAccessor; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.DeadlockWatchdog; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; @@ -1068,13 +1072,17 @@ private static boolean excludeFromReferenceMap(HostedField field) { } @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) final class InvalidVTableEntryFeature implements InternalFeature { + @Override + public boolean isInConfiguration(IsInConfigurationAccess access) { + return ImageLayerBuildingSupport.lastImageBuild(); + } + @Override public void beforeAnalysis(BeforeAnalysisAccess a) { BeforeAnalysisAccessImpl access = (BeforeAnalysisAccessImpl) a; - if (ImageLayerBuildingSupport.lastImageBuild()) { - access.registerAsRoot(InvalidMethodPointerHandler.INVALID_VTABLE_ENTRY_HANDLER_METHOD, true, "Registered in " + InvalidVTableEntryFeature.class); - } + access.registerAsRoot(InvalidMethodPointerHandler.INVALID_VTABLE_ENTRY_HANDLER_METHOD, true, "Registered in " + InvalidVTableEntryFeature.class); } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/option/RuntimeOptionFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/option/RuntimeOptionFeature.java index b76a55c5881c..e1ba7c86bde1 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/option/RuntimeOptionFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/option/RuntimeOptionFeature.java @@ -39,6 +39,10 @@ import com.oracle.svm.core.option.HostedOptionValues; import com.oracle.svm.core.option.RuntimeOptionKey; import com.oracle.svm.core.option.RuntimeOptionParser; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl; @@ -46,6 +50,7 @@ import jdk.graal.compiler.options.OptionKey; @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class RuntimeOptionFeature implements InternalFeature { private RuntimeOptionParser runtimeOptionParser; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/EnumSwitchPlugin.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/EnumSwitchPlugin.java index 04b8b166ff3c..a29c9acaf9c9 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/EnumSwitchPlugin.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/EnumSwitchPlugin.java @@ -25,6 +25,8 @@ package com.oracle.svm.hosted.phases; import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -36,9 +38,21 @@ import com.oracle.svm.core.classinitialization.EnsureClassInitializedNode; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; +import com.oracle.svm.core.layeredimagesingleton.ImageSingletonLoader; +import com.oracle.svm.core.layeredimagesingleton.ImageSingletonWriter; +import com.oracle.svm.core.layeredimagesingleton.LayeredPersistFlags; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.SingletonLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredCallbacksSupplier; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTrait; +import com.oracle.svm.core.traits.SingletonTraitKind; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; import com.oracle.svm.hosted.code.SubstrateCompilationDirectives; +import com.oracle.svm.hosted.phases.EnumSwitchFeature.LayeredCallbacks; import com.oracle.svm.util.ReflectionUtil; import jdk.graal.compiler.debug.GraalError; @@ -119,11 +133,19 @@ public boolean handleInvoke(GraphBuilderContext b, ResolvedJavaMethod m, ValueNo } @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = LayeredCallbacks.class, layeredInstallationKind = Independent.class) final class EnumSwitchFeature implements InternalFeature { + private static final String METHODS_ID = "methodsId"; + private static final String METHODS_MULTI_METHOD_KEY_NAME = "methodsMultiMethodKeyName"; + private static final String METHODS_SAFE = "methodsSafe"; + private BigBang bb; - private ConcurrentMap methodsSafeForExecution = new ConcurrentHashMap<>(); + private ConcurrentMap methodsSafeForExecution = new ConcurrentHashMap<>(); + + private record AnalysisMethodKey(int id, String multiMethodKeyName) { + } @Override public void duringSetup(DuringSetupAccess a) { @@ -135,14 +157,23 @@ public void duringSetup(DuringSetupAccess a) { private void onMethodParsed(AnalysisMethod method, StructuredGraph graph) { boolean methodSafeForExecution = graph.getNodes().filter(node -> node instanceof EnsureClassInitializedNode).isEmpty(); - Boolean existingValue = methodsSafeForExecution.put(method, methodSafeForExecution); + Boolean existingValue = methodsSafeForExecution.put(new AnalysisMethodKey(method.getId(), method.getMultiMethodKey().toString()), methodSafeForExecution); + if (!(existingValue == null || SubstrateCompilationDirectives.isDeoptTarget(method))) { + System.out.println("f"); + } assert existingValue == null || SubstrateCompilationDirectives.isDeoptTarget(method) : "Method parsed twice: " + method.format("%H.%n(%p)"); } @Override public void afterAnalysis(AfterAnalysisAccess access) { bb = null; - methodsSafeForExecution = null; + /* + * When building a Layered Image, the methods that are safe for execution need to be + * persisted across layers. + */ + if (!ImageLayerBuildingSupport.buildingImageLayer()) { + methodsSafeForExecution = null; + } } @Override @@ -151,10 +182,45 @@ public void registerGraphBuilderPlugins(Providers providers, Plugins plugins, Pa } Boolean isMethodsSafeForExecution(AnalysisMethod method) { - return methodsSafeForExecution.get(method); + return methodsSafeForExecution.get(new AnalysisMethodKey(method.getId(), method.getMultiMethodKey().toString())); } public BigBang getBigBang() { return bb; } + + static class LayeredCallbacks extends SingletonLayeredCallbacksSupplier { + @Override + public SingletonTrait getLayeredCallbacksTrait() { + return new SingletonTrait(SingletonTraitKind.LAYERED_CALLBACKS, new SingletonLayeredCallbacks() { + @Override + public LayeredPersistFlags doPersist(ImageSingletonWriter writer, EnumSwitchFeature singleton) { + List methodsId = new ArrayList<>(); + List methodsMultiMethodKey = new ArrayList<>(); + List methodsSafe = new ArrayList<>(); + for (var entry : singleton.methodsSafeForExecution.entrySet()) { + AnalysisMethodKey key = entry.getKey(); + methodsId.add(key.id()); + methodsMultiMethodKey.add(key.multiMethodKeyName()); + methodsSafe.add(entry.getValue()); + } + writer.writeIntList(METHODS_ID, methodsId); + writer.writeStringList(METHODS_MULTI_METHOD_KEY_NAME, methodsMultiMethodKey); + writer.writeBoolList(METHODS_SAFE, methodsSafe); + return LayeredPersistFlags.CALLBACK_ON_REGISTRATION; + } + + @Override + public void onSingletonRegistration(ImageSingletonLoader loader, EnumSwitchFeature singleton) { + List methodsId = loader.readIntList(METHODS_ID); + List methodsMultiMethodKeyName = loader.readStringList(METHODS_MULTI_METHOD_KEY_NAME); + List methodsSafe = loader.readBoolList(METHODS_SAFE); + ConcurrentMap methodsSafeForExecution = singleton.methodsSafeForExecution; + for (int i = 0; i < methodsId.size(); ++i) { + methodsSafeForExecution.put(new AnalysisMethodKey(methodsId.get(i), methodsMultiMethodKeyName.get(i)), methodsSafe.get(i)); + } + } + }); + } + } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/ReduceImplicitExceptionStackTraceInformationPhase.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/ReduceImplicitExceptionStackTraceInformationPhase.java index 9cd53053f373..3b92db831300 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/ReduceImplicitExceptionStackTraceInformationPhase.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/ReduceImplicitExceptionStackTraceInformationPhase.java @@ -38,6 +38,10 @@ import com.oracle.svm.core.graal.phases.RemoveUnwindPhase; import com.oracle.svm.core.graal.snippets.NonSnippetLowerings; import com.oracle.svm.core.snippets.ImplicitExceptions; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import jdk.graal.compiler.core.common.spi.ForeignCallDescriptor; @@ -60,6 +64,7 @@ import jdk.graal.compiler.phases.util.Providers; @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) class ReduceImplicitExceptionStackTraceInformationFeature implements InternalFeature { @Override public void registerGraalPhases(Providers providers, Suites suites, boolean hosted, boolean fallback) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/DynamicProxyFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/DynamicProxyFeature.java index 6078c6ce298c..ac0334fa1bd7 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/DynamicProxyFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/DynamicProxyFeature.java @@ -27,6 +27,7 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.dynamicaccess.AccessCondition; import org.graalvm.nativeimage.impl.RuntimeProxyCreationSupport; +import org.graalvm.nativeimage.impl.RuntimeProxyRegistrySupport; import com.oracle.svm.configure.ConfigurationFile; import com.oracle.svm.configure.ProxyConfigurationParser; @@ -36,6 +37,10 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.proxy.DynamicProxyRegistry; import com.oracle.svm.core.reflect.proxy.DynamicProxySupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FallbackFeature; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; @@ -43,9 +48,9 @@ import com.oracle.svm.hosted.classinitialization.ClassInitializationSupport; import com.oracle.svm.hosted.config.ConfigurationParserUtils; import com.oracle.svm.hosted.reflect.NativeImageConditionResolver; -import org.graalvm.nativeimage.impl.RuntimeProxyRegistrySupport; @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public final class DynamicProxyFeature implements InternalFeature { private int loadedConfigurations; private ProxyRegistry proxyRegistry; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/ProxyRegistry.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/ProxyRegistry.java index 28a445ac81ab..dd9f1683c2c5 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/ProxyRegistry.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/ProxyRegistry.java @@ -31,10 +31,15 @@ import org.graalvm.nativeimage.impl.RuntimeProxyRegistrySupport; import com.oracle.svm.core.jdk.proxy.DynamicProxyRegistry; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.ConditionalConfigurationRegistry; import com.oracle.svm.hosted.ImageClassLoader; import com.oracle.svm.util.LogUtils; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class ProxyRegistry extends ConditionalConfigurationRegistry implements RuntimeProxyRegistrySupport, BiConsumer> { private final DynamicProxyRegistry dynamicProxySupport; private final ImageClassLoader imageClassLoader; diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageFeature.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageFeature.java index e62a38d8a8d4..17699994770e 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageFeature.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageFeature.java @@ -77,6 +77,10 @@ import com.oracle.svm.core.log.Loggers; import com.oracle.svm.core.log.NoopLog; import com.oracle.svm.core.option.HostedOptionValues; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.HostedConfiguration; @@ -116,6 +120,7 @@ import jdk.graal.compiler.phases.util.Providers; import jdk.vm.ci.meta.ResolvedJavaMethod; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) @AutomaticallyRegisteredFeature @Platforms(WebImagePlatform.class) public class WebImageFeature implements InternalFeature { diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageHostedConfiguration.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageHostedConfiguration.java index 029c895e0b32..15d8fd8e13c1 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageHostedConfiguration.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageHostedConfiguration.java @@ -52,6 +52,10 @@ import com.oracle.svm.core.config.ObjectLayout; import com.oracle.svm.core.config.ObjectLayout.IdentityHashMode; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureHandler; import com.oracle.svm.hosted.HeapBreakdownProvider; import com.oracle.svm.hosted.HostedConfiguration; @@ -192,16 +196,7 @@ public void collectMonitorFieldInfo(BigBang bb, HostedUniverse hUniverse, Set new WebImageCodeCache(compileQueue.getCompilationResults(), heap); - case WASM -> new WebImageWasmCodeCache(compileQueue.getCompilationResults(), heap); - case WASMGC -> new WebImageWasmGCCodeCache(compileQueue.getCompilationResults(), heap); - }; - } - }; + return new WebImageCodeCacheFactory(); } @@ -230,4 +225,16 @@ public CompileQueue createCompileQueue(DebugContext debug, FeatureHandler featur case WASMGC -> new WebImageWasmGCCompileQueue(featureHandler, hostedUniverse, runtimeConfiguration, debug); }; } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) + private static final class WebImageCodeCacheFactory extends NativeImageCodeCacheFactory { + @Override + public NativeImageCodeCache newCodeCache(CompileQueue compileQueue, NativeImageHeap heap, Platform targetPlatform, Path tempDir) { + return switch (getBackend()) { + case JS -> new WebImageCodeCache(compileQueue.getCompilationResults(), heap); + case WASM -> new WebImageWasmCodeCache(compileQueue.getCompilationResults(), heap); + case WASMGC -> new WebImageWasmGCCodeCache(compileQueue.getCompilationResults(), heap); + }; + } + } } diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageJSFeature.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageJSFeature.java index ef357c1f2740..0b0917c42a92 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageJSFeature.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageJSFeature.java @@ -40,8 +40,13 @@ import com.oracle.svm.core.graal.code.SubstrateSuitesCreatorProvider; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; +import com.oracle.svm.core.graal.meta.SubstrateRegisterConfig.ConfigKind; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; import com.oracle.svm.core.graal.snippets.SubstrateAllocationSnippets; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.webimage.codegen.WebImageJSBackend; import com.oracle.svm.hosted.webimage.codegen.WebImageNoRegisterConfig; import com.oracle.svm.hosted.webimage.codegen.phase.WebImageJSSuitesCreatorProvider; @@ -53,6 +58,9 @@ import jdk.graal.compiler.options.OptionValues; import jdk.graal.compiler.phases.util.Providers; import jdk.graal.compiler.replacements.TargetGraphBuilderPlugins; +import jdk.vm.ci.code.RegisterConfig; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.meta.MetaAccessProvider; @AutomaticallyRegisteredFeature @Platforms(WebImageJSPlatform.class) @@ -65,15 +73,10 @@ public void registerForeignCalls(SubstrateForeignCallsProvider foreignCalls) { @Override public void afterRegistration(Feature.AfterRegistrationAccess access) { - ImageSingletons.add(SubstrateRegisterConfigFactory.class, (config, metaAccess, target, preserveFramePointer) -> new WebImageNoRegisterConfig()); + ImageSingletons.add(SubstrateRegisterConfigFactory.class, new WebImageSubstrateRegisterConfigFactory()); // TODO: Introduce separate backends and lowering providers for WebImageJSPlatform. - ImageSingletons.add(SubstrateBackendFactory.class, new SubstrateBackendFactory() { - @Override - public SubstrateBackend newBackend(Providers newProviders) { - return new WebImageJSBackend(newProviders); - } - }); + ImageSingletons.add(SubstrateBackendFactory.class, new WebImageSubstrateBackendFactory()); ImageSingletons.add(SubstrateLoweringProviderFactory.class, WebImageJSLoweringProvider::new); ImageSingletons.add(TargetGraphBuilderPlugins.class, new JSGraphBuilderPlugins()); @@ -88,4 +91,20 @@ public void registerLowerings(RuntimeConfiguration runtimeConfig, OptionValues o SubstrateAllocationSnippets.Templates templates = new SubstrateAllocationSnippets.Templates(options, providers, allocationSnippets); templates.registerLowering(lowerings); } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) + private static final class WebImageSubstrateRegisterConfigFactory implements SubstrateRegisterConfigFactory { + @Override + public RegisterConfig newRegisterFactory(ConfigKind config, MetaAccessProvider metaAccess, TargetDescription target, Boolean preserveFramePointer) { + return new WebImageNoRegisterConfig(); + } + } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) + private static final class WebImageSubstrateBackendFactory extends SubstrateBackendFactory { + @Override + public SubstrateBackend newBackend(Providers newProviders) { + return new WebImageJSBackend(newProviders); + } + } } diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/codegen/phase/WebImageJSSuitesCreatorProvider.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/codegen/phase/WebImageJSSuitesCreatorProvider.java index 0948b8a05d47..f6a802a21a36 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/codegen/phase/WebImageJSSuitesCreatorProvider.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/codegen/phase/WebImageJSSuitesCreatorProvider.java @@ -26,7 +26,12 @@ package com.oracle.svm.hosted.webimage.codegen.phase; import com.oracle.svm.core.graal.code.SubstrateSuitesCreatorProvider; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public class WebImageJSSuitesCreatorProvider extends SubstrateSuitesCreatorProvider { public WebImageJSSuitesCreatorProvider() { super(new WebImageJSSuitesCreator(), new WebImageJSSuitesCreator()); diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/WebImageWasmLMFeature.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/WebImageWasmLMFeature.java index 08e0e4a1a3b4..99611e511202 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/WebImageWasmLMFeature.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/WebImageWasmLMFeature.java @@ -39,8 +39,13 @@ import com.oracle.svm.core.graal.code.SubstrateRegisterConfigFactory; import com.oracle.svm.core.graal.code.SubstrateSuitesCreatorProvider; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; +import com.oracle.svm.core.graal.meta.SubstrateRegisterConfig.ConfigKind; import com.oracle.svm.core.graal.snippets.ExceptionSnippets; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.webimage.codegen.WebImageNoRegisterConfig; import com.oracle.svm.hosted.webimage.wasm.codegen.WasmAssembler; import com.oracle.svm.hosted.webimage.wasm.codegen.WebImageWasmLMBackend; @@ -52,6 +57,9 @@ import jdk.graal.compiler.options.OptionValues; import jdk.graal.compiler.phases.util.Providers; import jdk.graal.compiler.replacements.TargetGraphBuilderPlugins; +import jdk.vm.ci.code.RegisterConfig; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.meta.MetaAccessProvider; @AutomaticallyRegisteredFeature @Platforms(WebImageWasmLMPlatform.class) @@ -64,16 +72,11 @@ public void duringSetup(DuringSetupAccess access) { @Override public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(SubstrateRegisterConfigFactory.class, (config, metaAccess, target, preserveFramePointer) -> new WebImageNoRegisterConfig()); + ImageSingletons.add(SubstrateRegisterConfigFactory.class, new WebImageWasmLMSubstrateRegisterConfigFactory()); ImageSingletons.add(ReservedRegisters.class, new WebImageWasmReservedRegisters()); - ImageSingletons.add(SubstrateBackendFactory.class, new SubstrateBackendFactory() { - @Override - public SubstrateBackend newBackend(Providers newProviders) { - return new WebImageWasmLMBackend(newProviders); - } - }); + ImageSingletons.add(SubstrateBackendFactory.class, new WebImageWasmLMSubstrateBackendFactory()); ImageSingletons.add(SubstrateLoweringProviderFactory.class, WebImageWasmLMLoweringProvider::new); ImageSingletons.add(TargetGraphBuilderPlugins.class, new WasmLMGraphBuilderPlugins()); @@ -84,4 +87,20 @@ public SubstrateBackend newBackend(Providers newProviders) { public void registerLowerings(RuntimeConfiguration runtimeConfig, OptionValues options, Providers providers, Map, NodeLoweringProvider> lowerings, boolean hosted) { lowerings.put(LoadExceptionObjectNode.class, new ExceptionSnippets.LoadExceptionObjectLowering()); } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) + private static final class WebImageWasmLMSubstrateRegisterConfigFactory implements SubstrateRegisterConfigFactory { + @Override + public RegisterConfig newRegisterFactory(ConfigKind config, MetaAccessProvider metaAccess, TargetDescription target, Boolean preserveFramePointer) { + return new WebImageNoRegisterConfig(); + } + } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) + private static final class WebImageWasmLMSubstrateBackendFactory extends SubstrateBackendFactory { + @Override + public SubstrateBackend newBackend(Providers newProviders) { + return new WebImageWasmLMBackend(newProviders); + } + } } diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/phases/WebImageWasmLMSuitesCreatorProvider.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/phases/WebImageWasmLMSuitesCreatorProvider.java index 6caaf02220c6..7de2be058abb 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/phases/WebImageWasmLMSuitesCreatorProvider.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/phases/WebImageWasmLMSuitesCreatorProvider.java @@ -26,7 +26,12 @@ package com.oracle.svm.hosted.webimage.wasm.phases; import com.oracle.svm.core.graal.code.SubstrateSuitesCreatorProvider; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public class WebImageWasmLMSuitesCreatorProvider extends SubstrateSuitesCreatorProvider { public WebImageWasmLMSuitesCreatorProvider() { super(new WebImageWasmLMSuitesCreator(), new WebImageWasmLMSuitesCreator()); diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasmgc/WebImageWasmGCFeature.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasmgc/WebImageWasmGCFeature.java index 03509745dccf..456a83f7de8f 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasmgc/WebImageWasmGCFeature.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasmgc/WebImageWasmGCFeature.java @@ -43,10 +43,15 @@ import com.oracle.svm.core.graal.code.SubstrateSuitesCreatorProvider; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; +import com.oracle.svm.core.graal.meta.SubstrateRegisterConfig.ConfigKind; import com.oracle.svm.core.graal.snippets.ExceptionSnippets; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; import com.oracle.svm.core.graal.snippets.SubstrateAllocationSnippets; import com.oracle.svm.core.snippets.SnippetRuntime; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import com.oracle.svm.hosted.webimage.WebImageFeature; import com.oracle.svm.hosted.webimage.codegen.WebImageNoRegisterConfig; @@ -65,6 +70,9 @@ import jdk.graal.compiler.options.OptionValues; import jdk.graal.compiler.phases.util.Providers; import jdk.graal.compiler.replacements.TargetGraphBuilderPlugins; +import jdk.vm.ci.code.RegisterConfig; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.meta.MetaAccessProvider; @AutomaticallyRegisteredFeature @Platforms(WebImageWasmGCPlatform.class) @@ -81,14 +89,9 @@ public List> getRequiredFeatures() { @Override public void afterRegistration(Feature.AfterRegistrationAccess access) { - ImageSingletons.add(SubstrateRegisterConfigFactory.class, (config, metaAccess, target, preserveFramePointer) -> new WebImageNoRegisterConfig()); + ImageSingletons.add(SubstrateRegisterConfigFactory.class, new WebImageWasmGCSubstrateRegisterConfigFactory()); - ImageSingletons.add(SubstrateBackendFactory.class, new SubstrateBackendFactory() { - @Override - public SubstrateBackend newBackend(Providers newProviders) { - return new WebImageWasmGCBackend(newProviders); - } - }); + ImageSingletons.add(SubstrateBackendFactory.class, new WebImageWasmGCSubstrateBackendFactory()); ImageSingletons.add(SubstrateLoweringProviderFactory.class, WebImageWasmGCLoweringProvider::new); ImageSingletons.add(TargetGraphBuilderPlugins.class, new WasmGCGraphBuilderPlugins()); @@ -150,4 +153,20 @@ public void registerLowerings(RuntimeConfiguration runtimeConfig, OptionValues o public void beforeCompilation(BeforeCompilationAccess access) { WasmGCAllocationSupport.preRegisterAllocationTemplates((WebImageWasmGCProviders) ImageSingletons.lookup(WebImageProviders.class)); } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) + private static final class WebImageWasmGCSubstrateRegisterConfigFactory implements SubstrateRegisterConfigFactory { + @Override + public RegisterConfig newRegisterFactory(ConfigKind config, MetaAccessProvider metaAccess, TargetDescription target, Boolean preserveFramePointer) { + return new WebImageNoRegisterConfig(); + } + } + + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) + private static final class WebImageWasmGCSubstrateBackendFactory extends SubstrateBackendFactory { + @Override + public SubstrateBackend newBackend(Providers newProviders) { + return new WebImageWasmGCBackend(newProviders); + } + } } diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasmgc/phases/WebImageWasmGCSuitesCreatorProvider.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasmgc/phases/WebImageWasmGCSuitesCreatorProvider.java index 2d9d5b7f5101..37393c0f802e 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasmgc/phases/WebImageWasmGCSuitesCreatorProvider.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasmgc/phases/WebImageWasmGCSuitesCreatorProvider.java @@ -26,7 +26,12 @@ package com.oracle.svm.hosted.webimage.wasmgc.phases; import com.oracle.svm.core.graal.code.SubstrateSuitesCreatorProvider; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public class WebImageWasmGCSuitesCreatorProvider extends SubstrateSuitesCreatorProvider { public WebImageWasmGCSuitesCreatorProvider() { diff --git a/web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/threads/WebImageMonitorFeature.java b/web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/threads/WebImageMonitorFeature.java index 26e3b2c07249..8260de855ebc 100644 --- a/web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/threads/WebImageMonitorFeature.java +++ b/web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/threads/WebImageMonitorFeature.java @@ -30,8 +30,13 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.monitor.MonitorSupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public class WebImageMonitorFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { diff --git a/web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/threads/WebImageSingleThreadedMonitorSupport.java b/web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/threads/WebImageSingleThreadedMonitorSupport.java index 0fd4d868fe45..8ebb6e455caa 100644 --- a/web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/threads/WebImageSingleThreadedMonitorSupport.java +++ b/web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/threads/WebImageSingleThreadedMonitorSupport.java @@ -28,10 +28,15 @@ import com.oracle.svm.core.monitor.MonitorInflationCause; import com.oracle.svm.core.monitor.MonitorSupport; import com.oracle.svm.core.thread.ThreadStatus; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; /** * Without support for threads, there is no need for any monitor operations. */ +@SingletonTraits(access = AllAccess.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public class WebImageSingleThreadedMonitorSupport extends MonitorSupport { @Override public void monitorEnter(Object obj, MonitorInflationCause cause) { diff --git a/web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/threads/WebImageSingleThreadedVMLockSupport.java b/web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/threads/WebImageSingleThreadedVMLockSupport.java index 17dc64fe6483..aed8dee860bc 100644 --- a/web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/threads/WebImageSingleThreadedVMLockSupport.java +++ b/web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/threads/WebImageSingleThreadedVMLockSupport.java @@ -33,6 +33,10 @@ import com.oracle.svm.core.locks.VMLockSupport; import com.oracle.svm.core.locks.VMMutex; import com.oracle.svm.core.locks.VMSemaphore; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; /** @@ -40,6 +44,7 @@ * environments. No real locking is necessary. */ @AutomaticallyRegisteredImageSingleton(VMLockSupport.class) +@SingletonTraits(access = AllAccess.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) final class WebImageSingleThreadedVMLockSupport extends VMLockSupport { @Override protected VMMutex replaceVMMutex(VMMutex source) {