changeset 13130:103a0003db01

Introduce ComparableWord and PointerBase into the Word type hierarchy
author Christian Wimmer <christian.wimmer@oracle.com>
date Fri, 22 Nov 2013 12:13:47 -0800
parents 3a05ef752a40
children 5d4b75c35f59
files graal/com.oracle.graal.word/src/com/oracle/graal/word/ComparableWord.java graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java graal/com.oracle.graal.word/src/com/oracle/graal/word/PointerBase.java graal/com.oracle.graal.word/src/com/oracle/graal/word/Signed.java graal/com.oracle.graal.word/src/com/oracle/graal/word/Unsigned.java graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java
diffstat 6 files changed, 87 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/ComparableWord.java	Fri Nov 22 12:13:47 2013 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, 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
+ * 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.word;
+
+public interface ComparableWord extends WordBase {
+
+    /**
+     * Compares this word with the specified value.
+     * 
+     * @param val value to which this word is to be compared.
+     * @return {@code this == val}
+     */
+    boolean equal(ComparableWord val);
+
+    /**
+     * Compares this word with the specified value.
+     * 
+     * @param val value to which this word is to be compared.
+     * @return {@code this != val}
+     */
+    boolean notEqual(ComparableWord val);
+}
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java	Fri Nov 22 12:12:38 2013 -0800
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java	Fri Nov 22 12:13:47 2013 -0800
@@ -26,7 +26,7 @@
 import com.oracle.graal.nodes.HeapAccess.BarrierType;
 import com.oracle.graal.nodes.extended.*;
 
-public interface Pointer extends Unsigned {
+public interface Pointer extends Unsigned, PointerBase {
 
     /**
      * Unsafe conversion of this Pointer to a Java language object. No correctness checks or type
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/PointerBase.java	Fri Nov 22 12:13:47 2013 -0800
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2013, 2013, 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.word;
+
+/**
+ * Marker interface for all {@link WordBase word types} that have the semantic of a pointer (but not
+ * necessarily all the memory access methods defined in {@link Pointer}).
+ */
+public interface PointerBase extends ComparableWord {
+}
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Signed.java	Fri Nov 22 12:12:38 2013 -0800
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Signed.java	Fri Nov 22 12:13:47 2013 -0800
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.word;
 
-public interface Signed extends WordBase {
+public interface Signed extends ComparableWord {
 
     /**
      * Returns a Signed whose value is {@code (this + val)}.
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Unsigned.java	Fri Nov 22 12:12:38 2013 -0800
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Unsigned.java	Fri Nov 22 12:13:47 2013 -0800
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.word;
 
-public interface Unsigned extends WordBase {
+public interface Unsigned extends ComparableWord {
 
     /**
      * Returns a Unsigned whose value is {@code (this + val)}.
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java	Fri Nov 22 12:12:38 2013 -0800
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java	Fri Nov 22 12:13:47 2013 -0800
@@ -427,6 +427,12 @@
 
     @Override
     @Operation(opcode = Opcode.COMPARISON, condition = Condition.EQ)
+    public boolean equal(ComparableWord val) {
+        return equal((Word) val);
+    }
+
+    @Override
+    @Operation(opcode = Opcode.COMPARISON, condition = Condition.EQ)
     public boolean equal(Signed val) {
         return equal((Word) val);
     }
@@ -450,6 +456,12 @@
 
     @Override
     @Operation(opcode = Opcode.COMPARISON, condition = Condition.NE)
+    public boolean notEqual(ComparableWord val) {
+        return notEqual((Word) val);
+    }
+
+    @Override
+    @Operation(opcode = Opcode.COMPARISON, condition = Condition.NE)
     public boolean notEqual(Signed val) {
         return notEqual((Word) val);
     }