Skip to content

[GR-65008] Remove sequential reachability handler. #11208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions substratevm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This changelog summarizes major changes to GraalVM Native Image.
* (GR-60209) New syntax for configuration of the [Foreign Function & Memory API](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/ForeignInterface.md)
* (GR-64584) Experimental option `-H:+RelativeCodePointers` to significantly reduce relocation entries in position-independent executables and shared libraries.
* (GR-60238) JNI registration is now included as part of the `"reflection"` section of _reachability-metadata.json_ using the `"jniAccessible"` attribute. Registrations performed through the `"jni"` section of _reachability-metadata.json_ and through _jni-config.json_ will still be accepted and parsed correctly.
* (GR-65008) Remove the sequential reachability handler. The only remaining variant is the concurrent reachability handler, which has been the default implementation since its introduction. Additionally, remove the `-H:-RunReachabilityHandlersConcurrently` option which was introduced to simplify migration and has been deprecated since Version 24.0.0.

## GraalVM for JDK 24 (Internal Version 24.2.0)
* (GR-59717) Added `DuringSetupAccess.registerObjectReachabilityHandler` to allow registering a callback that is executed when an object of a specified type is marked as reachable during heap scanning.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1286,9 +1286,6 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, String ol
@Option(help = "Verify type states computed by the static analysis at run time. This is useful when diagnosing problems in the static analysis, but reduces peak performance significantly.", type = OptionType.Debug)//
public static final HostedOptionKey<Boolean> VerifyTypes = new HostedOptionKey<>(false);

@Option(help = "Run reachability handlers concurrently during analysis.", type = Expert, deprecated = true, deprecationMessage = "This option was introduced to simplify migration to GraalVM 22.2 and will be removed in a future release")//
public static final HostedOptionKey<Boolean> RunReachabilityHandlersConcurrently = new HostedOptionKey<>(true);

@Option(help = "Force many trampolines to be needed for inter-method calls. Normally trampolines are only used when a method destination is outside the range of a pc-relative branch instruction.", type = OptionType.Debug)//
public static final HostedOptionKey<Boolean> UseDirectCallTrampolinesALot = new HostedOptionKey<>(false);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 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
Expand Down Expand Up @@ -31,35 +31,21 @@
import java.util.function.BiConsumer;
import java.util.function.Consumer;

import org.graalvm.nativeimage.ImageSingletons;

import com.oracle.graal.pointsto.meta.AnalysisElement;
import com.oracle.graal.pointsto.meta.AnalysisElement.ElementNotification;
import com.oracle.graal.pointsto.meta.AnalysisElement.MethodOverrideReachableNotification;
import com.oracle.graal.pointsto.meta.AnalysisElement.SubtypeReachableNotification;
import com.oracle.graal.pointsto.meta.AnalysisMetaAccess;
import com.oracle.graal.pointsto.meta.AnalysisMethod;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.svm.core.SubstrateOptions;
import com.oracle.svm.core.feature.InternalFeature;
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
import com.oracle.svm.core.util.UserError;
import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl;

