From 2db9e4aef0f3c6dab70a4476d5c21a4ed05ed9aa Mon Sep 17 00:00:00 2001 From: Christoph Blumschein Date: Sun, 1 Sep 2024 21:25:11 +0200 Subject: [PATCH] Respect condition in reflection registration: fixup --- .../pointsto/AbstractAnalysisEngine.java | 27 +------------------ .../hosted/reflect/ReflectionDataBuilder.java | 18 ++++++++++--- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/AbstractAnalysisEngine.java b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/AbstractAnalysisEngine.java index 89bf0274feb2..48337db3e49f 100644 --- a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/AbstractAnalysisEngine.java +++ b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/AbstractAnalysisEngine.java @@ -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; @@ -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 factories) { - return task.getDebug(opts, factories); - } - - @Override - public DebugContext.Description getDescription() { - return task.getDescription(); - } - }); - } + executor.execute(task); } public void postTask(final Runnable task) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java index 19ad76a40994..71835389b83d 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java @@ -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; @@ -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(); } @@ -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));