# HG changeset patch # User Tom Rodriguez # Date 1424919720 28800 # Node ID b6beb2161e7a373f7d9b6c7f8e8988ef54fb5890 # Parent 81a4eeea02643ecb55a50abeb3c73272bf7a05e4 Move stack monitor value into api.code diff -r 81a4eeea0264 -r b6beb2161e7a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/StackLockValue.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/StackLockValue.java Wed Feb 25 19:02:00 2015 -0800 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2011, 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.api.code; + +import static com.oracle.graal.api.code.ValueUtil.*; + +import com.oracle.graal.api.meta.*; + +/** + * Represents lock information in the debug information. + */ +public final class StackLockValue extends AbstractValue implements JavaValue { + + private static final long serialVersionUID = 8241681800464483691L; + + private JavaValue owner; + private StackSlotValue slot; + private final boolean eliminated; + + public StackLockValue(JavaValue owner, StackSlotValue slot, boolean eliminated) { + super(LIRKind.Illegal); + this.owner = owner; + this.slot = slot; + this.eliminated = eliminated; + } + + public JavaValue getOwner() { + return owner; + } + + public void setOwner(JavaValue newOwner) { + this.owner = newOwner; + } + + public Value getSlot() { + return slot; + } + + public boolean isEliminated() { + return eliminated; + } + + @Override + public String toString() { + return "monitor[" + owner + (slot != null ? ", " + slot : "") + (eliminated ? ", eliminated" : "") + "]"; + } + + @Override + public int hashCode() { + final int prime = 43; + int result = super.hashCode(); + result = prime * result + (eliminated ? 1231 : 1237); + result = prime * result + owner.hashCode(); + result = prime * result + slot.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof StackLockValue) { + StackLockValue other = (StackLockValue) obj; + return super.equals(obj) && eliminated == other.eliminated && owner.equals(other.owner) && slot.equals(other.slot); + } + return false; + } + + public void setSlot(StackSlotValue stackSlot) { + assert slot == null || (isVirtualStackSlot(slot) && (slot.equals(stackSlot) || isStackSlot(stackSlot))) : String.format("Can not set slot for %s to %s", this, stackSlot); + slot = stackSlot; + } +} diff -r 81a4eeea0264 -r b6beb2161e7a graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotMonitorValueTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotMonitorValueTest.java Wed Feb 25 19:00:00 2015 -0800 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotMonitorValueTest.java Wed Feb 25 19:02:00 2015 -0800 @@ -35,7 +35,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.test.*; -import com.oracle.graal.hotspot.meta.*; public class HotSpotMonitorValueTest extends GraalCompilerTest { @@ -53,14 +52,14 @@ assertNull(caller.caller()); assertDeepEquals(2, frame.numLocks); assertDeepEquals(2, caller.numLocks); - HotSpotMonitorValue lock1 = (HotSpotMonitorValue) frame.getLockValue(0); - HotSpotMonitorValue lock2 = (HotSpotMonitorValue) frame.getLockValue(1); - HotSpotMonitorValue lock3 = (HotSpotMonitorValue) caller.getLockValue(0); - HotSpotMonitorValue lock4 = (HotSpotMonitorValue) caller.getLockValue(1); + StackLockValue lock1 = (StackLockValue) frame.getLockValue(0); + StackLockValue lock2 = (StackLockValue) frame.getLockValue(1); + StackLockValue lock3 = (StackLockValue) caller.getLockValue(0); + StackLockValue lock4 = (StackLockValue) caller.getLockValue(1); - List locks = Arrays.asList(lock1, lock2, lock3, lock4); - for (HotSpotMonitorValue lock : locks) { - for (HotSpotMonitorValue other : locks) { + List locks = Arrays.asList(lock1, lock2, lock3, lock4); + for (StackLockValue lock : locks) { + for (StackLockValue other : locks) { if (other != lock) { // Every lock must have a different stack slot assertThat(lock.getSlot(), not(other.getSlot())); diff -r 81a4eeea0264 -r b6beb2161e7a 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 Wed Feb 25 19:00:00 2015 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugInfoBuilder.java Wed Feb 25 19:02:00 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.hotspot.meta.*; import com.oracle.graal.lir.*; import com.oracle.graal.nodes.*; @@ -57,7 +56,7 @@ JavaValue object = toValue(lock); boolean eliminated = object instanceof VirtualObject && state.monitorIdAt(lockIndex) != null; assert state.monitorIdAt(lockIndex) == null || state.monitorIdAt(lockIndex).getLockDepth() == lockDepth; - return new HotSpotMonitorValue(object, slot, eliminated); + return new StackLockValue(object, slot, eliminated); } @Override diff -r 81a4eeea0264 -r b6beb2161e7a 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 Wed Feb 25 19:00:00 2015 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLIRFrameState.java Wed Feb 25 19:02:00 2015 -0800 @@ -26,12 +26,11 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.LIRInstruction.OperandMode; /** - * Extends {@link LIRFrameState} to handle {@link HotSpotMonitorValue}s correctly. + * Extends {@link LIRFrameState} to handle {@link StackLockValue}s correctly. */ class HotSpotLIRFrameState extends LIRFrameState { @@ -41,8 +40,8 @@ @Override protected Value processValue(LIRInstruction inst, InstructionValueProcedure proc, Value value) { - if (value instanceof HotSpotMonitorValue) { - HotSpotMonitorValue monitor = (HotSpotMonitorValue) value; + if (value instanceof StackLockValue) { + StackLockValue monitor = (StackLockValue) value; if (monitor.getOwner() instanceof Value) { Value owner = (Value) monitor.getOwner(); if (processed(owner)) { diff -r 81a4eeea0264 -r b6beb2161e7a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMonitorValue.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMonitorValue.java Wed Feb 25 19:00:00 2015 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2011, 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.meta; - -import static com.oracle.graal.api.code.ValueUtil.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; - -/** - * Represents lock information in the debug information. - */ -public final class HotSpotMonitorValue extends AbstractValue implements JavaValue { - - private static final long serialVersionUID = 8241681800464483691L; - - private JavaValue owner; - private StackSlotValue slot; - private final boolean eliminated; - - public HotSpotMonitorValue(JavaValue owner, StackSlotValue slot, boolean eliminated) { - super(LIRKind.Illegal); - this.owner = owner; - this.slot = slot; - this.eliminated = eliminated; - } - - public JavaValue getOwner() { - return owner; - } - - public void setOwner(JavaValue newOwner) { - this.owner = newOwner; - } - - public Value getSlot() { - return slot; - } - - public boolean isEliminated() { - return eliminated; - } - - @Override - public String toString() { - return "monitor[" + owner + (slot != null ? ", " + slot : "") + (eliminated ? ", eliminated" : "") + "]"; - } - - @Override - public int hashCode() { - final int prime = 43; - int result = super.hashCode(); - result = prime * result + (eliminated ? 1231 : 1237); - result = prime * result + owner.hashCode(); - result = prime * result + slot.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof HotSpotMonitorValue) { - HotSpotMonitorValue other = (HotSpotMonitorValue) obj; - return super.equals(obj) && eliminated == other.eliminated && owner.equals(other.owner) && slot.equals(other.slot); - } - return false; - } - - public void setSlot(StackSlotValue stackSlot) { - assert slot == null || (isVirtualStackSlot(slot) && (slot.equals(stackSlot) || isStackSlot(stackSlot))) : String.format("Can not set slot for %s to %s", this, stackSlot); - slot = stackSlot; - } -} diff -r 81a4eeea0264 -r b6beb2161e7a src/share/vm/classfile/systemDictionary.hpp --- a/src/share/vm/classfile/systemDictionary.hpp Wed Feb 25 19:00:00 2015 -0800 +++ b/src/share/vm/classfile/systemDictionary.hpp Wed Feb 25 19:02:00 2015 -0800 @@ -198,7 +198,6 @@ GRAAL_ONLY(do_klass(HotSpotNmethod_klass, com_oracle_graal_hotspot_meta_HotSpotNmethod, Graal)) \ GRAAL_ONLY(do_klass(HotSpotResolvedJavaMethodImpl_klass, com_oracle_graal_hotspot_meta_HotSpotResolvedJavaMethodImpl, Graal)) \ GRAAL_ONLY(do_klass(HotSpotResolvedObjectTypeImpl_klass, com_oracle_graal_hotspot_meta_HotSpotResolvedObjectTypeImpl, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotMonitorValue_klass, com_oracle_graal_hotspot_meta_HotSpotMonitorValue, Graal)) \ GRAAL_ONLY(do_klass(HotSpotCompressedNullConstant_klass, com_oracle_graal_hotspot_meta_HotSpotCompressedNullConstant, Graal)) \ GRAAL_ONLY(do_klass(HotSpotObjectConstantImpl_klass, com_oracle_graal_hotspot_meta_HotSpotObjectConstantImpl, Graal)) \ GRAAL_ONLY(do_klass(HotSpotMetaspaceConstantImpl_klass, com_oracle_graal_hotspot_meta_HotSpotMetaspaceConstantImpl, Graal)) \ @@ -227,6 +226,7 @@ GRAAL_ONLY(do_klass(RegisterValue_klass, com_oracle_graal_api_code_RegisterValue, Graal)) \ GRAAL_ONLY(do_klass(RegisterCategory_klass, com_oracle_graal_api_code_Register_RegisterCategory, Graal)) \ GRAAL_ONLY(do_klass(StackSlot_klass, com_oracle_graal_api_code_StackSlot, Graal)) \ + GRAAL_ONLY(do_klass(StackLockValue_klass, com_oracle_graal_api_code_StackLockValue, Graal)) \ GRAAL_ONLY(do_klass(VirtualObject_klass, com_oracle_graal_api_code_VirtualObject, Graal)) \ GRAAL_ONLY(do_klass(SpeculationLog_klass, com_oracle_graal_api_code_SpeculationLog, Graal)) \ GRAAL_ONLY(do_klass(JavaConstant_klass, com_oracle_graal_api_meta_JavaConstant, Graal)) \ diff -r 81a4eeea0264 -r b6beb2161e7a src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Wed Feb 25 19:00:00 2015 -0800 +++ b/src/share/vm/classfile/vmSymbols.hpp Wed Feb 25 19:02:00 2015 -0800 @@ -305,7 +305,6 @@ GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotNmethod, "com/oracle/graal/hotspot/meta/HotSpotNmethod")) \ GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotResolvedJavaMethodImpl, "com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethodImpl")) \ GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotResolvedObjectTypeImpl, "com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotMonitorValue, "com/oracle/graal/hotspot/meta/HotSpotMonitorValue")) \ GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotCompressedNullConstant, "com/oracle/graal/hotspot/meta/HotSpotCompressedNullConstant")) \ GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotObjectConstantImpl, "com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl")) \ GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotMetaspaceConstantImpl,"com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstantImpl")) \ @@ -343,6 +342,7 @@ GRAAL_ONLY(template(com_oracle_graal_api_code_RegisterValue, "com/oracle/graal/api/code/RegisterValue")) \ GRAAL_ONLY(template(com_oracle_graal_api_code_Register_RegisterCategory, "com/oracle/graal/api/code/Register$RegisterCategory")) \ GRAAL_ONLY(template(com_oracle_graal_api_code_StackSlot, "com/oracle/graal/api/code/StackSlot")) \ + GRAAL_ONLY(template(com_oracle_graal_api_code_StackLockValue, "com/oracle/graal/api/code/StackLockValue")) \ GRAAL_ONLY(template(com_oracle_graal_api_code_VirtualObject, "com/oracle/graal/api/code/VirtualObject")) \ GRAAL_ONLY(template(com_oracle_graal_api_code_RegisterSaveLayout, "com/oracle/graal/api/code/RegisterSaveLayout")) \ GRAAL_ONLY(template(com_oracle_graal_api_code_InvalidInstalledCodeException, "com/oracle/graal/api/code/InvalidInstalledCodeException")) \ diff -r 81a4eeea0264 -r b6beb2161e7a src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Wed Feb 25 19:00:00 2015 -0800 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Wed Feb 25 19:02:00 2015 -0800 @@ -365,19 +365,19 @@ } MonitorValue* CodeInstaller::get_monitor_value(oop value, int total_frame_size, GrowableArray* objects, OopRecorder* oop_recorder) { - guarantee(value->is_a(HotSpotMonitorValue::klass()), "Monitors must be of type MonitorValue"); + guarantee(value->is_a(StackLockValue::klass()), "Monitors must be of type MonitorValue"); ScopeValue* second = NULL; - ScopeValue* owner_value = get_scope_value(HotSpotMonitorValue::owner(value), total_frame_size, objects, second, oop_recorder); + ScopeValue* owner_value = get_scope_value(StackLockValue::owner(value), total_frame_size, objects, second, oop_recorder); assert(second == NULL, "monitor cannot occupy two stack slots"); - ScopeValue* lock_data_value = get_scope_value(HotSpotMonitorValue::slot(value), total_frame_size, objects, second, oop_recorder); + ScopeValue* lock_data_value = get_scope_value(StackLockValue::slot(value), total_frame_size, objects, second, oop_recorder); assert(second == lock_data_value, "monitor is LONG value that occupies two stack slots"); assert(lock_data_value->is_location(), "invalid monitor location"); Location lock_data_loc = ((LocationValue*)lock_data_value)->location(); bool eliminated = false; - if (HotSpotMonitorValue::eliminated(value)) { + if (StackLockValue::eliminated(value)) { eliminated = true; } diff -r 81a4eeea0264 -r b6beb2161e7a src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Wed Feb 25 19:00:00 2015 -0800 +++ b/src/share/vm/graal/graalJavaAccess.hpp Wed Feb 25 19:02:00 2015 -0800 @@ -243,10 +243,10 @@ oop_field(VirtualObject, type, "Lcom/oracle/graal/api/meta/ResolvedJavaType;") \ objArrayOop_field(VirtualObject, values, "[Lcom/oracle/graal/api/meta/JavaValue;") \ end_class \ - start_class(HotSpotMonitorValue) \ - oop_field(HotSpotMonitorValue, owner, "Lcom/oracle/graal/api/meta/JavaValue;") \ - oop_field(HotSpotMonitorValue, slot, "Lcom/oracle/graal/api/code/StackSlotValue;") \ - boolean_field(HotSpotMonitorValue, eliminated) \ + start_class(StackLockValue) \ + oop_field(StackLockValue, owner, "Lcom/oracle/graal/api/meta/JavaValue;") \ + oop_field(StackLockValue, slot, "Lcom/oracle/graal/api/code/StackSlotValue;") \ + boolean_field(StackLockValue, eliminated) \ end_class \ start_class(SpeculationLog) \ oop_field(SpeculationLog, lastFailed, "Ljava/lang/Object;") \