# HG changeset patch # User Gilles Duboscq # Date 1338479841 -7200 # Node ID c73882b7db101b13493e2677b77f14115013383a # Parent 071f24ba116e67a64a80754f10f3e816e5126a5f runtime may be null in the canonicalizer (like target or assumptions) diff -r 071f24ba116e -r c73882b7db10 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java Wed May 30 18:14:20 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java Thu May 31 17:57:21 2012 +0200 @@ -57,12 +57,12 @@ @Override public ValueNode canonical(CanonicalizerTool tool) { - if (object() != null && object().isConstant() && object().kind() == CiKind.Object) { + RiRuntime runtime = tool.runtime(); + if (runtime != null && object() != null && object().isConstant() && object().kind() == CiKind.Object) { if (this.location() == LocationNode.FINAL_LOCATION && location().getClass() == LocationNode.class) { Object value = object().asConstant().asObject(); long displacement = location().displacement(); CiKind kind = location().kind(); - RiRuntime runtime = tool.runtime(); CiConstant constant = kind.readUnsafeConstant(value, displacement); if (constant != null) { return ConstantNode.forCiConstant(constant, runtime, graph()); diff -r 071f24ba116e -r c73882b7db10 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadHubNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadHubNode.java Wed May 30 18:14:20 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadHubNode.java Thu May 31 17:57:21 2012 +0200 @@ -49,22 +49,25 @@ @Override public ValueNode canonical(CanonicalizerTool tool) { - ObjectStamp stamp = object.objectStamp(); + RiRuntime runtime = tool.runtime(); + if (runtime != null) { + ObjectStamp stamp = object.objectStamp(); - RiResolvedType exactType; - if (stamp.isExactType()) { - exactType = stamp.type(); - } else if (stamp.type() != null && tool.assumptions() != null) { - exactType = stamp.type().uniqueConcreteSubtype(); + RiResolvedType exactType; + if (stamp.isExactType()) { + exactType = stamp.type(); + } else if (stamp.type() != null && tool.assumptions() != null) { + exactType = stamp.type().uniqueConcreteSubtype(); + if (exactType != null) { + tool.assumptions().recordConcreteSubtype(stamp.type(), exactType); + } + } else { + exactType = null; + } + if (exactType != null) { - tool.assumptions().recordConcreteSubtype(stamp.type(), exactType); + return ConstantNode.forCiConstant(exactType.getEncoding(Representation.ObjectHub), runtime, graph()); } - } else { - exactType = null; - } - - if (exactType != null) { - return ConstantNode.forCiConstant(exactType.getEncoding(Representation.ObjectHub), tool.runtime(), graph()); } return this; } diff -r 071f24ba116e -r c73882b7db10 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Wed May 30 18:14:20 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Thu May 31 17:57:21 2012 +0200 @@ -43,12 +43,12 @@ @Override public ValueNode canonical(CanonicalizerTool tool) { - if (object() != null && object().isConstant() && object().kind() == CiKind.Object) { + RiRuntime runtime = tool.runtime(); + if (runtime != null && object() != null && object().isConstant() && object().kind() == CiKind.Object) { if (location() == LocationNode.FINAL_LOCATION && location().getClass() == LocationNode.class) { Object value = object().asConstant().asObject(); long displacement = location().displacement(); CiKind kind = location().kind(); - RiRuntime runtime = tool.runtime(); CiConstant constant = kind.readUnsafeConstant(value, displacement); if (constant != null) { return ConstantNode.forCiConstant(constant, runtime, graph()); diff -r 071f24ba116e -r c73882b7db10 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java Wed May 30 18:14:20 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java Thu May 31 17:57:21 2012 +0200 @@ -52,11 +52,10 @@ assert length != null; return length; } - CiConstant constantValue = null; - if (array().isConstant() && !array().isNullConstant()) { - constantValue = array().asConstant(); + RiRuntime runtime = tool.runtime(); + if (runtime != null && array().isConstant() && !array().isNullConstant()) { + CiConstant constantValue = array().asConstant(); if (constantValue != null && constantValue.isNonNull()) { - RiRuntime runtime = tool.runtime(); return ConstantNode.forInt(runtime.getArrayLength(constantValue), graph()); } } diff -r 071f24ba116e -r c73882b7db10 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadFieldNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadFieldNode.java Wed May 30 18:14:20 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadFieldNode.java Thu May 31 17:57:21 2012 +0200 @@ -55,14 +55,17 @@ @Override public ValueNode canonical(CanonicalizerTool tool) { - CiConstant constant = null; - if (isStatic()) { - constant = field().constantValue(null); - } else if (object().isConstant() && !object().isNullConstant()) { - constant = field().constantValue(object().asConstant()); - } - if (constant != null) { - return ConstantNode.forCiConstant(constant, tool.runtime(), graph()); + RiRuntime runtime = tool.runtime(); + if (runtime != null) { + CiConstant constant = null; + if (isStatic()) { + constant = field().constantValue(null); + } else if (object().isConstant() && !object().isNullConstant()) { + constant = field().constantValue(object().asConstant()); + } + if (constant != null) { + return ConstantNode.forCiConstant(constant, runtime, graph()); + } } return this; } diff -r 071f24ba116e -r c73882b7db10 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadIndexedNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadIndexedNode.java Wed May 30 18:14:20 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadIndexedNode.java Thu May 31 17:57:21 2012 +0200 @@ -32,6 +32,7 @@ import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; /** * The {@code LoadIndexedNode} represents a read from an element of an array. @@ -63,7 +64,8 @@ @Override public ValueNode canonical(CanonicalizerTool tool) { - if (index().isConstant() && array().isConstant() && !array().isNullConstant()) { + RiRuntime runtime = tool.runtime(); + if (runtime != null && index().isConstant() && array().isConstant() && !array().isNullConstant()) { CiConstant arrayConst = array().asConstant(); if (tool.isImmutable(arrayConst)) { int index = index().asConstant().asInt(); @@ -71,7 +73,7 @@ int length = Array.getLength(array); if (index >= 0 && index < length) { return ConstantNode.forCiConstant(elementKind().readUnsafeConstant(array, - Unsafe.ARRAY_OBJECT_BASE_OFFSET + index * Unsafe.ARRAY_OBJECT_INDEX_SCALE), tool.runtime(), graph()); + Unsafe.ARRAY_OBJECT_BASE_OFFSET + index * Unsafe.ARRAY_OBJECT_INDEX_SCALE), runtime, graph()); } } }