Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gluon-bot committed Sep 25, 2023
2 parents 4970f2f + 69f247b commit 216a775
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ protected void calcLatestBlock(HIRBlock earliestBlock, SchedulingStrategy strate
*/
continue;
}
latestBlock = calcBlockForUsage(currentNode, usage, latestBlock, currentNodeMap, moveInputsIntoDominator);
latestBlock = calcLatestBlockForUsage(currentNode, usage, earliestBlock, latestBlock, currentNodeMap, moveInputsIntoDominator);
checkLatestEarliestRelation(currentNode, earliestBlock, latestBlock, usage);
}

Expand Down Expand Up @@ -687,9 +687,10 @@ private static Node getUnproxifiedUncompressed(Node node) {
return result;
}

private static HIRBlock calcBlockForUsage(Node node, Node usage, HIRBlock startBlock, NodeMap<HIRBlock> currentNodeMap, NodeBitMap moveInputsToDominator) {
private static HIRBlock calcLatestBlockForUsage(Node node, Node usage, HIRBlock earliestBlock, HIRBlock initialLatestBlock, NodeMap<HIRBlock> currentNodeMap,
NodeBitMap moveInputsToDominator) {
assert !(node instanceof PhiNode);
HIRBlock currentBlock = startBlock;
HIRBlock currentBlock = initialLatestBlock;
if (usage instanceof PhiNode) {
// An input to a PhiNode is used at the end of the predecessor block that
// corresponds to the PhiNode input. One PhiNode can use an input multiple times.
Expand All @@ -711,7 +712,16 @@ private static HIRBlock calcBlockForUsage(Node node, Node usage, HIRBlock startB
}

if (!(node instanceof VirtualState) && !moveInputsToDominator.isNew(usage) && moveInputsToDominator.isMarked(usage)) {
otherBlock = otherBlock.getDominator();
/*
* The usage is marked as forcing its inputs into the dominator. Respect that if
* we can, but the dominator might not be a legal position for the node. This is
* the case for loop-variant floating nodes between a loop phi and a virtual
* state on the loop begin.
*/
HIRBlock dominator = otherBlock.getDominator();
if (AbstractControlFlowGraph.dominates(earliestBlock, dominator)) {
otherBlock = dominator;
}
GraalError.guarantee(otherBlock != null, "Dominators need to be computed in the CFG");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import org.graalvm.collections.EconomicMap;
import org.graalvm.collections.Equivalence;
import org.graalvm.compiler.debug.Assertions;
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.graph.GraalGraphError;
Expand Down Expand Up @@ -150,12 +151,24 @@ private static void visitForward(ArrayList<Node> nodes, NodeBitMap visited, Node
}
}

public static boolean assertSchedulableGraph(StructuredGraph g) {
assert GraphOrder.assertNonCyclicGraph(g);
assert g.getGuardsStage() == GuardsStage.AFTER_FSA || GraphOrder.assertScheduleableBeforeFSA(g);
if (g.getGuardsStage() == GuardsStage.AFTER_FSA && Assertions.detailedAssertionsEnabled(g.getOptions())) {
// we still want to do a memory verification of the schedule even if we can
// no longer use assertSchedulableGraph after the floating reads phase
SchedulePhase.runWithoutContextOptimizations(g, SchedulePhase.SchedulingStrategy.LATEST_OUT_OF_LOOPS, true);
}
assert g.verify();
return true;
}

/**
* This method schedules the graph and makes sure that, for every node, all inputs are available
* at the position where it is scheduled. This is a very expensive assertion.
*/
@SuppressWarnings("try")
public static boolean assertSchedulableGraph(final StructuredGraph graph) {
private static boolean assertScheduleableBeforeFSA(final StructuredGraph graph) {
assert graph.getGuardsStage() != GuardsStage.AFTER_FSA : "Cannot use the BlockIteratorClosure after FrameState Assignment, HIR Loop Data Structures are no longer valid.";
try (DebugContext.Scope s = graph.getDebug().scope("AssertSchedulableGraph")) {
SchedulePhase.runWithoutContextOptimizations(graph, getSchedulingPolicy(graph), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.DebugContext.Builder;
import org.graalvm.compiler.debug.DebugContext.Scope;
import org.graalvm.compiler.debug.DebugDumpScope;
import org.graalvm.compiler.debug.DiagnosticsOutputDirectory;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.debug.Indent;
Expand Down Expand Up @@ -540,6 +541,9 @@ private StructuredGraph truffleTier(TruffleCompilationWrapper wrapper, DebugCont
wrapper.compilationId, TruffleTierContext.getSpeculationLog(wrapper), wrapper.task,
handler);

// Save the graph so it can dumped into the graal_diagnostics zip
wrapper.graph = context.graph;

try (Scope s = context.debug.scope("CreateGraph", context.graph);
Indent indent = context.debug.logAndIndent("evaluate %s", context.graph);) {
truffleTier.apply(context.graph, context);
Expand Down Expand Up @@ -676,6 +680,7 @@ final class TruffleCompilationWrapper extends CompilationWrapper<Void> {
final CompilationIdentifier compilationId;
final ExpansionStatistics statistics;
final OptionValues compilerOptions;
StructuredGraph graph;
boolean silent;

private TruffleCompilationWrapper(
Expand All @@ -700,6 +705,18 @@ public String toString() {
return compilable.toString();
}

@SuppressWarnings("try")
@Override
protected void dumpOnError(DebugContext errorContext, Throwable cause) {
if (graph != null) {
try (DebugContext.Scope s = errorContext.scope("DumpOnError", graph, compilationId, new DebugDumpScope("Original failure"))) {
errorContext.forceDump(graph, "Exception: %s", cause);
} catch (Throwable t) {
throw errorContext.handle(t);
}
}
}

@Override
protected ExceptionAction lookupAction(OptionValues options, Throwable cause) {
// Respect current action if it has been explicitly set.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public void duringSetup(DuringSetupAccess a) {
rerunClassInit(a, "sun.nio.ch.IOUtil", "sun.nio.ch.ServerSocketChannelImpl", "sun.nio.ch.DatagramChannelImpl", "sun.nio.ch.FileChannelImpl", "sun.nio.ch.FileKey");
rerunClassInit(a, "java.nio.file.Files$FileTypeDetectors");
rerunClassInit(a, "sun.nio.ch.Net", "sun.nio.ch.SocketOptionRegistry$LazyInitialization");
rerunClassInit(a, "sun.nio.ch.AsynchronousSocketChannelImpl$DefaultOptionsHolder", "sun.nio.ch.AsynchronousServerSocketChannelImpl$DefaultOptionsHolder",
"sun.nio.ch.DatagramChannelImpl$DefaultOptionsHolder", "sun.nio.ch.ServerSocketChannelImpl$DefaultOptionsHolder", "sun.nio.ch.SocketChannelImpl$DefaultOptionsHolder");
/* Ensure that the interrupt signal handler is initialized at runtime. */
rerunClassInit(a, "sun.nio.ch.NativeThread");
rerunClassInit(a, "sun.nio.ch.FileDispatcherImpl", "sun.nio.ch.FileChannelImpl$Unmapper");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ boolean hasExecutableName() {

@ExportMessage
@TruffleBoundary
Object getExecutableName() {
return rootNode.getName();
Object getExecutableName() throws UnsupportedMessageException {
String name = rootNode.getName();
if (name == null) {
throw UnsupportedMessageException.create();
}
return name;
}

@ExportMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ static void verifyStackTraceElementGuestObject(Object guestObject) throws Unsupp
if (interop.hasExecutableName(guestObject)) {
Object executableName = interop.getExecutableName(guestObject);
Assert.assertTrue(interop.isString(executableName));
} else {
AbstractPolyglotTest.assertFails(() -> interop.getExecutableName(guestObject), UnsupportedMessageException.class);
}
if (interop.hasDeclaringMetaObject(guestObject)) {
Object metaObject = interop.getDeclaringMetaObject(guestObject);
Expand Down

0 comments on commit 216a775

Please sign in to comment.