Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion substratevm/mx.substratevm/mx_substratevm_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
ignore_files = {"copy_x86.hpp", "copy_aarch64.hpp", "osThread_linux.hpp"}
ignore_includes = {"CPU_HEADER(copy)", "OS_HEADER(osThread)"}

files_with_cpp_guard = {"sharedGCStructs.hpp"}
files_with_cpp_guard = {"sharedGCStructs.h", "shenandoahGCStructs.h", "g1GCStructs.h"}

SVM_NAMESPACE = "svm_namespace"

Expand Down
2 changes: 2 additions & 0 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,8 @@
"dependency:com.oracle.svm.native.jvm.posix/*",
"dependency:com.oracle.svm.native.libcontainer/*",
"file:debug/include",
"file:src/com.oracle.svm.core/src/com/oracle/svm/core/gc/shared/include",
"file:src/com.oracle.svm.core/src/com/oracle/svm/core/gc/shenandoah/include",
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public String getName() {
}

@Override
@Platforms(Platform.HOSTED_ONLY.class)
public String getDefaultMaxHeapSize() {
return String.format("%s%% of RAM", SerialAndEpsilonGCOptions.MaximumHeapSizePercent.getValue());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.core.posix.linux.shenandoah;

import org.graalvm.word.UnsignedWord;

import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton;
import com.oracle.svm.core.gc.shenandoah.ShenandoahCommittedMemoryProvider;
import com.oracle.svm.core.gc.shenandoah.UseShenandoahGC;
import com.oracle.svm.core.heap.PhysicalMemory.PhysicalMemorySupport;
import com.oracle.svm.core.posix.linux.LinuxPhysicalMemorySupportImpl;
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.SingletonTraits;

@AutomaticallyRegisteredImageSingleton(value = PhysicalMemorySupport.class, onlyWith = UseShenandoahGC.class)
@SingletonTraits(access = RuntimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class)
public class ShenandoahPhysicalMemorySupport extends LinuxPhysicalMemorySupportImpl {
@Override
public UnsignedWord size() {
return ShenandoahCommittedMemoryProvider.getInstance().getPhysicalMemorySize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -588,12 +588,12 @@ public HostedOptionKey<ReplacingLocatableMultiOptionValue.DelimitedString> multi

@Option(help = "Please use '--gc=*' instead. Possible values are listed with '--help'.")//
public static final HostedOptionKey<ReplacingLocatableMultiOptionValue.DelimitedString> SupportedGCs = new HostedOptionKey<>(
ReplacingLocatableMultiOptionValue.DelimitedString.buildWithCommaDelimiter(GCOptionValue.SERIAL.getValue())) {
ReplacingLocatableMultiOptionValue.DelimitedString.buildWithCommaDelimiter(GCOptionValue.Serial.getValue())) {
@Override
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, ReplacingLocatableMultiOptionValue.DelimitedString oldValue,
ReplacingLocatableMultiOptionValue.DelimitedString newValue) {

if (newValue.contains(GCOptionValue.G1.getValue())) {
if (newValue.contains(GCOptionValue.G1.getValue()) || newValue.contains(GCOptionValue.Shenandoah.getValue())) {
SubstrateOptions.SpawnIsolates.update(values, true);
SubstrateOptions.AllowVMInternalThreads.update(values, true);
SubstrateOptions.ConcealedOptions.UseDedicatedVMOperationThread.update(values, true);
Expand All @@ -602,24 +602,28 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Replacing

super.onValueUpdate(values, oldValue, newValue);
}

};

@Fold
public static boolean useSerialGC() {
return !SubstrateOptions.SupportedGCs.hasBeenSet() || SubstrateOptions.SupportedGCs.getValue().contains(GCOptionValue.SERIAL.getValue());
return !SubstrateOptions.SupportedGCs.hasBeenSet() || SubstrateOptions.SupportedGCs.getValue().contains(GCOptionValue.Serial.getValue());
}

@Fold
public static boolean useEpsilonGC() {
return SubstrateOptions.SupportedGCs.getValue().contains(GCOptionValue.EPSILON.getValue());
return SubstrateOptions.SupportedGCs.getValue().contains(GCOptionValue.Epsilon.getValue());
}

@Fold
public static boolean useG1GC() {
return SubstrateOptions.SupportedGCs.getValue().contains(GCOptionValue.G1.getValue());
}

@Fold
public static boolean useShenandoahGC() {
return SubstrateOptions.SupportedGCs.getValue().contains(GCOptionValue.Shenandoah.getValue());
}

public static class DeprecatedOptions {

@LayerVerifiedOption(kind = Kind.Changed, severity = Severity.Error)//
Expand All @@ -629,9 +633,9 @@ public static class DeprecatedOptions {
@Override
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean oldValue, Boolean newValue) {
if (newValue) {
SubstrateOptions.SupportedGCs.update(values, ReplacingLocatableMultiOptionValue.DelimitedString.buildWithCommaDelimiter(GCOptionValue.SERIAL.getValue()));
SubstrateOptions.SupportedGCs.update(values, ReplacingLocatableMultiOptionValue.DelimitedString.buildWithCommaDelimiter(GCOptionValue.Serial.getValue()));
} else if (!values.containsKey(SubstrateOptions.SupportedGCs) ||
((ReplacingLocatableMultiOptionValue.DelimitedString) values.get(SubstrateOptions.SupportedGCs)).contains(GCOptionValue.SERIAL.getValue())) {
((ReplacingLocatableMultiOptionValue.DelimitedString) values.get(SubstrateOptions.SupportedGCs)).contains(GCOptionValue.Serial.getValue())) {
SubstrateOptions.SupportedGCs.update(values, ReplacingLocatableMultiOptionValue.DelimitedString.buildWithCommaDelimiter());
}
}
Expand All @@ -644,8 +648,23 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o
@Override
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean oldValue, Boolean newValue) {
if (newValue) {
SubstrateOptions.SupportedGCs.update(values, ReplacingLocatableMultiOptionValue.DelimitedString.buildWithCommaDelimiter(GCOptionValue.EPSILON.getValue()));
} else if (((AccumulatingLocatableMultiOptionValue.Strings) values.get(SubstrateOptions.SupportedGCs)).contains(GCOptionValue.EPSILON.getValue())) {
SubstrateOptions.SupportedGCs.update(values, ReplacingLocatableMultiOptionValue.DelimitedString.buildWithCommaDelimiter(GCOptionValue.Epsilon.getValue()));
} else if (((AccumulatingLocatableMultiOptionValue.Strings) values.get(SubstrateOptions.SupportedGCs)).contains(GCOptionValue.Epsilon.getValue())) {
SubstrateOptions.SupportedGCs.update(values, ReplacingLocatableMultiOptionValue.DelimitedString.buildWithCommaDelimiter());
}
}
};

@LayerVerifiedOption(kind = Kind.Changed, severity = Severity.Error)//
@APIOption(name = "shenandoah", group = GCGroup.class, customHelp = "Shenandoah garbage collector")//
@Option(help = "Use the Shenandoah GC", deprecated = true, deprecationMessage = "Please use '--gc=shenandoah' instead")//
public static final HostedOptionKey<Boolean> UseShenandoahGC = new HostedOptionKey<>(false) {
@Override
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean oldValue, Boolean newValue) {
if (newValue) {
SubstrateOptions.SupportedGCs.update(values, ReplacingLocatableMultiOptionValue.DelimitedString.buildWithCommaDelimiter(GCOptionValue.Shenandoah.getValue()));
} else if (!values.containsKey(SubstrateOptions.SupportedGCs) ||
((ReplacingLocatableMultiOptionValue.DelimitedString) values.get(SubstrateOptions.SupportedGCs)).contains(GCOptionValue.Shenandoah.getValue())) {
SubstrateOptions.SupportedGCs.update(values, ReplacingLocatableMultiOptionValue.DelimitedString.buildWithCommaDelimiter());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[[rule]]
files = "*"
all = [
"christian.haeubl@oracle.com",
]
any = [
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.core.gc.shared;

import org.graalvm.nativeimage.Isolate;
import org.graalvm.nativeimage.IsolateThread;

import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.c.function.CEntryPointOptions.Prologue;
import com.oracle.svm.core.graal.nodes.WriteCurrentVMThreadNode;
import com.oracle.svm.core.graal.snippets.CEntryPointSnippets;

/**
* Prologue that only initializes the base registers so that a thread can execute SVM code.
* Unattached threads need to pass null as the {@link IsolateThread}, so that this prologue behaves
* the same as {@link InitializeReservedRegistersForUnattachedThread}.
*/
public class InitializeReservedRegistersForPossiblyUnattachedThread implements Prologue {
@Uninterruptible(reason = "prologue")
@SuppressWarnings("unused")
public static void enter(Isolate heapBase, IsolateThread thread) {
CEntryPointSnippets.initBaseRegisters(heapBase);
WriteCurrentVMThreadNode.writeCurrentVMThread(thread);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.core.gc.shared;

import org.graalvm.nativeimage.Isolate;

import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.c.function.CEntryPointOptions.Prologue;
import com.oracle.svm.core.graal.nodes.WriteCurrentVMThreadNode;
import com.oracle.svm.core.graal.snippets.CEntryPointSnippets;

import jdk.graal.compiler.word.Word;

/**
* Prologue that only initializes the base registers so that an unattached thread can execute SVM
* code.
*/
public final class InitializeReservedRegistersForUnattachedThread implements Prologue {
@Uninterruptible(reason = "prologue")
@SuppressWarnings("unused")
public static void enter(Isolate heapBase) {
CEntryPointSnippets.initBaseRegisters(heapBase);
WriteCurrentVMThreadNode.writeCurrentVMThread(Word.nullPointer());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.core.gc.shared;

/** Defines which debug-levels are supported for GCs such as G1. */
public enum NativeGCDebugLevel {
Product("", 0),
FastDebug("-fastdebug", 1),
Debug("-debug", 2);

private final String libSuffix;
private final int index;

NativeGCDebugLevel(String libSuffix, int index) {
this.libSuffix = libSuffix;
this.index = index;
}

public String getLibSuffix() {
return libSuffix;
}

public int getIndex() {
return index;
}

public static NativeGCDebugLevel fromString(String value) {
return switch (value) {
case "product" -> Product;
case "fastdebug" -> FastDebug;
case "debug" -> Debug;
default -> null;
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.core.gc.shared;

import java.util.Collections;
import java.util.List;

import org.graalvm.nativeimage.c.CContext;

import com.oracle.svm.core.c.ProjectHeaderFile;

/**
* Determines which header files must be included when building a native-image that uses a GC such
* as G1.
*/
public class NativeGCHeaderFiles implements CContext.Directives {
@Override
public boolean isInConfiguration() {
return UseNativeGC.get();
}

@Override
public List<String> getHeaderFiles() {
return Collections.singletonList(ProjectHeaderFile.resolve("", "include/sharedGCStructs.h"));
}
}
Loading
Loading