001/* 002 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package jdk.internal.jvmci.code; 024 025import jdk.internal.jvmci.meta.*; 026import static jdk.internal.jvmci.code.ValueUtil.*; 027 028/** 029 * Represents lock information in the debug information. 030 */ 031public final class StackLockValue extends AbstractValue implements JavaValue { 032 033 private Value owner; 034 private StackSlotValue slot; 035 private final boolean eliminated; 036 037 public StackLockValue(Value object, StackSlotValue slot, boolean eliminated) { 038 super(LIRKind.Illegal); 039 this.owner = object; 040 this.slot = slot; 041 this.eliminated = eliminated; 042 } 043 044 public Value getOwner() { 045 return owner; 046 } 047 048 public void setOwner(Value newOwner) { 049 this.owner = newOwner; 050 } 051 052 public Value getSlot() { 053 return slot; 054 } 055 056 public boolean isEliminated() { 057 return eliminated; 058 } 059 060 @Override 061 public String toString() { 062 return "monitor[" + owner + (slot != null ? ", " + slot : "") + (eliminated ? ", eliminated" : "") + "]"; 063 } 064 065 @Override 066 public int hashCode() { 067 final int prime = 43; 068 int result = super.hashCode(); 069 result = prime * result + (eliminated ? 1231 : 1237); 070 result = prime * result + owner.hashCode(); 071 result = prime * result + slot.hashCode(); 072 return result; 073 } 074 075 @Override 076 public boolean equals(Object obj) { 077 if (obj instanceof StackLockValue) { 078 StackLockValue other = (StackLockValue) obj; 079 return super.equals(obj) && eliminated == other.eliminated && owner.equals(other.owner) && slot.equals(other.slot); 080 } 081 return false; 082 } 083 084 public void setSlot(StackSlotValue stackSlot) { 085 assert slot == null || (isVirtualStackSlot(slot) && (slot.equals(stackSlot) || isStackSlot(stackSlot))) : String.format("Can not set slot for %s to %s", this, stackSlot); 086 slot = stackSlot; 087 } 088}