# HG changeset patch # User Tom Rodriguez # Date 1425350447 28800 # Node ID f595e97626fd2312c7265ba2ee2bef89bdbf97e1 # Parent c96f8337292e9ad4fc22697f8be18c2c3b6f1fef Use Value instead of JavaValue in BytecodeFrame and VirtualObject diff -r c96f8337292e -r f595e97626fd graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java Tue Mar 03 00:01:36 2015 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java Mon Mar 02 18:40:47 2015 -0800 @@ -66,7 +66,7 @@ * Note that the number of locals and the number of stack slots may be smaller than the maximum * number of locals and stack slots as specified in the compiled method. */ - public final JavaValue[] values; + public final Value[] values; /** * The number of locals in the values array. @@ -144,7 +144,7 @@ * @param numStack the depth of the stack * @param numLocks the number of locked objects */ - public BytecodeFrame(BytecodeFrame caller, ResolvedJavaMethod method, int bci, boolean rethrowException, boolean duringCall, JavaValue[] values, int numLocals, int numStack, int numLocks) { + public BytecodeFrame(BytecodeFrame caller, ResolvedJavaMethod method, int bci, boolean rethrowException, boolean duringCall, Value[] values, int numLocals, int numStack, int numLocks) { super(caller, method, bci); assert values != null; this.rethrowException = rethrowException; @@ -183,7 +183,7 @@ * @param i the local variable index * @return the value that can be used to reconstruct the local's current value */ - public JavaValue getLocalValue(int i) { + public Value getLocalValue(int i) { return values[i]; } @@ -193,7 +193,7 @@ * @param i the stack index * @return the value that can be used to reconstruct the stack slot's current value */ - public JavaValue getStackValue(int i) { + public Value getStackValue(int i) { return values[i + numLocals]; } @@ -203,7 +203,7 @@ * @param i the lock index * @return the value that can be used to reconstruct the lock's current value */ - public JavaValue getLockValue(int i) { + public Value getLockValue(int i) { return values[i + numLocals + numStack]; } diff -r c96f8337292e -r f595e97626fd graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/StackLockValue.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/StackLockValue.java Tue Mar 03 00:01:36 2015 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/StackLockValue.java Mon Mar 02 18:40:47 2015 -0800 @@ -33,22 +33,22 @@ private static final long serialVersionUID = 8241681800464483691L; - private JavaValue owner; + private Value owner; private StackSlotValue slot; private final boolean eliminated; - public StackLockValue(JavaValue owner, StackSlotValue slot, boolean eliminated) { + public StackLockValue(Value object, StackSlotValue slot, boolean eliminated) { super(LIRKind.Illegal); - this.owner = owner; + this.owner = object; this.slot = slot; this.eliminated = eliminated; } - public JavaValue getOwner() { + public Value getOwner() { return owner; } - public void setOwner(JavaValue newOwner) { + public void setOwner(Value newOwner) { this.owner = newOwner; } diff -r c96f8337292e -r f595e97626fd graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java Tue Mar 03 00:01:36 2015 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java Mon Mar 02 18:40:47 2015 -0800 @@ -36,7 +36,7 @@ private static final long serialVersionUID = -2907197776426346021L; private final ResolvedJavaType type; - private JavaValue[] values; + private Value[] values; private final int id; /** @@ -54,18 +54,18 @@ * position in the compiled code. * @return a new {@link VirtualObject} instance. */ - public static VirtualObject get(ResolvedJavaType type, JavaValue[] values, int id) { + public static VirtualObject get(ResolvedJavaType type, Value[] values, int id) { return new VirtualObject(type, values, id); } - private VirtualObject(ResolvedJavaType type, JavaValue[] values, int id) { + private VirtualObject(ResolvedJavaType type, Value[] values, int id) { super(LIRKind.reference(Kind.Object)); this.type = type; this.values = values; this.id = id; } - private static StringBuilder appendValue(StringBuilder buf, JavaValue value, Set visited) { + private static StringBuilder appendValue(StringBuilder buf, Value value, Set visited) { if (value instanceof VirtualObject) { VirtualObject vo = (VirtualObject) value; buf.append("vobject:").append(vo.type.toJavaName(false)).append(':').append(vo.id); @@ -120,7 +120,7 @@ /** * Returns an array containing all the values to be stored into the object when it is recreated. */ - public JavaValue[] getValues() { + public Value[] getValues() { return values; } @@ -132,7 +132,7 @@ return id; } - private static boolean checkValues(ResolvedJavaType type, JavaValue[] values) { + private static boolean checkValues(ResolvedJavaType type, Value[] values) { if (values != null) { if (!type.isArray()) { ResolvedJavaField[] fields = type.getInstanceFields(true); @@ -140,8 +140,8 @@ for (int i = 0; i < values.length; i++) { ResolvedJavaField field = fields[fieldIndex++]; Kind valKind = values[i].getKind().getStackKind(); - if (field.getKind() == Kind.Object && values[i] instanceof Value) { - assert ((Value) values[i]).getLIRKind().isReference(0) : field + ": " + valKind + " != " + field.getKind(); + if (field.getKind() == Kind.Object) { + assert values[i].getLIRKind().isReference(0) : field + ": " + valKind + " != " + field.getKind(); } else { if ((valKind == Kind.Double || valKind == Kind.Long) && field.getKind() == Kind.Int) { assert fields[fieldIndex].getKind() == Kind.Int; @@ -156,9 +156,7 @@ Kind componentKind = type.getComponentType().getKind().getStackKind(); if (componentKind == Kind.Object) { for (int i = 0; i < values.length; i++) { - if (values[i] instanceof Value) { - assert ((Value) values[i]).getLIRKind().isReference(0) : values[i].getKind() + " != " + componentKind; - } + assert values[i].getLIRKind().isReference(0) : values[i].getKind() + " != " + componentKind; } } else { for (int i = 0; i < values.length; i++) { @@ -177,7 +175,7 @@ * @param values an array containing all the values to be stored into the object when it is * recreated. */ - public void setValues(JavaValue[] values) { + public void setValues(Value[] values) { assert checkValues(type, values); this.values = values; } diff -r c96f8337292e -r f595e97626fd graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Tue Mar 03 00:01:36 2015 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Mon Mar 02 18:40:47 2015 -0800 @@ -83,7 +83,7 @@ for (Entry entry : virtualObjectsCopy.entrySet()) { if (entry.getValue().getValues() == null) { VirtualObjectNode vobj = entry.getKey(); - JavaValue[] values = new JavaValue[vobj.entryCount()]; + Value[] values = new Value[vobj.entryCount()]; if (values.length > 0) { changed = true; VirtualObjectState currentField = (VirtualObjectState) objectStates.get(vobj); @@ -98,7 +98,7 @@ } } if (pos != vobj.entryCount()) { - JavaValue[] newValues = new JavaValue[pos]; + Value[] newValues = new Value[pos]; System.arraycopy(values, 0, newValues, 0, pos); values = newValues; } @@ -136,7 +136,7 @@ int numStack = state.stackSize(); int numLocks = state.locksSize(); - JavaValue[] values = new JavaValue[numLocals + numStack + numLocks]; + Value[] values = new Value[numLocals + numStack + numLocks]; computeLocals(state, numLocals, values); computeStack(state, numLocals, numStack, values); computeLocks(state, values); @@ -151,33 +151,33 @@ } } - protected void computeLocals(FrameState state, int numLocals, JavaValue[] values) { + protected void computeLocals(FrameState state, int numLocals, Value[] values) { for (int i = 0; i < numLocals; i++) { values[i] = computeLocalValue(state, i); } } - protected JavaValue computeLocalValue(FrameState state, int i) { + protected Value computeLocalValue(FrameState state, int i) { return toValue(state.localAt(i)); } - protected void computeStack(FrameState state, int numLocals, int numStack, JavaValue[] values) { + protected void computeStack(FrameState state, int numLocals, int numStack, Value[] values) { for (int i = 0; i < numStack; i++) { values[numLocals + i] = computeStackValue(state, i); } } - protected JavaValue computeStackValue(FrameState state, int i) { + protected Value computeStackValue(FrameState state, int i) { return toValue(state.stackAt(i)); } - protected void computeLocks(FrameState state, JavaValue[] values) { + protected void computeLocks(FrameState state, Value[] values) { for (int i = 0; i < state.locksSize(); i++) { values[state.localsSize() + state.stackSize() + i] = computeLockValue(state, i); } } - protected JavaValue computeLockValue(FrameState state, int i) { + protected Value computeLockValue(FrameState state, int i) { return toValue(state.lockAt(i)); } @@ -186,7 +186,7 @@ private static final DebugMetric STATE_VARIABLES = Debug.metric("StateVariables"); private static final DebugMetric STATE_CONSTANTS = Debug.metric("StateConstants"); - protected JavaValue toValue(ValueNode value) { + protected Value toValue(ValueNode value) { try { if (value instanceof VirtualObjectNode) { VirtualObjectNode obj = (VirtualObjectNode) value; @@ -218,7 +218,7 @@ STATE_VARIABLES.increment(); Value operand = nodeOperands.get(value); assert operand != null && (operand instanceof Variable || operand instanceof JavaConstant) : operand + " for " + value; - return (JavaValue) operand; + return operand; } else { // return a dummy value because real value not needed diff -r c96f8337292e -r f595e97626fd graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugInfoBuilder.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugInfoBuilder.java Tue Mar 03 00:01:36 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugInfoBuilder.java Mon Mar 02 18:40:47 2015 -0800 @@ -26,7 +26,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.graph.*; -import com.oracle.graal.lir.*; import com.oracle.graal.nodes.*; /** @@ -46,25 +45,20 @@ } @Override - protected JavaValue computeLockValue(FrameState state, int lockIndex) { + protected Value computeLockValue(FrameState state, int lockIndex) { int lockDepth = lockIndex; if (state.outerFrameState() != null) { lockDepth += state.outerFrameState().nestedLockDepth(); } StackSlotValue slot = lockStack.makeLockSlot(lockDepth); ValueNode lock = state.lockAt(lockIndex); - JavaValue object = toValue(lock); + Value object = toValue(lock); boolean eliminated = object instanceof VirtualObject && state.monitorIdAt(lockIndex) != null; assert state.monitorIdAt(lockIndex) == null || state.monitorIdAt(lockIndex).getLockDepth() == lockDepth; return new StackLockValue(object, slot, eliminated); } @Override - protected LIRFrameState newLIRFrameState(LabelRef exceptionEdge, BytecodeFrame frame, VirtualObject[] virtualObjectsArray) { - return new HotSpotLIRFrameState(frame, virtualObjectsArray, exceptionEdge); - } - - @Override protected BytecodeFrame computeFrameForState(FrameState state) { assert state.bci >= 0 || state.bci == BytecodeFrame.BEFORE_BCI : state.bci; return super.computeFrameForState(state); diff -r c96f8337292e -r f595e97626fd graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLIRFrameState.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLIRFrameState.java Tue Mar 03 00:01:36 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2013, 2014, 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.hotspot; - -import static com.oracle.graal.api.code.ValueUtil.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.LIRInstruction.OperandMode; - -/** - * Extends {@link LIRFrameState} to handle {@link StackLockValue}s correctly. - */ -class HotSpotLIRFrameState extends LIRFrameState { - - public HotSpotLIRFrameState(BytecodeFrame topFrame, VirtualObject[] virtualObjects, LabelRef exceptionEdge) { - super(topFrame, virtualObjects, exceptionEdge); - } - - @Override - protected Value processValue(LIRInstruction inst, InstructionValueProcedure proc, Value value) { - if (value instanceof StackLockValue) { - StackLockValue monitor = (StackLockValue) value; - if (monitor.getOwner() instanceof Value) { - Value owner = (Value) monitor.getOwner(); - if (processed(owner)) { - monitor.setOwner((JavaValue) proc.doValue(inst, owner, OperandMode.ALIVE, STATE_FLAGS)); - } - } - Value slot = monitor.getSlot(); - if (isVirtualStackSlot(slot) && processed(slot)) { - monitor.setSlot(asStackSlotValue(proc.doValue(inst, slot, OperandMode.ALIVE, STATE_FLAGS))); - } - return value; - } else { - return super.processValue(inst, proc, value); - } - } -} diff -r c96f8337292e -r f595e97626fd 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 Tue Mar 03 00:01:36 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRFrameState.java Mon Mar 02 18:40:47 2015 -0800 @@ -80,34 +80,46 @@ */ protected static final EnumSet STATE_FLAGS = EnumSet.of(OperandFlag.REG, OperandFlag.STACK); - protected void processValues(LIRInstruction inst, JavaValue[] values, InstructionValueProcedure proc) { + protected void processValues(LIRInstruction inst, Value[] values, InstructionValueProcedure proc) { for (int i = 0; i < values.length; i++) { - if (values[i] instanceof Value) { - Value value = (Value) values[i]; - values[i] = (JavaValue) processValue(inst, proc, value); - } + Value value = values[i]; + values[i] = processValue(inst, proc, value); } } protected Value processValue(LIRInstruction inst, InstructionValueProcedure proc, Value value) { - if (processed(value)) { - return proc.doValue(inst, value, OperandMode.ALIVE, STATE_FLAGS); + if (value instanceof StackLockValue) { + StackLockValue monitor = (StackLockValue) value; + Value owner = monitor.getOwner(); + if (owner instanceof AllocatableValue) { + monitor.setOwner(proc.doValue(inst, owner, OperandMode.ALIVE, STATE_FLAGS)); + } + Value slot = monitor.getSlot(); + if (isVirtualStackSlot(slot)) { + monitor.setSlot(asStackSlotValue(proc.doValue(inst, slot, OperandMode.ALIVE, STATE_FLAGS))); + } + } else { + if (!isIllegal(value) && value instanceof AllocatableValue) { + return proc.doValue(inst, value, OperandMode.ALIVE, STATE_FLAGS); + } else { + assert unprocessed(value); + } } return value; } - protected boolean processed(Value value) { + private boolean unprocessed(Value value) { if (isIllegal(value)) { // Ignore dead local variables. - return false; + return true; } else if (isConstant(value)) { // Ignore constants, the register allocator does not need to see them. - return false; + return true; } else if (isVirtualObject(value)) { assert Arrays.asList(virtualObjects).contains(value); - return false; + return true; } else { - return true; + return false; } } diff -r c96f8337292e -r f595e97626fd 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 Tue Mar 03 00:01:36 2015 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java Mon Mar 02 18:40:47 2015 -0800 @@ -182,7 +182,7 @@ return sb.toString(); } - protected String valueToString(JavaValue value, List virtualObjects) { + protected String valueToString(Value value, List virtualObjects) { if (value == null) { return "-"; } diff -r c96f8337292e -r f595e97626fd src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Tue Mar 03 00:01:36 2015 +0100 +++ b/src/share/vm/graal/graalJavaAccess.hpp Mon Mar 02 18:40:47 2015 -0800 @@ -169,7 +169,7 @@ typeArrayOop_field(BitSet, words, "[J") \ end_class \ start_class(BytecodeFrame) \ - objArrayOop_field(BytecodeFrame, values, "[Lcom/oracle/graal/api/meta/JavaValue;") \ + objArrayOop_field(BytecodeFrame, values, "[Lcom/oracle/graal/api/meta/Value;") \ int_field(BytecodeFrame, numLocals) \ int_field(BytecodeFrame, numStack) \ int_field(BytecodeFrame, numLocks) \ @@ -241,10 +241,10 @@ start_class(VirtualObject) \ int_field(VirtualObject, id) \ oop_field(VirtualObject, type, "Lcom/oracle/graal/api/meta/ResolvedJavaType;") \ - objArrayOop_field(VirtualObject, values, "[Lcom/oracle/graal/api/meta/JavaValue;") \ + objArrayOop_field(VirtualObject, values, "[Lcom/oracle/graal/api/meta/Value;") \ end_class \ - start_class(StackLockValue) \ - oop_field(StackLockValue, owner, "Lcom/oracle/graal/api/meta/JavaValue;") \ + start_class(StackLockValue) \ + oop_field(StackLockValue, owner, "Lcom/oracle/graal/api/meta/Value;") \ oop_field(StackLockValue, slot, "Lcom/oracle/graal/api/code/StackSlotValue;") \ boolean_field(StackLockValue, eliminated) \ end_class \