changeset 5543:25d561cfdcfa

Clean up in api classes. Removed CiGenericCallback. Simplified Constant.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 09 Jun 2012 17:24:23 +0200
parents e318468952f5
children 20e390e09717
files graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CiGenericCallback.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/Util.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/IsTypeNode.java
diffstat 5 files changed, 3 insertions(+), 120 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CiGenericCallback.java	Sat Jun 09 17:13:21 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 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.api.code;
-
-/**
- * This interface is used for {@link CiRuntimeCall#GenericCallback} runtime calls.
- */
-public abstract class CiGenericCallback {
-
-    @SuppressWarnings("unused")
-    private Object callbackInternal(Object arg) {
-        try {
-            return callback(arg);
-        } catch (Throwable t) {
-            t.printStackTrace();
-            return null;
-        }
-    }
-
-    public abstract Object callback(Object arg);
-}
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java	Sat Jun 09 17:13:21 2012 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java	Sat Jun 09 17:24:23 2012 +0200
@@ -56,20 +56,8 @@
     public static final Constant FALSE = new Constant(Kind.Boolean, 0L);
 
     static {
-        assert NULL_OBJECT.isDefaultValue();
-        assert INT_0.isDefaultValue();
-        assert FLOAT_0.isDefaultValue();
-        assert DOUBLE_0.isDefaultValue();
-        assert FALSE.isDefaultValue();
-
-        // Ensure difference between 0.0f and -0.0f is preserved
-        assert FLOAT_0 != forFloat(-0.0F);
-        assert !forFloat(-0.0F).isDefaultValue();
-
-        // Ensure difference between 0.0d and -0.0d is preserved
-        assert DOUBLE_0 != forDouble(-0.0d);
-        assert !forDouble(-0.0D).isDefaultValue();
-
+        assert FLOAT_0 != forFloat(-0.0F) : "Constant for 0.0f must be different from -0.0f";
+        assert DOUBLE_0 != forDouble(-0.0d) : "Constant for 0.0d must be different from -0.0d";
         assert NULL_OBJECT.isNull();
     }
 
@@ -307,50 +295,6 @@
     }
 
     /**
-     * Checks whether this constant is identical to another constant or has the same value as it.
-     * @param other the constant to compare for equality against this constant
-     * @return {@code true} if this constant is equivalent to {@code other}
-     */
-    public boolean equivalent(Constant other) {
-        return other == this || valueEqual(other, false);
-    }
-
-    /**
-     * Checks whether this constant is the default value for its type.
-     * @return {@code true} if the value is the default value for its type; {@code false} otherwise
-     */
-    public boolean isDefaultValue() {
-        // Checkstyle: stop
-        switch (kind.stackKind()) {
-            case Int: return asInt() == 0;
-            case Long: return asLong() == 0;
-            case Float: return this == FLOAT_0;
-            case Double: return this == DOUBLE_0;
-            case Object: return object == null;
-        }
-        // Checkstyle: resume
-        throw new IllegalArgumentException("Cannot det default CiConstant for kind " + kind);
-    }
-
-    /**
-     * Gets the default value for a given kind.
-     *
-     * @return the default value for {@code kind}'s {@linkplain Kind#stackKind() stack kind}
-     */
-    public static Constant defaultValue(Kind kind) {
-        // Checkstyle: stop
-        switch (kind.stackKind()) {
-            case Int: return INT_0;
-            case Long: return LONG_0;
-            case Float: return FLOAT_0;
-            case Double: return DOUBLE_0;
-            case Object: return NULL_OBJECT;
-        }
-        // Checkstyle: resume
-        throw new IllegalArgumentException("Cannot get default CiConstant for kind " + kind);
-    }
-
-    /**
      * Creates a boxed double constant.
      * @param d the double value to box
      * @return a boxed copy of {@code value}
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java	Sat Jun 09 17:13:21 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java	Sat Jun 09 17:24:23 2012 +0200
@@ -544,7 +544,6 @@
     @Override
     protected void emitCall(Object targetMethod, Value result, List<Value> arguments, Value targetAddress, LIRDebugInfo info, Map<XirMark, Mark> marks) {
         if (isConstant(targetAddress)) {
-            assert asConstant(targetAddress).isDefaultValue() : "destination address should be zero";
             append(new DirectCallOp(targetMethod, result, arguments.toArray(new Value[arguments.size()]), info, marks));
         } else {
             append(new IndirectCallOp(targetMethod, result, arguments.toArray(new Value[arguments.size()]), targetAddress, info, marks));
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/Util.java	Sat Jun 09 17:13:21 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/Util.java	Sat Jun 09 17:24:23 2012 +0200
@@ -329,25 +329,6 @@
         return (short) v;
     }
 
-    /**
-     * Checks that two instructions are equivalent, optionally comparing constants.
-     * @param x the first instruction
-     * @param y the second instruction
-     * @param compareConstants {@code true} if equivalent constants should be considered equivalent
-     * @return {@code true} if the instructions are equivalent; {@code false} otherwise
-     */
-    public static boolean equivalent(FixedWithNextNode x, FixedWithNextNode y, boolean compareConstants) {
-        if (x == y) {
-            return true;
-        }
-        if (compareConstants && x != null && y != null) {
-            if (x.isConstant() && x.asConstant().equivalent(y.asConstant())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
     public static boolean isFixed(Node n) {
         return n instanceof FixedNode;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/IsTypeNode.java	Sat Jun 09 17:13:21 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/IsTypeNode.java	Sat Jun 09 17:24:23 2012 +0200
@@ -66,7 +66,7 @@
             Constant constant = objectClass().asConstant();
             Constant typeHub = type.getEncoding(Representation.ObjectHub);
             assert constant.kind == typeHub.kind;
-            return ConstantNode.forBoolean(constant.equivalent(typeHub), graph());
+            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) {