Skip to content

Commit 3c9dd8b

Browse files
committed
Label PhysicalMemorySupport
1 parent 6243935 commit 3c9dd8b

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinPhysicalMemorySupportImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
package com.oracle.svm.core.posix.darwin;
2626

27-
import jdk.graal.compiler.word.Word;
2827
import org.graalvm.nativeimage.c.struct.SizeOf;
2928
import org.graalvm.nativeimage.c.type.CIntPointer;
3029
import org.graalvm.nativeimage.c.type.WordPointer;
@@ -37,8 +36,15 @@
3736
import com.oracle.svm.core.log.Log;
3837
import com.oracle.svm.core.posix.headers.Sysctl;
3938
import com.oracle.svm.core.posix.headers.darwin.DarwinSysctl;
39+
import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks;
40+
import com.oracle.svm.core.traits.BuiltinTraits.RuntimeAccessOnly;
41+
import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed;
42+
import com.oracle.svm.core.traits.SingletonTraits;
4043
import com.oracle.svm.core.util.VMError;
4144

45+
import jdk.graal.compiler.word.Word;
46+
47+
@SingletonTraits(access = RuntimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class)
4248
@AutomaticallyRegisteredImageSingleton(PhysicalMemorySupport.class)
4349
class DarwinPhysicalMemorySupportImpl implements PhysicalMemorySupport {
4450

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemorySupportImpl.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,17 @@
4141
import com.oracle.svm.core.heap.PhysicalMemory.PhysicalMemorySupport;
4242
import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport;
4343
import com.oracle.svm.core.posix.headers.Unistd;
44+
import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly;
45+
import com.oracle.svm.core.traits.BuiltinTraits.RuntimeAccessOnly;
46+
import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer;
47+
import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent;
48+
import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly;
49+
import com.oracle.svm.core.traits.SingletonTraits;
4450
import com.oracle.svm.core.util.VMError;
4551

4652
import jdk.graal.compiler.word.Word;
4753

54+
@SingletonTraits(access = RuntimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class)
4855
public class LinuxPhysicalMemorySupportImpl implements PhysicalMemorySupport {
4956

5057
private static final long K = 1024;
@@ -119,11 +126,17 @@ private static long parseFirstNumber(String str) {
119126
}
120127
}
121128

129+
@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class)
122130
@AutomaticallyRegisteredFeature
123131
class LinuxPhysicalMemorySupportFeature implements InternalFeature {
132+
@Override
133+
public boolean isInConfiguration(IsInConfigurationAccess access) {
134+
return ImageLayerBuildingSupport.firstImageBuild();
135+
}
136+
124137
@Override
125138
public void beforeAnalysis(BeforeAnalysisAccess access) {
126-
if (ImageLayerBuildingSupport.firstImageBuild() && !ImageSingletons.contains(PhysicalMemorySupport.class)) {
139+
if (!ImageSingletons.contains(PhysicalMemorySupport.class)) {
127140
ImageSingletons.add(PhysicalMemorySupport.class, new LinuxPhysicalMemorySupportImpl());
128141
}
129142
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,22 @@
2626

2727
import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE;
2828

29-
import jdk.graal.compiler.word.Word;
3029
import org.graalvm.nativeimage.c.struct.SizeOf;
3130
import org.graalvm.word.UnsignedWord;
3231

3332
import com.oracle.svm.core.Uninterruptible;
3433
import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton;
3534
import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue;
3635
import com.oracle.svm.core.heap.PhysicalMemory.PhysicalMemorySupport;
36+
import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks;
37+
import com.oracle.svm.core.traits.BuiltinTraits.RuntimeAccessOnly;
38+
import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed;
39+
import com.oracle.svm.core.traits.SingletonTraits;
3740
import com.oracle.svm.core.windows.headers.SysinfoAPI;
3841

42+
import jdk.graal.compiler.word.Word;
43+
44+
@SingletonTraits(access = RuntimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class)
3945
@AutomaticallyRegisteredImageSingleton(PhysicalMemorySupport.class)
4046
class WindowsPhysicalMemorySupportImpl implements PhysicalMemorySupport {
4147

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PhysicalMemory.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636
import com.oracle.svm.core.Uninterruptible;
3737
import com.oracle.svm.core.container.Container;
3838
import com.oracle.svm.core.container.OperatingSystem;
39-
import com.oracle.svm.core.traits.BuiltinTraits.RuntimeAccessOnly;
40-
import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer;
41-
import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly;
42-
import com.oracle.svm.core.traits.SingletonTraits;
4339
import com.oracle.svm.core.util.UnsignedUtils;
4440
import com.oracle.svm.core.util.VMError;
4541
import com.sun.management.OperatingSystemMXBean;
@@ -52,7 +48,6 @@
5248
public class PhysicalMemory {
5349

5450
/** Implemented by operating-system specific code. */
55-
@SingletonTraits(access = RuntimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class)
5651
public interface PhysicalMemorySupport {
5752
/** Get the size of physical memory from the OS. */
5853
UnsignedWord size();

0 commit comments

Comments
 (0)