Mercurial > hg > graal-jvmci-8
changeset 21655:31f4a8259879
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 02 Jun 2015 11:55:30 +0200 |
parents | cd6b1b2189a0 (diff) ec47283499ef (current diff) |
children | e49a0ebb2659 |
files | |
diffstat | 6 files changed, 22 insertions(+), 172 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Tue Jun 02 11:27:04 2015 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Tue Jun 02 11:55:30 2015 +0200 @@ -2907,16 +2907,15 @@ ValueNode checkCastNode = null; if (profile != null) { if (profile.getNullSeen().isFalse()) { - object = append(GuardingPiNode.createNullCheck(object)); + object = appendNullCheck(object); ResolvedJavaType singleType = profile.asSingleType(); if (singleType != null) { LogicNode typeCheck = append(TypeCheckNode.create(singleType, object)); if (typeCheck.isTautology()) { checkCastNode = object; } else { - GuardingPiNode piNode = append(new GuardingPiNode(object, typeCheck, false, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile, - StampFactory.exactNonNull(singleType))); - checkCastNode = piNode; + FixedGuardNode fixedGuard = append(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile, false)); + checkCastNode = append(new PiNode(object, StampFactory.exactNonNull(singleType), fixedGuard)); } } } @@ -2927,6 +2926,12 @@ frameState.push(Kind.Object, checkCastNode); } + private ValueNode appendNullCheck(ValueNode object) { + IsNullNode isNull = append(new IsNullNode(object)); + FixedGuardNode fixedGuard = append(new FixedGuardNode(isNull, DeoptimizationReason.NullCheckException, DeoptimizationAction.InvalidateReprofile, true)); + return append(new PiNode(object, object.stamp().join(StampFactory.objectNonNull()), fixedGuard)); + } + private void genInstanceOf() { int cpi = getStream().readCPI(); JavaType type = lookupType(cpi, INSTANCEOF); @@ -2948,7 +2953,7 @@ ValueNode instanceOfNode = null; if (profile != null) { if (profile.getNullSeen().isFalse()) { - object = append(GuardingPiNode.createNullCheck(object)); + object = appendNullCheck(object); ResolvedJavaType singleType = profile.asSingleType(); if (singleType != null) { LogicNode typeCheck = append(TypeCheckNode.create(singleType, object));
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java Tue Jun 02 11:27:04 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2012, 2015, 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.nodes; - -import com.oracle.graal.compiler.common.type.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.graph.spi.*; -import com.oracle.graal.nodeinfo.*; -import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; -import com.oracle.jvmci.meta.*; - -/** - * A node that changes the stamp of its input based on some condition being true. - */ -@NodeInfo(nameTemplate = "GuardingPi(!={p#negated}) {p#reason/s}") -public final class GuardingPiNode extends FixedWithNextNode implements Lowerable, Virtualizable, Canonicalizable, ValueProxy { - - public static final NodeClass<GuardingPiNode> TYPE = NodeClass.create(GuardingPiNode.class); - @Input ValueNode object; - @Input(InputType.Condition) LogicNode condition; - protected final DeoptimizationReason reason; - protected final DeoptimizationAction action; - protected final Stamp piStamp; - protected boolean negated; - - public ValueNode object() { - return object; - } - - public LogicNode condition() { - return condition; - } - - public boolean isNegated() { - return negated; - } - - public DeoptimizationReason getReason() { - return reason; - } - - public DeoptimizationAction getAction() { - return action; - } - - public GuardingPiNode(ValueNode object) { - this(object, object.graph().unique(new IsNullNode(object)), true, DeoptimizationReason.NullCheckException, DeoptimizationAction.None, object.stamp().join(StampFactory.objectNonNull())); - } - - public GuardingPiNode(ValueNode object, ValueNode condition, boolean negateCondition, DeoptimizationReason reason, DeoptimizationAction action, Stamp stamp) { - super(TYPE, stamp); - assert stamp != null; - this.piStamp = stamp; - this.object = object; - this.condition = (LogicNode) condition; - this.reason = reason; - this.action = action; - this.negated = negateCondition; - } - - public static ValueNode createNullCheck(ValueNode object) { - ObjectStamp objectStamp = (ObjectStamp) object.stamp(); - if (objectStamp.nonNull()) { - return object; - } else { - return new GuardingPiNode(object); - } - } - - @Override - public void lower(LoweringTool tool) { - GuardingNode guard = tool.createGuard(next(), condition, reason, action, negated); - ValueAnchorNode anchor = graph().add(new ValueAnchorNode((ValueNode) guard)); - if (usages().isNotEmpty()) { - PiNode pi = graph().unique(new PiNode(object, stamp(), (ValueNode) guard)); - replaceAtUsages(pi); - } - graph().replaceFixedWithFixed(this, anchor); - } - - @Override - public void virtualize(VirtualizerTool tool) { - State state = tool.getObjectState(object); - if (state != null && state.getState() == EscapeState.Virtual && StampTool.typeOrNull(this) != null && StampTool.typeOrNull(this).isAssignableFrom(state.getVirtualObject().type())) { - tool.replaceWithVirtual(state.getVirtualObject()); - } - } - - @Override - public boolean inferStamp() { - return updateStamp(piStamp.join(object().stamp())); - } - - @Override - public Node canonical(CanonicalizerTool tool) { - if (stamp().isEmpty()) { - // The guard always fails - return new DeoptimizeNode(action, reason); - } - if (condition instanceof LogicConstantNode) { - LogicConstantNode c = (LogicConstantNode) condition; - if (c.getValue() == negated) { - // The guard always fails - return new DeoptimizeNode(action, reason); - } else if (stamp().equals(object().stamp())) { - // The guard always succeeds, and does not provide new type information - return object; - } else { - // The guard always succeeds, and provides new type information - return new PiNode(object, stamp()); - } - } - return this; - } - - @NodeIntrinsic - public static native Object guardingNonNull(Object object); - - @Override - public ValueNode getOriginalNode() { - return object; - } - - /** - * Casts a value to have an exact, non-null stamp representing {@link Class} that is guarded by - * a null check. - */ - @NodeIntrinsic(GuardingPiNode.class) - public static native Class<?> asNonNullClass(Class<?> c); -}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Tue Jun 02 11:27:04 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Tue Jun 02 11:55:30 2015 +0200 @@ -32,6 +32,7 @@ import com.oracle.graal.nodeinfo.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; +import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; import com.oracle.jvmci.meta.*; @@ -90,7 +91,7 @@ } /** - * Lowers a {@link CheckCastNode} to a {@link GuardingPiNode}. That is: + * Lowers a {@link CheckCastNode}. That is: * * <pre> * 1: A a = ... @@ -118,7 +119,7 @@ @Override public void lower(LoweringTool tool) { Stamp newStamp = StampFactory.declaredTrusted(type).improveWith(object().stamp()); - ValueNode condition; + LogicNode condition; ValueNode theValue = object; if (newStamp.isEmpty()) { // This is a check cast that will always fail @@ -148,9 +149,11 @@ condition = LogicNode.or(graph().unique(new IsNullNode(object)), typeTest, shortCircuitProbability); } } - GuardingPiNode checkedObject = graph().add(new GuardingPiNode(theValue, condition, false, forStoreCheck ? ArrayStoreException : ClassCastException, InvalidateReprofile, newStamp)); - graph().replaceFixedWithFixed(this, checkedObject); - checkedObject.lower(tool); + GuardingNode guard = tool.createGuard(next(), condition, forStoreCheck ? ArrayStoreException : ClassCastException, InvalidateReprofile, false); + ValueAnchorNode valueAnchor = graph().add(new ValueAnchorNode((ValueNode) guard)); + PiNode piNode = graph().unique(new PiNode(theValue, newStamp, valueAnchor)); + this.replaceAtUsages(piNode); + graph().replaceFixedWithFixed(this, valueAnchor); } @Override
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java Tue Jun 02 11:27:04 2015 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java Tue Jun 02 11:55:30 2015 +0200 @@ -655,8 +655,9 @@ if (firstParam.getKind() == Kind.Object && !StampTool.isPointerNonNull(firstParam)) { IsNullNode condition = graph.unique(new IsNullNode(firstParam)); Stamp stamp = firstParam.stamp().join(objectNonNull()); - GuardingPiNode nonNullReceiver = graph.add(new GuardingPiNode(firstParam, condition, true, NullCheckException, InvalidateReprofile, stamp)); - graph.addBeforeFixed(invoke.asNode(), nonNullReceiver); + FixedGuardNode fixedGuard = graph.add(new FixedGuardNode(condition, NullCheckException, InvalidateReprofile, true)); + PiNode nonNullReceiver = graph.unique(new PiNode(firstParam, stamp, fixedGuard)); + graph.addBeforeFixed(invoke.asNode(), fixedGuard); callTarget.replaceFirstInput(firstParam, nonNullReceiver); return nonNullReceiver; }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java Tue Jun 02 11:27:04 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java Tue Jun 02 11:55:30 2015 +0200 @@ -95,7 +95,7 @@ */ protected InstanceOfUsageReplacer createReplacer(FloatingNode instanceOf, Instantiation instantiation, Node usage, final StructuredGraph graph) { InstanceOfUsageReplacer replacer; - if (usage instanceof IfNode || usage instanceof FixedGuardNode || usage instanceof ShortCircuitOrNode || usage instanceof GuardingPiNode || usage instanceof ConditionAnchorNode) { + if (usage instanceof IfNode || usage instanceof FixedGuardNode || usage instanceof ShortCircuitOrNode || usage instanceof ConditionAnchorNode) { ValueNode trueValue = ConstantNode.forInt(1, graph); ValueNode falseValue = ConstantNode.forInt(0, graph); if (instantiation.isInitialized() && (trueValue != instantiation.trueValue || falseValue != instantiation.falseValue)) {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Tue Jun 02 11:27:04 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Tue Jun 02 11:55:30 2015 +0200 @@ -489,12 +489,6 @@ for (Node piUsage : usage.usages().snapshot()) { checkCheckCastUsage(graph, intrinsifiedNode, usage, piUsage); } - } else if (usage instanceof GuardingPiNode) { - GuardingPiNode pi = (GuardingPiNode) usage; - for (Node piUsage : pi.usages().snapshot()) { - checkCheckCastUsage(graph, intrinsifiedNode, usage, piUsage); - } - graph.removeFixed(pi); } else { DebugScope.forceDump(graph, "exception"); assert false : sourceLocation(usage) + " has unexpected usage " + usage + " of checkcast " + input + " at " + sourceLocation(input);