Skip to content
Merged
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
4 changes: 1 addition & 3 deletions docs/reference-manual/native-image/FFM-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ Modules that are permitted to perform _restricted_ native operations (including

## Foreign Memory

Native Image supports most foreign memory features.
Support for shared arenas (`Arena.ofShared()`) is still experimental and needs to be explicitly enabled with `-H:+SharedArenaSupport` (together with `-H:+UnlockExperimentalVMOptions`).
Note: Building a native image that includes calls to `Arena.ofShared()` will still succeed even if support for shared arenas is disabled. However, an exception will be thrown at run time when the application attempts to close the shared arena.
Native Image supports all foreign memory features.

## Foreign Functions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1528,16 +1528,13 @@ public static boolean isForeignAPIEnabled() {
public static final HostedOptionKey<Boolean> VectorAPISupport = new HostedOptionKey<>(false);

@Option(help = "Enable support for Arena.ofShared ", type = Expert)//
public static final HostedOptionKey<Boolean> SharedArenaSupport = new HostedOptionKey<>(false, key -> {
if (key.getValue()) {
UserError.guarantee(isForeignAPIEnabled(), "Support for Arena.ofShared is only available with foreign API support. " +
"Enable foreign API support with %s",
SubstrateOptionsParser.commandArgument(ForeignAPISupport, "+"));

public static final HostedOptionKey<Boolean> SharedArenaSupport = new HostedOptionKey<>(true, key -> {
if (isSharedArenaSupportEnabled()) {
// GR-65162: Shared arenas cannot be used together with Vector API support
UserError.guarantee(!VectorAPIEnabled.getValue(), "Support for Arena.ofShared is not available with Vector API support. " +
"Either disable Vector API support using %s or replace usages of Arena.ofShared with Arena.ofAuto and disable shared arena support.",
SubstrateOptionsParser.commandArgument(VectorAPISupport, "-"));
UserError.guarantee(!VectorAPIEnabled.getValue(), "Support for Arena.ofShared (which is part of the FFM API) is not available with Vector API support. " +
"Either disable Vector API support using %s or replace usages of Arena.ofShared with Arena.ofAuto and disable shared arena support using %s.",
SubstrateOptionsParser.commandArgument(VectorAPISupport, "-"),
SubstrateOptionsParser.commandArgument(key, "-"));
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.util.function.Supplier;
import java.util.function.UnaryOperator;

import com.oracle.svm.core.thread.JavaThreads;
import org.graalvm.collections.EconomicSet;
import org.graalvm.nativeimage.AnnotationAccess;
import org.graalvm.nativeimage.ImageSingletons;
Expand Down Expand Up @@ -764,6 +765,7 @@ protected void initSafeArenaAccessors(BeforeAnalysisAccessImpl access) throws No
registerSafeArenaAccessorMethod(metaAccess, ReflectionUtil.lookupMethod(mappedMemoryUtils, "unload", long.class, boolean.class, long.class));
registerSafeArenaAccessorMethod(metaAccess, ReflectionUtil.lookupMethod(SubstrateMappedMemoryUtils.class, "load", long.class, boolean.class, long.class));
registerSafeArenaAccessorMethod(metaAccess, Thread.class.getMethod("currentThread"));
registerSafeArenaAccessorMethod(metaAccess, JavaThreads.class.getMethod("getCurrentThreadOrNull"));

/*
* The actual method checking a valid session state (if not inlined) is also safe as this
Expand Down