Skip to content

Commit

Permalink
[GR-36676] Remove the option to do the reference handling in a regula…
Browse files Browse the repository at this point in the history
…r Java thread.

PullRequest: graal/11167
  • Loading branch information
christianhaeubl committed Mar 26, 2022
2 parents b398106 + 79ab826 commit 015b140
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public Builder auxiliaryImageReservedSpaceSize(UnsignedWord size) {
/**
* Appends an isolate argument. The syntax for arguments is the same as the one that is
* used on the command-line when starting Native Image (e.g., {@code
* -XX:+UseReferenceHandlerThread}). If the same argument is added multiple times, the
* -XX:+AutomaticReferenceHandling}). If the same argument is added multiple times, the
* last specified value will be used.
*
* @since 22.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ private void collect(GCCause cause, boolean forceFullGC) {
if (outOfMemory) {
throw OUT_OF_MEMORY_ERROR;
}
doReferenceHandlingInRegularThread();
}
}

Expand Down Expand Up @@ -1163,13 +1162,6 @@ private void finishCollection() {
collectionInProgress = false;
}

// This method will be removed as soon as possible, see GR-36676.
static void doReferenceHandlingInRegularThread() {
if (ReferenceHandler.useRegularJavaThread() && !VMOperation.isInProgress() && PlatformThreads.isCurrentAssigned()) {
doReferenceHandling();
}
}

/**
* Inside a VMOperation, we are not allowed to do certain things, e.g., perform synchronization
* (because it can deadlock when a lock is held outside the VMOperation). Similar restrictions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ private static Object slowPathNewInstance(Word objectHeader) {
* </pre>
*/
private static void runSlowPathHooks() {
GCImpl.doReferenceHandlingInRegularThread();
GCImpl.getPolicy().updateSizeParameters();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
*/
public class IsolateArgumentParser {
private static final RuntimeOptionKey<?>[] OPTIONS = {SubstrateGCOptions.MinHeapSize, SubstrateGCOptions.MaxHeapSize, SubstrateGCOptions.MaxNewSize,
SubstrateOptions.ConcealedOptions.UseReferenceHandlerThread, SubstrateOptions.ConcealedOptions.AutomaticReferenceHandling};
SubstrateOptions.ConcealedOptions.AutomaticReferenceHandling};
private static final int OPTION_COUNT = OPTIONS.length;
private static final CGlobalData<CCharPointer> OPTION_NAMES = CGlobalDataFactory.createBytes(IsolateArgumentParser::createOptionNames);
private static final CGlobalData<CIntPointer> OPTION_NAME_POSITIONS = CGlobalDataFactory.createBytes(IsolateArgumentParser::createOptionNamePosition);
Expand All @@ -73,11 +73,6 @@ public class IsolateArgumentParser {
public IsolateArgumentParser() {
}

@Fold
public static boolean isSupported() {
return ImageSingletons.contains(IsolateArgumentParser.class);
}

@Fold
public static IsolateArgumentParser singleton() {
return ImageSingletons.lookup(IsolateArgumentParser.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,6 @@ public Boolean getValue(OptionValues values) {
@Option(help = "Determines if VM operations should be executed in a dedicated thread.", type = OptionType.Expert)//
public static final HostedOptionKey<Boolean> UseDedicatedVMOperationThread = new HostedOptionKey<>(false);

/** Use {@link ReferenceHandler#useDedicatedThread()} instead. */
@Option(help = "Populate reference queues in a separate thread rather than after a garbage collection.", type = OptionType.Expert) //
public static final RuntimeOptionKey<Boolean> UseReferenceHandlerThread = new ImmutableRuntimeOptionKey<>(true);

/** Use {@link ReferenceHandler#isExecutedManually()} instead. */
@Option(help = "Determines if the reference handling is executed automatically or manually.", type = OptionType.Expert) //
public static final RuntimeOptionKey<Boolean> AutomaticReferenceHandling = new ImmutableRuntimeOptionKey<>(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,16 @@

public final class ReferenceHandler {
public static boolean useDedicatedThread() {
if (ReferenceHandlerThread.isSupported()) {
int useReferenceHandlerThread = IsolateArgumentParser.getOptionIndex(SubstrateOptions.ConcealedOptions.UseReferenceHandlerThread);
int automaticReferenceHandling = IsolateArgumentParser.getOptionIndex(SubstrateOptions.ConcealedOptions.AutomaticReferenceHandling);
return IsolateArgumentParser.getBooleanOptionValue(useReferenceHandlerThread) && IsolateArgumentParser.getBooleanOptionValue(automaticReferenceHandling);
}
return false;
}

public static boolean useRegularJavaThread() {
int useReferenceHandlerThread = IsolateArgumentParser.getOptionIndex(SubstrateOptions.ConcealedOptions.UseReferenceHandlerThread);
int automaticReferenceHandling = IsolateArgumentParser.getOptionIndex(SubstrateOptions.ConcealedOptions.AutomaticReferenceHandling);
return (!ReferenceHandlerThread.isSupported() || !IsolateArgumentParser.getBooleanOptionValue(useReferenceHandlerThread)) &&
IsolateArgumentParser.getBooleanOptionValue(automaticReferenceHandling);
return ReferenceHandlerThread.isSupported() && IsolateArgumentParser.getBooleanOptionValue(automaticReferenceHandling);
}

public static boolean isExecutedManually() {
int automaticReferenceHandling = IsolateArgumentParser.getOptionIndex(SubstrateOptions.ConcealedOptions.AutomaticReferenceHandling);
return !IsolateArgumentParser.getBooleanOptionValue(automaticReferenceHandling);
return !useDedicatedThread();
}

public static void processPendingReferencesInRegularThread() {
assert !useDedicatedThread();
assert isExecutedManually();

/*
* We might be running in a user thread that is close to a stack overflow, so enable the
Expand Down

0 comments on commit 015b140

Please sign in to comment.