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 Jun 20, 2021
2 parents b84b275 + 89fc926 commit cb7fdfa
Show file tree
Hide file tree
Showing 59 changed files with 2,484 additions and 1,264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ private enum FreezeState {

public final String name;

/**
* Cached actual value of the {@link Options} to avoid expensive map lookup for every time a
* node / graph is verified.
*/
public final boolean verifyGraphs;
public final boolean verifyGraphEdges;

/**
* The set of nodes in the graph, ordered by {@linkplain #register(Node) registration} time.
*/
Expand Down Expand Up @@ -287,6 +294,9 @@ public Graph(String name, OptionValues options, DebugContext debug, boolean trac
nodeModCounts = new int[INITIAL_NODES_SIZE];
nodeUsageModCounts = new int[INITIAL_NODES_SIZE];
}

verifyGraphs = Options.VerifyGraalGraphs.getValue(options);
verifyGraphEdges = Options.VerifyGraalGraphEdges.getValue(options);
}

int extractOriginalNodeId(Node node) {
Expand Down Expand Up @@ -1166,7 +1176,7 @@ void unregister(Node node) {
}

public boolean verify() {
if (Options.VerifyGraalGraphs.getValue(options)) {
if (verifyGraphs) {
for (Node node : getNodes()) {
try {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.graalvm.compiler.debug.DebugCloseable;
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.graph.Graph.NodeEventListener;
import org.graalvm.compiler.graph.Graph.Options;
import org.graalvm.compiler.graph.iterators.NodeIterable;
import org.graalvm.compiler.graph.iterators.NodePredicate;
import org.graalvm.compiler.nodeinfo.InputType;
Expand Down Expand Up @@ -1154,10 +1153,10 @@ protected boolean verifyInputs() {
}

public boolean verify() {
assertTrue(isAlive(), "cannot verify inactive nodes (id=%d)", id);
assertTrue(isAlive(), "cannot verify inactive node %s", this);
assertTrue(graph() != null, "null graph");
verifyInputs();
if (Options.VerifyGraalGraphEdges.getValue(getOptions())) {
if (graph.verifyGraphEdges) {
verifyEdges();
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ public void logInliningTree() {
*/
@Override
protected Graph copy(String newName, Consumer<UnmodifiableEconomicMap<Node, Node>> duplicationMapCallback, DebugContext debugForCopy) {
return copy(newName, rootMethod, getOptions(), duplicationMapCallback, compilationId, debugForCopy);
return copy(newName, rootMethod, getOptions(), duplicationMapCallback, compilationId, debugForCopy, trackNodeSourcePosition);
}

/**
Expand All @@ -695,12 +695,12 @@ protected Graph copy(String newName, Consumer<UnmodifiableEconomicMap<Node, Node
* @param options the option values for the graph copy
*/
public StructuredGraph copy(String newName, Consumer<UnmodifiableEconomicMap<Node, Node>> duplicationMapCallback, DebugContext debugForCopy, OptionValues options) {
return copy(newName, rootMethod, options, duplicationMapCallback, compilationId, debugForCopy);
return copy(newName, rootMethod, options, duplicationMapCallback, compilationId, debugForCopy, trackNodeSourcePosition);
}

@SuppressWarnings("try")
private StructuredGraph copy(String newName, ResolvedJavaMethod rootMethodForCopy, OptionValues optionsForCopy, Consumer<UnmodifiableEconomicMap<Node, Node>> duplicationMapCallback,
CompilationIdentifier newCompilationId, DebugContext debugForCopy) {
CompilationIdentifier newCompilationId, DebugContext debugForCopy, boolean trackNodeSourcePositionForCopy) {
AllowAssumptions allowAssumptions = allowAssumptions();
StructuredGraph copy = new StructuredGraph(newName,
rootMethodForCopy,
Expand All @@ -710,7 +710,7 @@ private StructuredGraph copy(String newName, ResolvedJavaMethod rootMethodForCop
useProfilingInfo,
isSubstitution,
methods != null ? new ArrayList<>(methods) : null,
trackNodeSourcePosition,
trackNodeSourcePositionForCopy,
newCompilationId,
optionsForCopy, debugForCopy, null, callerContext);
if (allowAssumptions == AllowAssumptions.YES && assumptions != null) {
Expand All @@ -719,7 +719,7 @@ private StructuredGraph copy(String newName, ResolvedJavaMethod rootMethodForCop
copy.hasUnsafeAccess = hasUnsafeAccess;
copy.setGuardsStage(getGuardsStage());
copy.stageFlags = EnumSet.copyOf(stageFlags);
copy.trackNodeSourcePosition = trackNodeSourcePosition;
copy.trackNodeSourcePosition = trackNodeSourcePositionForCopy;
if (fields != null) {
copy.fields = createFieldSet(fields);
}
Expand All @@ -744,11 +744,11 @@ private StructuredGraph copy(String newName, ResolvedJavaMethod rootMethodForCop
* accessed by multiple threads).
*/
public StructuredGraph copyWithIdentifier(CompilationIdentifier newCompilationId, DebugContext debugForCopy) {
return copy(name, rootMethod, getOptions(), null, newCompilationId, debugForCopy);
return copy(name, rootMethod, getOptions(), null, newCompilationId, debugForCopy, trackNodeSourcePosition);
}

public StructuredGraph copy(ResolvedJavaMethod rootMethodForCopy, OptionValues optionsForCopy, DebugContext debugForCopy) {
return copy(name, rootMethodForCopy, optionsForCopy, null, compilationId, debugForCopy);
public StructuredGraph copy(ResolvedJavaMethod rootMethodForCopy, OptionValues optionsForCopy, DebugContext debugForCopy, boolean trackNodeSourcePositionForCopy) {
return copy(name, rootMethodForCopy, optionsForCopy, null, compilationId, debugForCopy, trackNodeSourcePositionForCopy);
}

public ParameterNode getParameter(int index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public static void killCFG(FixedNode node) {
EconomicSet<Node> unsafeNodes = null;
Graph.NodeEventScope nodeEventScope = null;
OptionValues options = node.getOptions();
boolean verifyGraalGraphEdges = Graph.Options.VerifyGraalGraphEdges.getValue(options);
boolean verifyGraalGraphEdges = node.graph().verifyGraphEdges;
boolean verifyKillCFGUnusedNodes = GraphUtil.Options.VerifyKillCFGUnusedNodes.getValue(options);
if (verifyGraalGraphEdges) {
unsafeNodes = collectUnsafeNodes(node.graph());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,9 @@ private boolean lastTierCompile() {
private Object executeRootNode(VirtualFrame frame) {
final boolean inCompiled = CompilerDirectives.inCompilationRoot();
try {
return rootNode.execute(frame);
Object toRet = rootNode.execute(frame);
TruffleSafepoint.poll(rootNode);
return toRet;
} catch (ControlFlowException t) {
throw rethrow(profileExceptionType(t));
} catch (Throwable t) {
Expand All @@ -636,7 +638,6 @@ private Object executeRootNode(VirtualFrame frame) {
if (CompilerDirectives.inInterpreter() && inCompiled) {
notifyDeoptimized(frame);
}
TruffleSafepoint.poll(rootNode);
// this assertion is needed to keep the values from being cleared as non-live locals
assert frame != null && this != null;
}
Expand Down
4 changes: 2 additions & 2 deletions espresso/ci_common/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ local benchmark_suites = ['dacapo', 'renaissance', 'scala-dacapo'];

darwin: self.common + {
environment+: {
// for compatibility with macOS El Capitan
MACOSX_DEPLOYMENT_TARGET: '10.11',
// for compatibility with macOS Sierra
MACOSX_DEPLOYMENT_TARGET: '10.12',
},
capabilities: ['darwin', 'amd64'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@

import com.oracle.graal.pointsto.BigBang;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.typestate.TypeState;

public final class AllInstantiatedTypeFlow extends TypeFlow<AnalysisType> {

public AllInstantiatedTypeFlow(AnalysisType declaredType) {
super(declaredType, declaredType);
}

public AllInstantiatedTypeFlow(AnalysisType declaredType, TypeState state) {
super(declaredType, declaredType, state);
}

@Override
public TypeFlow<AnalysisType> copy(BigBang bb, MethodFlowsGraph methodFlows) {
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class AnalysisMethod implements WrappedJavaMethod, GraphProvider, Origina

private final AtomicReference<Object> parsedGraphCacheState = new AtomicReference<>(GRAPH_CACHE_UNPARSED);
private static final Object GRAPH_CACHE_UNPARSED = "unparsed";
private static final Object GRAPH_CACHE_CLEARED = "cleared by cleanupAfterAnalysis";

private StructuredGraph analyzedGraph;

Expand Down Expand Up @@ -179,6 +180,9 @@ public void cleanupAfterAnalysis() {
typeFlow = null;
invokedBy = null;
implementationInvokedBy = null;
if (parsedGraphCacheState.get() instanceof AnalysisParsedGraph) {
parsedGraphCacheState.set(GRAPH_CACHE_CLEARED);
}
}

public void startTrackInvocations() {
Expand Down Expand Up @@ -634,6 +638,9 @@ public AnalysisParsedGraph ensureGraphParsed(BigBang bb) {
} else if (curState instanceof Throwable) {
throw AnalysisError.shouldNotReachHere("parsing had failed in another thread", (Throwable) curState);

} else if (curState == GRAPH_CACHE_CLEARED) {
return null;

} else {
throw AnalysisError.shouldNotReachHere("Unknown state: " + curState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,10 @@ public static boolean verifyAssignableTypes(BigBang bb) {
}
}
}
return pass;
if (!pass) {
throw new AssertionError("Verification of all-instantiated type flows failed");
}
return true;
}

public static void updateAssignableTypes(BigBang bb) {
Expand Down Expand Up @@ -455,20 +458,26 @@ public static void updateAssignableTypes(BigBang bb) {
}
}
for (AnalysisType type : allTypes) {
if (type.assignableTypes != null) {
TypeState assignableTypeState = TypeState.forNull();
if (newAssignableTypes.get(type.getId()) != null) {
BitSet assignableTypes = newAssignableTypes.get(type.getId());
if (type.assignableTypes.getState().hasExactTypes(assignableTypes)) {
/* Avoid creation of the expensive type state. */
continue;
}
assignableTypeState = TypeState.forExactTypes(bb, newAssignableTypes.get(type.getId()), true);
if (type.assignableTypes == null) {
/*
* Computing assignable types in bulk here is much cheaper than doing it
* individually when needed in updateTypeFlows.
*/
type.assignableTypes = new AllInstantiatedTypeFlow(type, TypeState.forNull());
type.assignableTypesNonNull = new AllInstantiatedTypeFlow(type, TypeState.forEmpty());
}
TypeState assignableTypeState = TypeState.forNull();
if (newAssignableTypes.get(type.getId()) != null) {
BitSet assignableTypes = newAssignableTypes.get(type.getId());
if (type.assignableTypes.getState().hasExactTypes(assignableTypes)) {
/* Avoid creation of the expensive type state. */
continue;
}

updateFlow(bb, type.assignableTypes, assignableTypeState, changedFlows);
updateFlow(bb, type.assignableTypesNonNull, assignableTypeState.forNonNull(bb), changedFlows);
assignableTypeState = TypeState.forExactTypes(bb, newAssignableTypes.get(type.getId()), true);
}

updateFlow(bb, type.assignableTypes, assignableTypeState, changedFlows);
updateFlow(bb, type.assignableTypesNonNull, assignableTypeState.forNonNull(bb), changedFlows);
}

for (TypeFlow<?> changedFlow : changedFlows) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ public void init() {
}

public void init(Timing newTiming) {
assert isSequential() || !(executorService instanceof ForkJoinPool) || !((ForkJoinPool) executorService).hasQueuedSubmissions();

timing = newTiming;
setState(State.BEFORE_START);
postedOperations.reset();
Expand Down Expand Up @@ -235,7 +233,12 @@ public long complete() throws InterruptedException {
while (true) {
assert state.get() == State.STARTED;

boolean quiescent = executorService.awaitTermination(100, TimeUnit.MILLISECONDS);
boolean quiescent;
if (executorService instanceof ForkJoinPool) {
quiescent = ((ForkJoinPool) executorService).awaitQuiescence(100, TimeUnit.MILLISECONDS);
} else {
quiescent = executorService.awaitTermination(100, TimeUnit.MILLISECONDS);
}
if (timing != null && !quiescent) {
long curTime = System.nanoTime();
if (curTime - lastPrint > timing.getPrintIntervalNanos()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public Boolean getValue(OptionValues values) {
public static final RuntimeOptionKey<Integer> ActiveProcessorCount = new RuntimeOptionKey<>(-1);

@Option(help = "For internal purposes only. Disables type id result verification even when running with assertions enabled.", stability = OptionStability.EXPERIMENTAL, type = Debug)//
public static final HostedOptionKey<Boolean> DisableTypeIdResultVerification = new HostedOptionKey<>(false);
public static final HostedOptionKey<Boolean> DisableTypeIdResultVerification = new HostedOptionKey<>(true);

public static boolean areMethodHandlesSupported() {
return JavaVersionUtil.JAVA_SPEC >= 11;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import org.graalvm.compiler.core.common.type.StampFactory;
import org.graalvm.compiler.graph.Node.NodeIntrinsicFactory;
import org.graalvm.compiler.graph.NodeClass;
import org.graalvm.compiler.nodes.spi.Simplifiable;
import org.graalvm.compiler.nodes.spi.SimplifierTool;
import org.graalvm.compiler.nodeinfo.InputType;
import org.graalvm.compiler.nodeinfo.NodeCycles;
import org.graalvm.compiler.nodeinfo.NodeInfo;
Expand All @@ -40,6 +38,8 @@
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
import org.graalvm.compiler.nodes.memory.SingleMemoryKill;
import org.graalvm.compiler.nodes.spi.Lowerable;
import org.graalvm.compiler.nodes.spi.Simplifiable;
import org.graalvm.compiler.nodes.spi.SimplifierTool;
import org.graalvm.compiler.nodes.type.StampTool;
import org.graalvm.word.LocationIdentity;

Expand All @@ -59,10 +59,15 @@ public static boolean intrinsify(GraphBuilderContext b, ValueNode hub) {
return true;
}

public EnsureClassInitializedNode(ValueNode hub) {
public EnsureClassInitializedNode(ValueNode hub, FrameState stateAfter) {
super(TYPE, StampFactory.forVoid());
this.hub = hub;
assert StampTool.isPointerNonNull(hub) : "Hub must already be null-checked";
this.stateAfter = stateAfter;
}

public EnsureClassInitializedNode(ValueNode hub) {
this(hub, null);
}

public ValueNode getHub() {
Expand Down
Loading

0 comments on commit cb7fdfa

Please sign in to comment.