# HG changeset patch # User Josef Eisl # Date 1437727966 -7200 # Node ID 16e76320d7afbfe4037aa80d7a842a771e8dd4d4 # Parent 85278a174428f406c9885dd0c9ea5a22f821dfab Rename ValueSet to IntValueMap. diff -r 85278a174428 -r 16e76320d7af 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 10:50:59 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRFrameState.java Fri Jul 24 10:52:46 2015 +0200 @@ -45,7 +45,7 @@ public final LabelRef exceptionEdge; protected DebugInfo debugInfo; - private ValueSet liveBasePointers; + private IntValueMap liveBasePointers; public LIRFrameState(BytecodeFrame topFrame, VirtualObject[] virtualObjects, LabelRef exceptionEdge) { this.topFrame = topFrame; @@ -181,11 +181,11 @@ debugInfo = new DebugInfo(topFrame, virtualObjects); } - public ValueSet getLiveBasePointers() { + public IntValueMap getLiveBasePointers() { return liveBasePointers; } - public void setLiveBasePointers(ValueSet liveBasePointers) { + public void setLiveBasePointers(IntValueMap liveBasePointers) { this.liveBasePointers = liveBasePointers; } diff -r 85278a174428 -r 16e76320d7af graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/IntValueMap.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/IntValueMap.java Fri Jul 24 10:52:46 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.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 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 85278a174428 -r 16e76320d7af 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 10:50:59 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/MarkBasePointersPhase.java Fri Jul 24 10:52:46 2015 +0200 @@ -50,14 +50,14 @@ private final class BasePointersSet extends LiveValueSet.BasePointersSet> { - private final ValueSet variables; + private final IntValueMap variables; public BasePointersSet() { - variables = new ValueSet(); + variables = new IntValueMap(); } private BasePointersSet(BasePointersSet s) { - variables = new ValueSet(s.variables); + variables = new IntValueMap(s.variables); } @Override @@ -115,7 +115,7 @@ @Override protected void processState(LIRInstruction op, LIRFrameState info, BasePointersSet values) { - info.setLiveBasePointers(new ValueSet(values.variables)); + info.setLiveBasePointers(new IntValueMap(values.variables)); } } } diff -r 85278a174428 -r 16e76320d7af 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 10:50:59 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/RegStackValueSet.java Fri Jul 24 10:52:46 2015 +0200 @@ -35,20 +35,20 @@ final class RegStackValueSet extends LiveValueSet { private final FrameMap frameMap; - private final ValueSet registers; - private final ValueSet stack; + private final IntValueMap registers; + private final IntValueMap stack; private Set extraStack; public RegStackValueSet(FrameMap frameMap) { this.frameMap = frameMap; - registers = new ValueSet(); - stack = new ValueSet(); + registers = new IntValueMap(); + stack = new IntValueMap(); } private RegStackValueSet(FrameMap frameMap, RegStackValueSet s) { this.frameMap = frameMap; - registers = new ValueSet(s.registers); - stack = new ValueSet(s.stack); + registers = new IntValueMap(s.registers); + stack = new IntValueMap(s.stack); if (s.extraStack != null) { extraStack = new HashSet<>(s.extraStack); } diff -r 85278a174428 -r 16e76320d7af graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/ValueSet.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/dfa/ValueSet.java Fri Jul 24 10:50:59 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 ValueSet { - private Value[] values; - - ValueSet() { - values = Value.NO_VALUES; - } - - ValueSet(ValueSet 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(ValueSet 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 ValueSet) { - ValueSet that = (ValueSet) 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 85278a174428 -r 16e76320d7af 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 10:50:59 2015 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java Fri Jul 24 10:52:46 2015 +0200 @@ -114,7 +114,7 @@ /** * Formats given debug info as a multi line string. */ - protected String debugInfoToString(BytecodePosition codePos, ReferenceMap refMap, ValueSet liveBasePointers, RegisterSaveLayout calleeSaveInfo) { + protected String debugInfoToString(BytecodePosition codePos, ReferenceMap refMap, IntValueMap liveBasePointers, RegisterSaveLayout calleeSaveInfo) { StringBuilder sb = new StringBuilder(); if (refMap != null) { sb.append("reference-map: ");