# HG changeset patch # User Thomas Wuerthinger # Date 1339255463 -7200 # Node ID 25d561cfdcfa01eca966b56881e1adcecec0b46a # Parent e318468952f54ddd9a74f564c3ebea1c4f83c7af Clean up in api classes. Removed CiGenericCallback. Simplified Constant. diff -r e318468952f5 -r 25d561cfdcfa graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CiGenericCallback.java --- 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); -} diff -r e318468952f5 -r 25d561cfdcfa graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java --- 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} diff -r e318468952f5 -r 25d561cfdcfa graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java --- 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 arguments, Value targetAddress, LIRDebugInfo info, Map 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)); diff -r e318468952f5 -r 25d561cfdcfa graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/Util.java --- 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; } diff -r e318468952f5 -r 25d561cfdcfa graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/IsTypeNode.java --- 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) {