@AutomaticallyRegisteredFeature
public class ConcurrentReachabilityHandler extends ReachabilityHandler implements InternalFeature {

private final Map<Consumer<DuringAnalysisAccess>, ElementNotification> reachabilityNotifications = new ConcurrentHashMap<>();

public static ConcurrentReachabilityHandler singleton() {
return ImageSingletons.lookup(ConcurrentReachabilityHandler.class);
}

@Override
public boolean isInConfiguration(IsInConfigurationAccess access) {
return SubstrateOptions.RunReachabilityHandlersConcurrently.getValue();
}

@Override
public void registerMethodOverrideReachabilityHandler(BeforeAnalysisAccessImpl access, BiConsumer<DuringAnalysisAccess, Executable> callback, Executable baseMethod) {
AnalysisMetaAccess metaAccess = access.getMetaAccess();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
import com.oracle.graal.pointsto.meta.ObjectReachableCallback;
import com.oracle.svm.common.meta.MultiMethod;
import com.oracle.svm.core.LinkerInvocation;
import com.oracle.svm.core.SubstrateOptions;
import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.feature.InternalFeature;
import com.oracle.svm.core.graal.code.SubstrateBackend;
Expand All @@ -76,7 +75,6 @@
import com.oracle.svm.core.meta.SharedField;
import com.oracle.svm.core.meta.SharedMethod;
import com.oracle.svm.core.meta.SharedType;
import com.oracle.svm.core.option.SubstrateOptionsParser;
import com.oracle.svm.core.util.UserError;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.hosted.ameta.FieldValueInterceptionSupport;
Expand Down Expand Up @@ -360,16 +358,14 @@ public SVMHost getHostVM() {
public static class BeforeAnalysisAccessImpl extends AnalysisAccessBase implements Feature.BeforeAnalysisAccess {

private final NativeLibraries nativeLibraries;
private final boolean concurrentReachabilityHandlers;
private final ReachabilityHandler reachabilityHandler;
private ClassForNameSupport classForNameSupport;
private final ClassForNameSupport classForNameSupport;

public BeforeAnalysisAccessImpl(FeatureHandler featureHandler, ImageClassLoader imageClassLoader, Inflation bb, NativeLibraries nativeLibraries,
DebugContext debugContext) {
super(featureHandler, imageClassLoader, bb, debugContext);
this.nativeLibraries = nativeLibraries;
this.concurrentReachabilityHandlers = SubstrateOptions.RunReachabilityHandlersConcurrently.getValue(bb.getOptions());
this.reachabilityHandler = concurrentReachabilityHandlers ? ConcurrentReachabilityHandler.singleton() : ReachabilityHandlerFeature.singleton();
this.reachabilityHandler = new ConcurrentReachabilityHandler();
this.classForNameSupport = ClassForNameSupport.currentLayer();
}

Expand Down Expand Up @@ -491,10 +487,6 @@ public void registerClassInitializerReachabilityHandler(Consumer<DuringAnalysisA
reachabilityHandler.registerClassInitializerReachabilityHandler(this, callback, clazz);
}

public boolean concurrentReachabilityHandlers() {
return concurrentReachabilityHandlers;
}

@Override
public void registerFieldValueTransformer(Field field, FieldValueTransformer transformer) {
FieldValueInterceptionSupport.singleton().registerFieldValueTransformer(field, transformer);
Expand Down Expand Up @@ -534,20 +526,21 @@ public boolean getAndResetRequireAnalysisIteration() {

public static class ConcurrentAnalysisAccessImpl extends DuringAnalysisAccessImpl {

private static final String concurrentReachabilityOption = SubstrateOptionsParser.commandArgument(SubstrateOptions.RunReachabilityHandlersConcurrently, "-");

public ConcurrentAnalysisAccessImpl(FeatureHandler featureHandler, ImageClassLoader imageClassLoader, Inflation bb, NativeLibraries nativeLibraries, DebugContext debugContext) {
super(featureHandler, imageClassLoader, bb, nativeLibraries, debugContext);
}

@Override
public void requireAnalysisIteration() {
if (bb.executorIsStarted()) {
String msg = "Calling DuringAnalysisAccessImpl.requireAnalysisIteration() is not necessary when running the reachability handlers concurrently during analysis. " +
"To fallback to running the reachability handlers sequentially, i.e., from Feature.duringAnalysis(), you can add the " + concurrentReachabilityOption +
" option to the native-image command. Note that the fallback option is deprecated and it will be removed in a future release.";
throw VMError.shouldNotReachHere(msg);
throw VMError.shouldNotReachHere("Calling DuringAnalysisAccessImpl.requireAnalysisIteration() is not necessary when running the reachability handlers concurrently during analysis.");
}
/*
* While it may seem wrong that the concurrent analysis accessor can request an
* additional analysis iteration this is necessary because the concurrent reachability
* callbacks can be forced to run synchronously in the single-threaded "during analysis"
* phase when elements are marked as reachable from Feature.duringAnalysis hooks.
*/
super.requireAnalysisIteration();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ protected boolean runPointsToAnalysis(String imageName, OptionValues options, De
bb.getHostVM().notifyClassReachabilityListener(universe, config);
featureHandler.forEachFeature(feature -> feature.duringAnalysis(config));
}
return !config.getAndResetRequireAnalysisIteration();
return !config.getAndResetRequireAnalysisIteration() && !concurrentConfig.getAndResetRequireAnalysisIteration();
});
} catch (Throwable t) {
if (ImageSingletons.contains(RuntimeCompilationCallbacks.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ void enableCodeSource(DuringAnalysisAccess a) {
ProtectionDomainSupport.enableCodeSource();
if (access != null) {
access.rescanField(ImageSingletons.lookup(ProtectionDomainSupport.class), executableURLSupplierField);
if (!access.concurrentReachabilityHandlers()) {
access.requireAnalysisIteration();
}
}
}
}

This file was deleted.

Loading
Loading