Skip to content

Commit

Permalink
Respect condition in reflection registration: fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophTF committed Sep 1, 2024
1 parent 29166be commit 2db9e4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
import com.oracle.graal.pointsto.meta.AnalysisUniverse;
import com.oracle.graal.pointsto.meta.HostedProviders;
import com.oracle.graal.pointsto.reports.StatisticsPrinter;
import com.oracle.graal.pointsto.reports.causality.CausalityExport;
import com.oracle.graal.pointsto.reports.causality.events.CausalityEvent;
import com.oracle.graal.pointsto.util.AnalysisError;
import com.oracle.graal.pointsto.util.CompletionExecutor;
import com.oracle.graal.pointsto.util.Timer;
Expand Down Expand Up @@ -330,30 +328,7 @@ protected void schedule(Runnable task) {

@Override
public final void postTask(CompletionExecutor.DebugContextRunnable task) {
CausalityEvent inheritedCause = CausalityExport.getCause();
if (inheritedCause == null) {
executor.execute(task);
} else {
// This branch would always be correct, but slower.
executor.execute(new CompletionExecutor.DebugContextRunnable() {
@Override
public void run(DebugContext debug) {
try (var ignored = CausalityExport.setCause(inheritedCause)) {
task.run(debug);
}
}

@Override
public DebugContext getDebug(OptionValues opts, List<DebugHandlersFactory> factories) {
return task.getDebug(opts, factories);
}

@Override
public DebugContext.Description getDescription() {
return task.getDescription();
}
});
}
executor.execute(task);
}

public void postTask(final Runnable task) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.meta.AnalysisUniverse;
import com.oracle.graal.pointsto.reports.causality.CausalityExport;
import com.oracle.graal.pointsto.reports.causality.events.CausalityEvent;
import com.oracle.graal.pointsto.reports.causality.events.CausalityEvents;
import com.oracle.svm.core.MissingRegistrationUtils;
import com.oracle.svm.core.configure.ConditionalRuntimeValue;
Expand Down Expand Up @@ -169,9 +170,11 @@ public void duringSetup(AnalysisMetaAccess analysisMetaAccess, AnalysisUniverse
this.metaAccess = analysisMetaAccess;
this.universe = analysisUniverse;
for (var conditionalTask : pendingConditionalTasks) {
try (var ignored = CausalityExport.overwriteCause(CausalityEvents.DeferredTask.create(conditionalTask))) {
registerConditionalConfiguration(conditionalTask.condition, (cnd) -> universe.getBigbang().postTask(debug -> conditionalTask.task.accept(cnd)));
}
registerConditionalConfiguration(conditionalTask.condition, (cnd) -> universe.getBigbang().postTask(debug -> {
try (var ignored = CausalityExport.setCause(CausalityEvents.DeferredTask.create(conditionalTask))) {
conditionalTask.task.accept(cnd);
}
}));
}
pendingConditionalTasks.clear();
}
Expand All @@ -186,7 +189,14 @@ private void runConditionalInAnalysisTask(ConfigurationCondition condition, Cons
}

if (universe != null) {
registerConditionalConfiguration(condition, (cnd) -> universe.getBigbang().postTask(debug -> task.accept(cnd)));
registerConditionalConfiguration(condition, (cnd) -> {
CausalityEvent inheritedCause = CausalityExport.getCause();
universe.getBigbang().postTask(debug -> {
try (var ignored = CausalityExport.setCause(inheritedCause)) {
task.accept(cnd);
}
});
});
} else {
var conditionalTask = new ConditionalTask(condition, task);
CausalityExport.registerEvent(CausalityEvents.DeferredTask.create(conditionalTask));
Expand Down

0 comments on commit 2db9e4a

Please sign in to comment.