Skip to content

Commit 3160782

Browse files
committed
[GR-65008] Remove sequential reachability handler.
PullRequest: graal/20819
2 parents 077f075 + 2433fb1 commit 3160782

File tree

9 files changed

+15
-263
lines changed

9 files changed

+15
-263
lines changed

substratevm/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This changelog summarizes major changes to GraalVM Native Image.
1919
* (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)
2020
* (GR-64584) Experimental option `-H:+RelativeCodePointers` to significantly reduce relocation entries in position-independent executables and shared libraries.
2121
* (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.
22+
* (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.
2223

2324
## GraalVM for JDK 24 (Internal Version 24.2.0)
2425
* (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.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,9 +1294,6 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, String ol
12941294
@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)//
12951295
public static final HostedOptionKey<Boolean> VerifyTypes = new HostedOptionKey<>(false);
12961296

1297-
@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")//
1298-
public static final HostedOptionKey<Boolean> RunReachabilityHandlersConcurrently = new HostedOptionKey<>(true);
1299-
13001297
@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)//
13011298
public static final HostedOptionKey<Boolean> UseDirectCallTrampolinesALot = new HostedOptionKey<>(false);
13021299

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConcurrentReachabilityHandler.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,35 +31,21 @@
3131
import java.util.function.BiConsumer;
3232
import java.util.function.Consumer;
3333

34-
import org.graalvm.nativeimage.ImageSingletons;
35-
3634
import com.oracle.graal.pointsto.meta.AnalysisElement;
3735
import com.oracle.graal.pointsto.meta.AnalysisElement.ElementNotification;
3836
import com.oracle.graal.pointsto.meta.AnalysisElement.MethodOverrideReachableNotification;
3937
import com.oracle.graal.pointsto.meta.AnalysisElement.SubtypeReachableNotification;
4038
import com.oracle.graal.pointsto.meta.AnalysisMetaAccess;
4139
import com.oracle.graal.pointsto.meta.AnalysisMethod;
4240
import com.oracle.graal.pointsto.meta.AnalysisType;
43-
import com.oracle.svm.core.SubstrateOptions;
4441
import com.oracle.svm.core.feature.InternalFeature;
45-
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
4642
import com.oracle.svm.core.util.UserError;
4743
import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl;
4844

49-
@AutomaticallyRegisteredFeature
5045
public class ConcurrentReachabilityHandler extends ReachabilityHandler implements InternalFeature {
5146

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

54-
public static ConcurrentReachabilityHandler singleton() {
55-
return ImageSingletons.lookup(ConcurrentReachabilityHandler.class);
56-
}
57-
58-
@Override
59-
public boolean isInConfiguration(IsInConfigurationAccess access) {
60-
return SubstrateOptions.RunReachabilityHandlersConcurrently.getValue();
61-
}
62-
6349
@Override
6450
public void registerMethodOverrideReachabilityHandler(BeforeAnalysisAccessImpl access, BiConsumer<DuringAnalysisAccess, Executable> callback, Executable baseMethod) {
6551
AnalysisMetaAccess metaAccess = access.getMetaAccess();

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FeatureImpl.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
import com.oracle.graal.pointsto.meta.ObjectReachableCallback;
6868
import com.oracle.svm.common.meta.MultiMethod;
6969
import com.oracle.svm.core.LinkerInvocation;
70-
import com.oracle.svm.core.SubstrateOptions;
7170
import com.oracle.svm.core.annotate.Delete;
7271
import com.oracle.svm.core.feature.InternalFeature;
7372
import com.oracle.svm.core.graal.code.SubstrateBackend;
@@ -76,7 +75,6 @@
7675
import com.oracle.svm.core.meta.SharedField;
7776
import com.oracle.svm.core.meta.SharedMethod;
7877
import com.oracle.svm.core.meta.SharedType;
79-
import com.oracle.svm.core.option.SubstrateOptionsParser;
8078
import com.oracle.svm.core.util.UserError;
8179
import com.oracle.svm.core.util.VMError;
8280
import com.oracle.svm.hosted.ameta.FieldValueInterceptionSupport;
@@ -360,16 +358,14 @@ public SVMHost getHostVM() {
360358
public static class BeforeAnalysisAccessImpl extends AnalysisAccessBase implements Feature.BeforeAnalysisAccess {
361359

362360
private final NativeLibraries nativeLibraries;
363-
private final boolean concurrentReachabilityHandlers;
364361
private final ReachabilityHandler reachabilityHandler;
365-
private ClassForNameSupport classForNameSupport;
362+
private final ClassForNameSupport classForNameSupport;
366363

367364
public BeforeAnalysisAccessImpl(FeatureHandler featureHandler, ImageClassLoader imageClassLoader, Inflation bb, NativeLibraries nativeLibraries,
368365
DebugContext debugContext) {
369366
super(featureHandler, imageClassLoader, bb, debugContext);
370367
this.nativeLibraries = nativeLibraries;
371-
this.concurrentReachabilityHandlers = SubstrateOptions.RunReachabilityHandlersConcurrently.getValue(bb.getOptions());
372-
this.reachabilityHandler = concurrentReachabilityHandlers ? ConcurrentReachabilityHandler.singleton() : ReachabilityHandlerFeature.singleton();
368+
this.reachabilityHandler = new ConcurrentReachabilityHandler();
373369
this.classForNameSupport = ClassForNameSupport.currentLayer();
374370
}
375371

@@ -491,10 +487,6 @@ public void registerClassInitializerReachabilityHandler(Consumer<DuringAnalysisA
491487
reachabilityHandler.registerClassInitializerReachabilityHandler(this, callback, clazz);
492488
}
493489

494-
public boolean concurrentReachabilityHandlers() {
495-
return concurrentReachabilityHandlers;
496-
}
497-
498490
@Override
499491
public void registerFieldValueTransformer(Field field, FieldValueTransformer transformer) {
500492
FieldValueInterceptionSupport.singleton().registerFieldValueTransformer(field, transformer);
@@ -534,20 +526,21 @@ public boolean getAndResetRequireAnalysisIteration() {
534526

535527
public static class ConcurrentAnalysisAccessImpl extends DuringAnalysisAccessImpl {
536528

537-
private static final String concurrentReachabilityOption = SubstrateOptionsParser.commandArgument(SubstrateOptions.RunReachabilityHandlersConcurrently, "-");
538-
539529
public ConcurrentAnalysisAccessImpl(FeatureHandler featureHandler, ImageClassLoader imageClassLoader, Inflation bb, NativeLibraries nativeLibraries, DebugContext debugContext) {
540530
super(featureHandler, imageClassLoader, bb, nativeLibraries, debugContext);
541531
}
542532

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

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,8 @@ protected boolean runPointsToAnalysis(String imageName, OptionValues options, De
847847
bb.getHostVM().notifyClassReachabilityListener(universe, config);
848848
featureHandler.forEachFeature(feature -> feature.duringAnalysis(config));
849849
}
850-
return !config.getAndResetRequireAnalysisIteration();
850+
/* Analysis is finished if no additional iteration was requested. */
851+
return !config.getAndResetRequireAnalysisIteration() && !concurrentConfig.getAndResetRequireAnalysisIteration();
851852
});
852853
} catch (Throwable t) {
853854
if (ImageSingletons.contains(RuntimeCompilationCallbacks.class)) {

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProtectionDomainFeature.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ void enableCodeSource(DuringAnalysisAccess a) {
7575
ProtectionDomainSupport.enableCodeSource();
7676
if (access != null) {
7777
access.rescanField(ImageSingletons.lookup(ProtectionDomainSupport.class), executableURLSupplierField);
78-
if (!access.concurrentReachabilityHandlers()) {
79-
access.requireAnalysisIteration();
80-
}
8178
}
8279
}
8380
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ReachabilityHandlerFeature.java

Lines changed: 0 additions & 210 deletions
This file was deleted.

0 commit comments

Comments
 (0)