changeset 6457:03a1a0c5ee84

removed IsTypeNode and replaced its usage with an ObjectEqualsNode
author Doug Simon <doug.simon@oracle.com>
date Thu, 27 Sep 2012 21:37:46 +0200
parents a20c8500770c
children fb66841a0994
files graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/phases/CheckCastEliminationPhase.java graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/util/InliningUtil.java graal/com.oracle.graal.compiler.virtual/src/com/oracle/graal/compiler/phases/ea/PartialEscapeAnalysisPhase.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/IsTypeNode.java
diffstat 6 files changed, 4 insertions(+), 119 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/phases/CheckCastEliminationPhase.java	Thu Sep 27 20:29:17 2012 +0200
+++ b/graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/phases/CheckCastEliminationPhase.java	Thu Sep 27 21:37:46 2012 +0200
@@ -30,7 +30,6 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.nodes.util.*;
@@ -38,7 +37,6 @@
 public class CheckCastEliminationPhase extends Phase {
 
     private static final DebugMetric metricInstanceOfRegistered = Debug.metric("InstanceOfRegistered");
-    private static final DebugMetric metricIsTypeRegistered = Debug.metric("IsTypeRegistered");
     private static final DebugMetric metricNullCheckRegistered = Debug.metric("NullCheckRegistered");
     private static final DebugMetric metricCheckCastRemoved = Debug.metric("CheckCastRemoved");
     private static final DebugMetric metricInstanceOfRemoved = Debug.metric("InstanceOfRemoved");
@@ -290,15 +288,6 @@
                             state.knownNotNull.add(nullCheck.object());
                         }
                         metricNullCheckRegistered.increment();
-                    } else if (ifNode.compare() instanceof IsTypeNode) {
-                        IsTypeNode isType = (IsTypeNode) ifNode.compare();
-                        if (isType.objectClass() instanceof ReadHubNode && (node == ifNode.trueSuccessor())) {
-                            ReadHubNode readHub = (ReadHubNode) isType.objectClass();
-                            ValueNode object = readHub.object();
-                            state.knownNotNull.add(object);
-                            state.knownTypes.put(object, tighten(isType.type(), state.getNodeType(object)));
-                            metricIsTypeRegistered.increment();
-                        }
                     }
                 }
                 for (GuardNode guard : begin.guards().snapshot()) {
--- a/graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/util/InliningUtil.java	Thu Sep 27 20:29:17 2012 +0200
+++ b/graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/util/InliningUtil.java	Thu Sep 27 21:37:46 2012 +0200
@@ -28,6 +28,7 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.meta.JavaType.Representation;
 import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType;
 import com.oracle.graal.compiler.*;
 import com.oracle.graal.compiler.phases.*;
@@ -191,8 +192,9 @@
             InliningUtil.receiverNullCheck(invoke);
             ValueNode receiver = invoke.methodCallTarget().receiver();
             ReadHubNode receiverHub = graph.add(new ReadHubNode(receiver));
-            IsTypeNode isTypeNode = graph.unique(new IsTypeNode(receiverHub, type));
-            FixedGuardNode guard = graph.add(new FixedGuardNode(isTypeNode, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile, invoke.leafGraphId()));
+            ConstantNode typeHub = ConstantNode.forConstant(type.getEncoding(Representation.ObjectHub), runtime, graph);
+            ObjectEqualsNode typeCheck = graph.unique(new ObjectEqualsNode(receiverHub, typeHub));
+            FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile, invoke.leafGraphId()));
             ValueAnchorNode anchor = graph.add(new ValueAnchorNode());
             assert invoke.predecessor() != null;
 
--- a/graal/com.oracle.graal.compiler.virtual/src/com/oracle/graal/compiler/phases/ea/PartialEscapeAnalysisPhase.java	Thu Sep 27 20:29:17 2012 +0200
+++ b/graal/com.oracle.graal.compiler.virtual/src/com/oracle/graal/compiler/phases/ea/PartialEscapeAnalysisPhase.java	Thu Sep 27 21:37:46 2012 +0200
@@ -440,8 +440,6 @@
                     metricOtherRemoved.increment();
                 }
                 usageFound = true;
