changeset 22346:426a7a36de53

Move IntValueMap/ValueSet to c.o.g.lir/util.
author Josef Eisl <josef.eisl@jku.at>
date Fri, 24 Jul 2015 12:14:50 +0200
parents be74f2362eb6
children 8c7850564478
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRFrameState.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/IntValueMap.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/LocationMarker.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/MarkBasePointersPhase.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/RegStackValueSet.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/ValueSet.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/util/IntValueMap.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/util/ValueSet.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java
diffstat 9 files changed, 209 insertions(+), 204 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRFrameState.java	Fri Jul 24 10:55:17 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRFrameState.java	Fri Jul 24 12:14:50 2015 +0200
@@ -31,8 +31,8 @@
 
 import com.oracle.graal.lir.LIRInstruction.OperandFlag;
 import com.oracle.graal.lir.LIRInstruction.OperandMode;
-import com.oracle.graal.lir.dfa.*;
 import com.oracle.graal.lir.framemap.*;
+import com.oracle.graal.lir.util.*;
 
 /**
  * This class represents garbage collection and deoptimization information attached to a LIR
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/IntValueMap.java	Fri Jul 24 10:55:17 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, 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.lir.dfa;
-
-import java.util.*;
-
-import jdk.internal.jvmci.meta.*;
-
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.LIRInstruction.OperandFlag;
-import com.oracle.graal.lir.LIRInstruction.OperandMode;
-
-public final class IntValueMap {
-    private Value[] values;
-
-    IntValueMap() {
-        values = Value.NO_VALUES;
-    }
-
-    IntValueMap(IntValueMap other) {
-        int limit = other.values.length;
-        while (limit > 0) {
-            if (other.values[limit - 1] == null) {
-                limit--;
-                continue;
-            }
-            break;
-        }
-        values = new Value[limit];
-        System.arraycopy(other.values, 0, values, 0, values.length);
-    }
-
-    public Value get(int index) {
-        return values[index];
-    }
-
-    void put(int index, Value value) {
-        if (value != null && value.getLIRKind().isValue()) {
-            return;
-        }
-        if (values.length <= index) {
-            if (value == null) {
-                return;
-            }
-            Value[] newValues = new Value[index + 1];
-            System.arraycopy(values, 0, newValues, 0, values.length);
-            values = newValues;
-            values[index] = value;
-        } else {
-            values[index] = value;
-        }
-    }
-
-    public void putAll(IntValueMap stack) {
-        Value[] otherValues = stack.values;
-        int limit = otherValues.length;
-        if (limit > values.length) {
-            while (limit > 0) {
-                if (otherValues[limit - 1] == null) {
-                    limit--;
-                    continue;
-                }
-                break;
-            }
-            if (limit > values.length) {
-                Value[] newValues = new Value[limit];
-                System.arraycopy(values, 0, newValues, 0, values.length);
-                values = newValues;
-            }
-        }
-        for (int i = 0; i < limit; i++) {
-            Value value = otherValues[i];
-            if (value != null) {
-                values[i] = value;
-            }
-        }
-    }
-
-    @Override
-    public boolean equals(Object other) {
-        if (other instanceof IntValueMap) {
-            IntValueMap that = (IntValueMap) other;
-            int limit = Math.min(values.length, that.values.length);
-            for (int i = 0; i < limit; i++) {
-                if (!Objects.equals(values[i], that.values[i])) {
-                    return false;
-                }
-            }
-            for (int i = limit; i < values.length; i++) {
-                if (values[i] != null) {
-                    return false;
-                }
-            }
-            for (int i = limit; i < that.values.length; i++) {
-                if (that.values[i] != null) {
-                    return false;
-                }
-            }
-            return true;
-        }
-        return false;
-    }
-
-    public void forEach(LIRInstruction inst, OperandMode mode, EnumSet<OperandFlag> flags, InstructionValueProcedure proc) {
-        for (int i = 0; i < values.length; i++) {
-            if (values[i] != null) {
-                values[i] = proc.doValue(inst, values[i], mode, flags);
-            }
-        }
-    }
-
-    public void forEach(LIRInstruction inst, OperandMode mode, EnumSet<OperandFlag> flags, InstructionValueConsumer consumer) {
-        for (Value v : values) {
-            if (v != null) {
-                consumer.visitValue(inst, v, mode, flags);
-            }
-        }
-    }
-
-    @Override
-    public int hashCode() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder("[");
-        boolean comma = false;
-
-        for (int i = 0; i < values.length; i++) {
-            if (values[i] != null) {
-                if (comma) {
-                    sb.append(", ");
-                } else {
-                    comma = true;
-                }
-
-                sb.append(i);
-                sb.append(": ");
-                sb.append(values[i]);
-            }
-        }
-        sb.append(']');
-        return sb.toString();
-    }
-}
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/LocationMarker.java	Fri Jul 24 10:55:17 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/LocationMarker.java	Fri Jul 24 12:14:50 2015 +0200
@@ -27,7 +27,9 @@
 import java.util.*;
 
 import jdk.internal.jvmci.code.*;
+
 import com.oracle.graal.debug.*;
+
 import jdk.internal.jvmci.meta.*;
 
 import com.oracle.graal.compiler.common.cfg.*;
@@ -35,6 +37,7 @@
 import com.oracle.graal.lir.LIRInstruction.OperandFlag;
 import com.oracle.graal.lir.LIRInstruction.OperandMode;
 import com.oracle.graal.lir.framemap.*;
+import com.oracle.graal.lir.util.*;
 
 public abstract class LocationMarker<T extends AbstractBlockBase<T>, S extends ValueSet<S>> {
 
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/MarkBasePointersPhase.java	Fri Jul 24 10:55:17 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/MarkBasePointersPhase.java	Fri Jul 24 12:14:50 2015 +0200
@@ -34,6 +34,7 @@
 import com.oracle.graal.lir.gen.*;
 import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory;
 import com.oracle.graal.lir.phases.*;
+import com.oracle.graal.lir.util.*;
 
 /**
  * Record all derived reference base pointers in a frame state.
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/RegStackValueSet.java	Fri Jul 24 10:55:17 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/RegStackValueSet.java	Fri Jul 24 12:14:50 2015 +0200
@@ -31,6 +31,7 @@
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.LIRInstruction.*;
 import com.oracle.graal.lir.framemap.*;
+import com.oracle.graal.lir.util.*;
 
 final class RegStackValueSet extends ValueSet<RegStackValueSet> {
 
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/ValueSet.java	Fri Jul 24 10:55:17 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, 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.lir.dfa;
-
-import jdk.internal.jvmci.meta.*;
-
-abstract class ValueSet<S extends ValueSet<S>> {
-
-    public abstract void put(Value v);
-
-    public abstract void remove(Value v);
-
-    public abstract void putAll(S s);
-
-    public abstract S copy();
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/util/IntValueMap.java	Fri Jul 24 12:14:50 2015 +0200
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2014, 2015, 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.lir.util;
+
+import java.util.*;
+
+import jdk.internal.jvmci.meta.*;
+
+import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.LIRInstruction.OperandFlag;
+import com.oracle.graal.lir.LIRInstruction.OperandMode;
+
+public final class IntValueMap {
+    private Value[] values;
+
+    public IntValueMap() {
+        values = Value.NO_VALUES;
+    }
+
+    public IntValueMap(IntValueMap other) {
+        int limit = other.values.length;
+        while (limit > 0) {
+            if (other.values[limit - 1] == null) {
+                limit--;
+                continue;
+            }
+            break;
+        }
+        values = new Value[limit];
+        System.arraycopy(other.values, 0, values, 0, values.length);
+    }
+
+    public Value get(int index) {
+        return values[index];
+    }
+
+    public void put(int index, Value value) {
+        if (value != null && value.getLIRKind().isValue()) {
+            return;
+        }
+        if (values.length <= index) {
+            if (value == null) {
+                return;
+            }
+            Value[] newValues = new Value[index + 1];
+            System.arraycopy(values, 0, newValues, 0, values.length);
+            values = newValues;
+            values[index] = value;
+        } else {
+            values[index] = value;
+        }
+    }
+
+    public void putAll(IntValueMap stack) {
+        Value[] otherValues = stack.values;
+        int limit = otherValues.length;
+        if (limit > values.length) {
+            while (limit > 0) {
+                if (otherValues[limit - 1] == null) {
+                    limit--;
+                    continue;
+                }
+                break;
+            }
+            if (limit > values.length) {
+                Value[] newValues = new Value[limit];
+                System.arraycopy(values, 0, newValues, 0, values.length);
+                values = newValues;
+            }
+        }
+        for (int i = 0; i < limit; i++) {
+            Value value = otherValues[i];
+            if (value != null) {
+                values[i] = value;
+            }
+        }
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (other instanceof IntValueMap) {
+            IntValueMap that = (IntValueMap) other;
+            int limit = Math.min(values.length, that.values.length);
+            for (int i = 0; i < limit; i++) {
+                if (!Objects.equals(values[i], that.values[i])) {
+                    return false;
+                }
+            }
+            for (int i = limit; i < values.length; i++) {
+                if (values[i] != null) {
+                    return false;
+                }
+            }
+            for (int i = limit; i < that.values.length; i++) {
+                if (that.values[i] != null) {
+                    return false;
+                }
+            }
+            return true;
+        }
+        return false;
+    }
+
+    public void forEach(LIRInstruction inst, OperandMode mode, EnumSet<OperandFlag> flags, InstructionValueProcedure proc) {
+        for (int i = 0; i < values.length; i++) {
+            if (values[i] != null) {
+                values[i] = proc.doValue(inst, values[i], mode, flags);
+            }
+        }
+    }
+
+    public void forEach(LIRInstruction inst, OperandMode mode, EnumSet<OperandFlag> flags, InstructionValueConsumer consumer) {
+        for (Value v : values) {
+            if (v != null) {
+                consumer.visitValue(inst, v, mode, flags);
+            }
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder("[");
+        boolean comma = false;
+
+        for (int i = 0; i < values.length; i++) {
+            if (values[i] != null) {
+                if (comma) {
+                    sb.append(", ");
+                } else {
+                    comma = true;
+                }
+
+                sb.append(i);
+                sb.append(": ");
+                sb.append(values[i]);
+            }
+        }
+        sb.append(']');
+        return sb.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/util/ValueSet.java	Fri Jul 24 12:14:50 2015 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2014, 2015, 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.lir.util;
+
+import jdk.internal.jvmci.meta.*;
+
+public abstract class ValueSet<S extends ValueSet<S>> {
+
+    public abstract void put(Value v);
+
+    public abstract void remove(Value v);
+
+    public abstract void putAll(S s);
+
+    public abstract S copy();
+}
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java	Fri Jul 24 10:55:17 2015 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java	Fri Jul 24 12:14:50 2015 +0200
@@ -29,7 +29,7 @@
 import jdk.internal.jvmci.debug.*;
 import jdk.internal.jvmci.meta.*;
 
-import com.oracle.graal.lir.dfa.*;
+import com.oracle.graal.lir.util.*;
 
 /**
  * Utility for printing compilation related data structures at various compilation phases. The