changeset 4182:de7b3e7ae528

Simplify CiValue
author Christian Wimmer <Christian.Wimmer@Oracle.com>
date Mon, 02 Jan 2012 14:38:17 -0800
parents 319860ae697a
children 9e0c1b4cfef5
files graal/com.oracle.max.cri/src/com/sun/cri/ci/CiAddress.java graal/com.oracle.max.cri/src/com/sun/cri/ci/CiConstant.java graal/com.oracle.max.cri/src/com/sun/cri/ci/CiFrame.java graal/com.oracle.max.cri/src/com/sun/cri/ci/CiRegisterValue.java graal/com.oracle.max.cri/src/com/sun/cri/ci/CiStackSlot.java graal/com.oracle.max.cri/src/com/sun/cri/ci/CiValue.java graal/com.oracle.max.cri/src/com/sun/cri/ci/CiVariable.java graal/com.oracle.max.cri/src/com/sun/cri/ci/CiVirtualObject.java
diffstat 8 files changed, 8 insertions(+), 149 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiAddress.java	Mon Jan 02 14:16:08 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiAddress.java	Mon Jan 02 14:38:17 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012, 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
@@ -28,10 +28,6 @@
  * unassigned to target machine registers.
  */
 public final class CiAddress extends CiValue {
-
-    /**
-     *
-     */
     private static final long serialVersionUID = -1003772042519945089L;
 
     /**
@@ -253,15 +249,6 @@
     }
 
     @Override
-    public boolean equalsIgnoringKind(CiValue o) {
-        if (o instanceof CiAddress) {
-            CiAddress addr = (CiAddress) o;
-            return displacement == addr.displacement && base.equalsIgnoringKind(addr.base) && scale == addr.scale && index.equalsIgnoringKind(addr.index);
-        }
-        return false;
-    }
-
-    @Override
     public int hashCode() {
         return (base.hashCode() << 4) | kind.ordinal();
     }
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiConstant.java	Mon Jan 02 14:16:08 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiConstant.java	Mon Jan 02 14:38:17 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, 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
@@ -28,11 +28,8 @@
  * instances that represent frequently used constant values, such as {@link #ZERO}.
  */
 public final class CiConstant extends CiValue {
+    private static final long serialVersionUID = -6355452536852663986L;
 
-    /**
-     *
-     */
-    private static final long serialVersionUID = -6355452536852663986L;
     private static final CiConstant[] INT_CONSTANT_CACHE = new CiConstant[100];
     static {
         for (int i = 0; i < INT_CONSTANT_CACHE.length; ++i) {
@@ -309,11 +306,6 @@
         return o == this || o instanceof CiConstant && valueEqual((CiConstant) o, false);
     }
 
-    @Override
-    public boolean equalsIgnoringKind(CiValue o) {
-        return o == this || o instanceof CiConstant && valueEqual((CiConstant) o, true);
-    }
-
     /**
      * 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
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiFrame.java	Mon Jan 02 14:16:08 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiFrame.java	Mon Jan 02 14:38:17 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, 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
@@ -32,9 +32,6 @@
  * operand stack values and locked objects of the bytecode frame(s).
  */
 public class CiFrame extends CiCodePos implements Serializable {
-    /**
-     * 
-     */
     private static final long serialVersionUID = -345025397165977565L;
 
     /**
@@ -129,73 +126,8 @@
         return (CiFrame) caller;
     }
 
-    /**
-     * Deep equality test.
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
-        if (obj instanceof CiFrame) {
-            CiFrame other = (CiFrame) obj;
-            return equals(other, false, false);
-        }
-        return false;
-    }
-
-    /**
-     * Deep equality test.
-     *
-     * @param ignoreKinds if {@code true}, compares values but {@link CiValue#equalsIgnoringKind(CiValue) ignore} their kinds
-     * @param ignoreNegativeBCIs if {@code true}, negative BCIs are treated as equal
-     */
-    public boolean equals(CiFrame other, boolean ignoreKinds, boolean ignoreNegativeBCIs) {
-        if ((other.bci == bci || (ignoreNegativeBCIs && other.bci < 0 && bci < 0)) &&
-            numLocals == other.numLocals &&
-            numStack == other.numStack &&
-            numLocks == other.numLocks &&
-            values.length == other.values.length) {
-
-            if (ignoreKinds) {
-                for (int i = 0; i < values.length; i++) {
-                    if (!values[i].equalsIgnoringKind(other.values[i])) {
-                        return false;
-                    }
-                }
-            } else {
-                for (int i = 0; i < values.length; i++) {
-                    if (!values[i].equals(other.values[i])) {
-                        return false;
-                    }
-                }
-            }
-            if (caller == null) {
-                return other.caller == null;
-            }
-            if (other.caller == null) {
-                return false;
-            }
-            return caller().equals(other.caller(), ignoreKinds, ignoreNegativeBCIs);
-        }
-        return false;
-    }
-
     @Override
     public String toString() {
         return CiUtil.append(new StringBuilder(100), this).toString();
     }
-
-    /**
-     * Gets a copy of this frame but with an empty stack.
-     */
-    public CiFrame withEmptyStack() {
-        if (numStack == 0) {
-            return this;
-        }
-        CiValue[] ciValues = new CiValue[numLocals + numLocks];
-        System.arraycopy(this.values, 0, ciValues, 0, numLocals);
-        System.arraycopy(this.values, numLocals + numStack, ciValues, numLocals, numLocks);
-        return new CiFrame(caller(), method, bci, rethrowException, ciValues, numLocals, 0, numLocks);
-    }
 }
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiRegisterValue.java	Mon Jan 02 14:16:08 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiRegisterValue.java	Mon Jan 02 14:38:17 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, 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
@@ -49,19 +49,6 @@
     }
 
     @Override
-    public boolean equals(Object o) {
-        return o == this;
-    }
-
-    @Override
-    public boolean equalsIgnoringKind(CiValue other) {
-        if (other instanceof CiRegisterValue) {
-            return ((CiRegisterValue) other).reg == reg;
-        }
-        return false;
-    }
-
-    @Override
     public String toString() {
         return reg.name + kindSuffix();
     }
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiStackSlot.java	Mon Jan 02 14:16:08 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiStackSlot.java	Mon Jan 02 14:38:17 2012 -0800
@@ -29,7 +29,6 @@
  * or an incoming stack-based argument in a method's {@linkplain #inCallerFrame() caller's frame}.
  */
 public final class CiStackSlot extends CiValue {
-
     private static final long serialVersionUID = -7725071921307318433L;
 
     private final int offset;
@@ -119,18 +118,6 @@
     }
 
     @Override
-    public boolean equalsIgnoringKind(CiValue o) {
-        if (o == this) {
-            return true;
-        }
-        if (o instanceof CiStackSlot) {
-            CiStackSlot l = (CiStackSlot) o;
-            return l.offset == offset && l.addFrameSize == addFrameSize;
-        }
-        return false;
-    }
-
-    @Override
     public String toString() {
         String s;
         if (!addFrameSize) {
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiValue.java	Mon Jan 02 14:16:08 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiValue.java	Mon Jan 02 14:38:17 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, 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
@@ -96,11 +96,6 @@
         return this instanceof CiConstant;
     }
 
-    public boolean equalsIgnoringKind(CiValue other) {
-        // This is a suitable default implementation for several subclasses
-        return equals(other);
-    }
-
     @Override
     public abstract String toString();
 
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiVariable.java	Mon Jan 02 14:16:08 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiVariable.java	Mon Jan 02 14:38:17 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012, 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
@@ -28,10 +28,6 @@
  * by a register allocator.
  */
 public final class CiVariable extends CiValue {
-
-    /**
-     *
-     */
     private static final long serialVersionUID = 4507578431686109809L;
 
     /**
@@ -99,18 +95,6 @@
     }
 
     @Override
-    public boolean equalsIgnoringKind(CiValue o) {
-        if (this == o) {
-            return true;
-        }
-        if (o instanceof CiVariable) {
-            CiVariable var = (CiVariable) o;
-            return index == var.index;
-        }
-        return false;
-    }
-
-    @Override
     public int hashCode() {
         return (index << 4) | kind.ordinal();
     }
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiVirtualObject.java	Mon Jan 02 14:16:08 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiVirtualObject.java	Mon Jan 02 14:38:17 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012, 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
@@ -113,11 +113,6 @@
         return false;
     }
 
-    @Override
-    public boolean equalsIgnoringKind(CiValue o) {
-        return equals(o);
-    }
-
     /**
      * This is a helper class used to create virtual objects for a number of different JDK classes.
      */