-            } else if (node instanceof IsTypeNode) {
-                throw new GraalInternalError("a newly created object can never be an object hub");
             } else if (node instanceof AccessMonitorNode) {
                 AccessMonitorNode x = (AccessMonitorNode) node;
                 ObjectState obj = state.objectState(x.object());
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Thu Sep 27 20:29:17 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Thu Sep 27 21:37:46 2012 +0200
@@ -33,7 +33,6 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.code.CompilationResult.Mark;
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.meta.JavaType.Representation;
 import com.oracle.graal.compiler.*;
 import com.oracle.graal.compiler.util.*;
 import com.oracle.graal.debug.*;
@@ -689,8 +688,6 @@
             emitInstanceOfBranch((InstanceOfNode) node, trueSuccessor, falseSuccessor, info);
         } else if (node instanceof ConstantNode) {
             emitConstantBranch(((ConstantNode) node).asConstant().asBoolean(), trueSuccessor, falseSuccessor, info);
-        } else if (node instanceof IsTypeNode) {
-            emitTypeBranch((IsTypeNode) node, trueSuccessor, falseSuccessor, info);
         } else {
             throw GraalInternalError.unimplemented(node.toString());
         }
@@ -731,16 +728,6 @@
         }
     }
 
-    public void emitTypeBranch(IsTypeNode x, LabelRef trueSuccessor, LabelRef falseSuccessor, LIRFrameState info) {
-        XirArgument thisClass = toXirArgument(x.objectClass());
-        XirArgument otherClass = toXirArgument(x.type().getEncoding(Representation.ObjectHub));
-        XirSnippet snippet = xir.genTypeBranch(site(x), thisClass, otherClass, x.type());
-        emitXir(snippet, x, info, null, false, trueSuccessor, falseSuccessor);
-        if (trueSuccessor != null) {
-            emitJump(trueSuccessor, null);
-        }
-    }
-
     @Override
     public void emitConditional(ConditionalNode conditional) {
         Value tVal = operand(conditional.trueValue());
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Thu Sep 27 20:29:17 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Thu Sep 27 21:37:46 2012 +0200
@@ -418,12 +418,6 @@
             if (matches(graph, GraalOptions.HIRLowerInstanceOf)) {
                 instanceofSnippets.lower((InstanceOfNode) n, tool);
             }
-        } else if (n instanceof IsTypeNode) {
-            IsTypeNode isType = (IsTypeNode) n;
-            ValueNode objectHub = isType.objectClass();
-            ConstantNode hub = ConstantNode.forObject(new HotSpotKlassOop(isType.type()), this, graph);
-            ObjectEqualsNode typeCheck = graph.unique(new ObjectEqualsNode(objectHub, hub));
-            graph.replaceFloating(isType, typeCheck);
         } else if (n instanceof NewInstanceNode) {
             if (matches(graph, GraalOptions.HIRLowerNewInstance)) {
                 newObjectSnippets.lower((NewInstanceNode) n, tool);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/IsTypeNode.java	Thu Sep 27 20:29:17 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2009, 2011, 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.java;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.meta.JavaType.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.nodes.type.*;
-
-public final class IsTypeNode extends BooleanNode implements Canonicalizable, Lowerable, LIRLowerable {
-
-    @Input private ValueNode objectClass;
-    private final ResolvedJavaType type;
-
-    public ValueNode objectClass() {
-        return objectClass;
-    }
-
-    /**
-     * Constructs a new IsTypeNode.
-     *
-     * @param objectClass the instruction producing the object to check against the given type
-     * @param type the type for this check
-     */
-    public IsTypeNode(ValueNode objectClass, ResolvedJavaType type) {
-        super(StampFactory.condition());
-        assert objectClass == null || objectClass.kind() == Kind.Object;
-        this.type = type;
-        this.objectClass = objectClass;
-    }
-
-    public ResolvedJavaType type() {
-        return type;
-    }
-
-    @Override
-    public void lower(LoweringTool tool) {
-        tool.getRuntime().lower(this, tool);
-    }
-
-    @Override
-    public void generate(LIRGeneratorTool gen) {
-        // nothing to do
-    }
-
-    @Override
-    public ValueNode canonical(CanonicalizerTool tool) {
-        if (objectClass().isConstant()) {
-            Constant constant = objectClass().asConstant();
-            Constant typeHub = type.getEncoding(Representation.ObjectHub);
-            assert constant.getKind() == typeHub.getKind();
-            return ConstantNode.forBoolean(tool.runtime().areConstantObjectsEqual(constant, typeHub), graph());
-        }
-        // TODO(ls) since a ReadHubNode with an exactType should canonicalize itself to a constant this should actually never happen, maybe turn into an assertion?
-        if (objectClass() instanceof ReadHubNode) {
-            ObjectStamp stamp = ((ReadHubNode) objectClass()).object().objectStamp();
-            if (stamp.isExactType()) {
-                return ConstantNode.forBoolean(stamp.type() == type(), graph());
-            }
-        }
-        return this;
-    }
-}