# HG changeset patch # User Josef Eisl # Date 1437983095 -7200 # Node ID fd8b493efd4829c355c26d73a2eba4f7ee35875d # Parent 8fbf5bd5c4067bcedb3bc596ec413725b36d83e3 Rename IntValueMap to IndexedValueMap. diff -r 8fbf5bd5c406 -r fd8b493efd48 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRFrameState.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRFrameState.java Fri Jul 24 15:38:17 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRFrameState.java Mon Jul 27 09:44:55 2015 +0200 @@ -45,7 +45,7 @@ public final LabelRef exceptionEdge; protected DebugInfo debugInfo; - private IntValueMap liveBasePointers; + private IndexedValueMap liveBasePointers; public LIRFrameState(BytecodeFrame topFrame, VirtualObject[] virtualObjects, LabelRef exceptionEdge) { this.topFrame = topFrame; @@ -181,11 +181,11 @@ debugInfo = new DebugInfo(topFrame, virtualObjects); } - public IntValueMap getLiveBasePointers() { + public IndexedValueMap getLiveBasePointers() { return liveBasePointers; } - public void setLiveBasePointers(IntValueMap liveBasePointers) { + public void setLiveBasePointers(IndexedValueMap liveBasePointers) { this.liveBasePointers = liveBasePointers; } diff -r 8fbf5bd5c406 -r fd8b493efd48 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/MarkBasePointersPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/MarkBasePointersPhase.java Fri Jul 24 15:38:17 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/MarkBasePointersPhase.java Mon Jul 27 09:44:55 2015 +0200 @@ -51,14 +51,14 @@ private final class BasePointersSet extends ValueSet.BasePointersSet> { - private final IntValueMap variables; + private final IndexedValueMap variables; public BasePointersSet() { - variables = new IntValueMap(); + variables = new IndexedValueMap(); } private BasePointersSet(BasePointersSet s) { - variables = new IntValueMap(s.variables); + variables = new IndexedValueMap(s.variables); } @Override @@ -118,7 +118,7 @@ @Override protected void processState(LIRInstruction op, LIRFrameState info, BasePointersSet values) { - info.setLiveBasePointers(new IntValueMap(values.variables)); + info.setLiveBasePointers(new IndexedValueMap(values.variables)); } } } diff -r 8fbf5bd5c406 -r fd8b493efd48 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/RegStackValueSet.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/RegStackValueSet.java Fri Jul 24 15:38:17 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/RegStackValueSet.java Mon Jul 27 09:44:55 2015 +0200 @@ -36,20 +36,20 @@ final class RegStackValueSet extends ValueSet { private final FrameMap frameMap; - private final IntValueMap registers; - private final IntValueMap stack; + private final IndexedValueMap registers; + private final IndexedValueMap stack; private Set extraStack; public RegStackValueSet(FrameMap frameMap) { this.frameMap = frameMap; - registers = new IntValueMap(); - stack = new IntValueMap(); + registers = new IndexedValueMap(); + stack = new IndexedValueMap(); } private RegStackValueSet(FrameMap frameMap, RegStackValueSet s) { this.frameMap = frameMap; - registers = new IntValueMap(s.registers); - stack = new IntValueMap(s.stack); + registers = new IndexedValueMap(s.registers); + stack = new IndexedValueMap(s.stack); if (s.extraStack != null) { extraStack = new HashSet<>(s.extraStack); } diff -r 8fbf5bd5c406 -r fd8b493efd48 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/util/IndexedValueMap.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/util/IndexedValueMap.java Mon Jul 27 09:44:55 2015 +0200 @@ -0,0 +1,163 @@ +/* + * 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 IndexedValueMap { + private Value[] values; + + public IndexedValueMap() { + values = Value.NO_VALUES; + } + + public IndexedValueMap(IndexedValueMap 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 (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(IndexedValueMap 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 IndexedValueMap) { + IndexedValueMap that = (IndexedValueMap) 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 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 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(); + } +} diff -r 8fbf5bd5c406 -r fd8b493efd48 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/util/IntValueMap.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/util/IntValueMap.java Fri Jul 24 15:38:17 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,163 +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.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 (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 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 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(); - } -} diff -r 8fbf5bd5c406 -r fd8b493efd48 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java Fri Jul 24 15:38:17 2015 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java Mon Jul 27 09:44:55 2015 +0200 @@ -114,7 +114,7 @@ /** * Formats given debug info as a multi line string. */ - protected String debugInfoToString(BytecodePosition codePos, ReferenceMap refMap, IntValueMap liveBasePointers, RegisterSaveLayout calleeSaveInfo) { + protected String debugInfoToString(BytecodePosition codePos, ReferenceMap refMap, IndexedValueMap liveBasePointers, RegisterSaveLayout calleeSaveInfo) { StringBuilder sb = new StringBuilder(); if (refMap != null) { sb.append("reference-map: ");