< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/Graph.java
Print this page
rev 52889 : 8214023: Update Graal
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -23,13 +23,10 @@
package org.graalvm.compiler.graph;
import static org.graalvm.compiler.core.common.GraalOptions.TrackNodeInsertion;
-import static org.graalvm.compiler.graph.Graph.SourcePositionTracking.Default;
-import static org.graalvm.compiler.graph.Graph.SourcePositionTracking.Track;
-import static org.graalvm.compiler.graph.Graph.SourcePositionTracking.UpdateOnly;
import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_IGNORED;
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_IGNORED;
import java.util.ArrayList;
import java.util.Arrays;
@@ -73,17 +70,10 @@
Unfrozen,
TemporaryFreeze,
DeepFreeze
}
- public enum SourcePositionTracking {
- Default,
- Ignore,
- UpdateOnly,
- Track
- }
-
public final String name;
/**
* The set of nodes in the graph, ordered by {@linkplain #register(Node) registration} time.
*/
@@ -95,11 +85,11 @@
NodeSourcePosition currentNodeSourcePosition;
/**
* Records if updating of node source information is required when performing inlining.
*/
- protected SourcePositionTracking trackNodeSourcePosition;
+ protected boolean trackNodeSourcePosition;
/**
* The number of valid entries in {@link #nodes}.
*/
int nodesSize;
@@ -222,42 +212,30 @@
*/
public DebugCloseable withoutNodeSourcePosition() {
return new NodeSourcePositionScope(null);
}
- /**
- * Determines if this graph might contain nodes with source information. This is mainly useful
- * to short circuit logic for updating those positions after inlining since that requires
- * visiting every node in the graph.
- */
- public boolean updateNodeSourcePosition() {
- return trackNodeSourcePosition == Track || trackNodeSourcePosition == UpdateOnly;
- }
-
public boolean trackNodeSourcePosition() {
- return trackNodeSourcePosition == Track;
+ return trackNodeSourcePosition;
}
public void setTrackNodeSourcePosition() {
- if (trackNodeSourcePosition != Track) {
- assert trackNodeSourcePosition == Default : trackNodeSourcePosition;
- trackNodeSourcePosition = Track;
+ if (!trackNodeSourcePosition) {
+ assert getNodeCount() == 1 : "can't change the value after nodes have been added";
+ trackNodeSourcePosition = true;
}
}
- public static SourcePositionTracking trackNodeSourcePositionDefault(OptionValues options, DebugContext debug) {
- if (GraalOptions.TrackNodeSourcePosition.getValue(options) || debug.isDumpEnabledForMethod()) {
- return Track;
- }
- return Default;
+ public static boolean trackNodeSourcePositionDefault(OptionValues options, DebugContext debug) {
+ return (GraalOptions.TrackNodeSourcePosition.getValue(options) || debug.isDumpEnabledForMethod());
}
/**
* Creates an empty Graph with no name.
*/
public Graph(OptionValues options, DebugContext debug) {
- this(null, options, debug);
+ this(null, options, debug, false);
}
/**
* We only want the expensive modification count tracking when assertions are enabled for the
* {@link Graph} class.
@@ -274,17 +252,17 @@
/**
* Creates an empty Graph with a given name.
*
* @param name the name of the graph, used for debugging purposes
*/
- public Graph(String name, OptionValues options, DebugContext debug) {
+ public Graph(String name, OptionValues options, DebugContext debug, boolean trackNodeSourcePosition) {
nodes = new Node[INITIAL_NODES_SIZE];
iterableNodesFirst = new ArrayList<>(NodeClass.allocatedNodeIterabledIds());
iterableNodesLast = new ArrayList<>(NodeClass.allocatedNodeIterabledIds());
this.name = name;
this.options = options;
- this.trackNodeSourcePosition = trackNodeSourcePositionDefault(options, debug);
+ this.trackNodeSourcePosition = trackNodeSourcePosition || trackNodeSourcePositionDefault(options, debug);
assert debug != null;
this.debug = debug;
if (isModificationCountsEnabled()) {
nodeModCounts = new int[INITIAL_NODES_SIZE];
@@ -383,14 +361,11 @@
* @param debugForCopy the debug context for the graph copy. This must not be the debug for this
* graph if this graph can be accessed from multiple threads (e.g., it's in a cache
* accessed by multiple threads).
*/
protected Graph copy(String newName, Consumer<UnmodifiableEconomicMap<Node, Node>> duplicationMapCallback, DebugContext debugForCopy) {
- Graph copy = new Graph(newName, options, debugForCopy);
- if (trackNodeSourcePosition()) {
- copy.setTrackNodeSourcePosition();
- }
+ Graph copy = new Graph(newName, options, debugForCopy, trackNodeSourcePosition());
UnmodifiableEconomicMap<Node, Node> duplicates = copy.addDuplicates(getNodes(), this, this.getNodeCount(), (EconomicMap<Node, Node>) null);
if (duplicationMapCallback != null) {
duplicationMapCallback.accept(duplicates);
}
return copy;
@@ -553,11 +528,11 @@
NODE_ADDED,
/**
* A node was removed from the graph.
*/
- NODE_REMOVED;
+ NODE_REMOVED
}
/**
* Client interested in one or more node related events.
*/
< prev index next >