use of org.graalvm.compiler.nodes.calc.FloatingNode in project graal by oracle.
the class IntegerExactArithmeticSplitNode method lower.
static void lower(LoweringTool tool, IntegerExactArithmeticNode node) {
if (node.asNode().graph().getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
FloatingNode floatingNode = (FloatingNode) node;
FixedWithNextNode previous = tool.lastFixedNode();
FixedNode next = previous.next();
previous.setNext(null);
DeoptimizeNode deopt = floatingNode.graph().add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.ArithmeticException));
AbstractBeginNode normalBegin = floatingNode.graph().add(new BeginNode());
normalBegin.setNext(next);
IntegerExactArithmeticSplitNode split = node.createSplit(normalBegin, BeginNode.begin(deopt));
previous.setNext(split);
floatingNode.replaceAndDelete(split);
}
}
use of org.graalvm.compiler.nodes.calc.FloatingNode in project graal by oracle.
the class FrameStateBuilder method initializeForMethodStart.
public void initializeForMethodStart(Assumptions assumptions, boolean eagerResolve, Plugins plugins) {
int javaIndex = 0;
int index = 0;
ResolvedJavaMethod method = getMethod();
ResolvedJavaType originalType = method.getDeclaringClass();
if (!method.isStatic()) {
// add the receiver
FloatingNode receiver = null;
StampPair receiverStamp = null;
if (plugins != null) {
receiverStamp = plugins.getOverridingStamp(tool, originalType, true);
}
if (receiverStamp == null) {
receiverStamp = StampFactory.forDeclaredType(assumptions, originalType, true);
}
if (plugins != null) {
for (ParameterPlugin plugin : plugins.getParameterPlugins()) {
receiver = plugin.interceptParameter(tool, index, receiverStamp);
if (receiver != null) {
break;
}
}
}
if (receiver == null) {
receiver = new ParameterNode(javaIndex, receiverStamp);
}
locals[javaIndex] = graph.addOrUniqueWithInputs(receiver);
javaIndex = 1;
index = 1;
}
Signature sig = method.getSignature();
int max = sig.getParameterCount(false);
ResolvedJavaType accessingClass = originalType;
for (int i = 0; i < max; i++) {
JavaType type = sig.getParameterType(i, accessingClass);
if (eagerResolve) {
type = type.resolve(accessingClass);
}
JavaKind kind = type.getJavaKind();
StampPair stamp = null;
if (plugins != null) {
stamp = plugins.getOverridingStamp(tool, type, false);
}
if (stamp == null) {
stamp = StampFactory.forDeclaredType(assumptions, type, false);
}
FloatingNode param = null;
if (plugins != null) {
for (ParameterPlugin plugin : plugins.getParameterPlugins()) {
param = plugin.interceptParameter(tool, index, stamp);
if (param != null) {
break;
}
}
}
if (param == null) {
param = new ParameterNode(index, stamp);
}
locals[javaIndex] = graph.addOrUniqueWithInputs(param);
javaIndex++;
if (kind.needsTwoSlots()) {
locals[javaIndex] = TWO_SLOT_MARKER;
javaIndex++;
}
index++;
}
}
use of org.graalvm.compiler.nodes.calc.FloatingNode in project graal by oracle.
the class DefaultHotSpotLoweringProvider method throwCachedException.
private boolean throwCachedException(BytecodeExceptionNode node) {
Throwable exception;
if (node.getExceptionClass() == NullPointerException.class) {
exception = Exceptions.cachedNullPointerException;
} else if (node.getExceptionClass() == ArrayIndexOutOfBoundsException.class) {
exception = Exceptions.cachedArrayIndexOutOfBoundsException;
} else {
return false;
}
StructuredGraph graph = node.graph();
FloatingNode exceptionNode = ConstantNode.forConstant(constantReflection.forObject(exception), metaAccess, graph);
graph.replaceFixedWithFloating(node, exceptionNode);
return true;
}
use of org.graalvm.compiler.nodes.calc.FloatingNode in project graal by oracle.
the class ReplaceConstantNodesPhase method findFixedBeforeFloating.
/**
* Find the first {@link FixedWithNextNode} that is currently scheduled before the given
* floating node.
*
* @param graph
* @param node start search from this node up
* @return the first {@link FixedWithNextNode}
*/
private static FixedWithNextNode findFixedBeforeFloating(StructuredGraph graph, FloatingNode node) {
ScheduleResult schedule = graph.getLastSchedule();
NodeMap<Block> nodeToBlock = schedule.getNodeToBlockMap();
Block block = nodeToBlock.get(node);
BlockMap<List<Node>> blockToNodes = schedule.getBlockToNodesMap();
FixedWithNextNode result = null;
for (Node n : blockToNodes.get(block)) {
if (n.equals(node)) {
break;
}
if (n instanceof FixedWithNextNode) {
result = (FixedWithNextNode) n;
}
}
assert result != null;
return result;
}
use of org.graalvm.compiler.nodes.calc.FloatingNode in project graal by oracle.
the class CFGPrinter method printNode.
private void printNode(Node node, boolean unscheduled) {
assert !printedNodes.isMarked(node);
printedNodes.mark(node);
if (!(node instanceof ValuePhiNode)) {
for (Node input : node.inputs()) {
if (!inFixedSchedule(input) && !printedNodes.isMarked(input)) {
printNode(input, true);
}
}
}
if (unscheduled) {
assert lir == null && schedule == null : "unscheduled nodes can only be present before LIR generation";
out.print("f ").print(HOVER_START).print("u").print(HOVER_SEP).print("unscheduled").print(HOVER_END).println(COLUMN_END);
} else if (node instanceof FixedWithNextNode) {
out.print("f ").print(HOVER_START).print("#").print(HOVER_SEP).print("fixed with next").print(HOVER_END).println(COLUMN_END);
} else if (node instanceof FixedNode) {
out.print("f ").print(HOVER_START).print("*").print(HOVER_SEP).print("fixed").print(HOVER_END).println(COLUMN_END);
} else if (node instanceof FloatingNode) {
out.print("f ").print(HOVER_START).print("~").print(HOVER_SEP).print("floating").print(HOVER_END).println(COLUMN_END);
}
out.print("tid ").print(nodeToString(node)).println(COLUMN_END);
if (nodeLirGenerator != null) {
Value operand = nodeLirGenerator.hasOperand(node) ? nodeLirGenerator.operand(node) : null;
if (operand != null) {
out.print("result ").print(operand.toString()).println(COLUMN_END);
}
}
if (node instanceof StateSplit) {
StateSplit stateSplit = (StateSplit) node;
if (stateSplit.stateAfter() != null) {
String state = stateToString(stateSplit.stateAfter());
out.print("st ").print(HOVER_START).print("st").print(HOVER_SEP).print(state).print(HOVER_END).println(COLUMN_END);
}
}
Map<Object, Object> props = new TreeMap<>(node.getDebugProperties());
out.print("d ").print(HOVER_START).print("d").print(HOVER_SEP);
out.println("=== Debug Properties ===");
for (Map.Entry<Object, Object> entry : props.entrySet()) {
out.print(entry.getKey().toString()).print(": ").print(entry.getValue() == null ? "[null]" : entry.getValue().toString()).println();
}
out.println("=== Inputs ===");
printNamedNodes(node, node.inputPositions().iterator(), "", "\n", null);
out.println("=== Succesors ===");
printNamedNodes(node, node.successorPositions().iterator(), "", "\n", null);
out.println("=== Usages ===");
if (!node.hasNoUsages()) {
for (Node usage : node.usages()) {
out.print(nodeToString(usage)).print(" ");
}
out.println();
}
out.println("=== Predecessor ===");
out.print(nodeToString(node.predecessor())).print(" ");
out.print(HOVER_END).println(COLUMN_END);
out.print("instruction ");
out.print(HOVER_START).print(node.getNodeClass().shortName()).print(HOVER_SEP).print(node.getClass().getName()).print(HOVER_END).print(" ");
printNamedNodes(node, node.inputPositions().iterator(), "", "", "#NDF");
printNamedNodes(node, node.successorPositions().iterator(), "#", "", "#NDF");
for (Map.Entry<Object, Object> entry : props.entrySet()) {
String key = entry.getKey().toString();
if (key.startsWith("data.") && !key.equals("data.stamp")) {
out.print(key.substring("data.".length())).print(": ").print(entry.getValue() == null ? "[null]" : entry.getValue().toString()).print(" ");
}
}
out.print(COLUMN_END).print(' ').println(COLUMN_END);
}
Aggregations