< prev index next >
agent/src/share/classes/sun/jvm/hotspot/oops/Symbol.java
Print this page
@@ -78,14 +78,23 @@
public long getLength() { return length.getValue(this.addr); }
public byte getByteAt(long index) {
return addr.getJByteAt(baseOffset + index);
}
-
+ // _identity_hash is a short
private static CIntegerField idHash;
- public int identityHash() { return (int)idHash.getValue(this.addr); }
+ public int identityHash() {
+ long addr_value = getAddress().asLongValue();
+ int addr_bits = (int)(addr_value >> (VM.getVM().getLogMinObjAlignmentInBytes() + 3));
+ int length = (int)getLength();
+ int byte0 = getByteAt(0);
+ int byte1 = getByteAt(1);
+ int id_hash = (int)(0xffff & idHash.getValue(this.addr));
+ return id_hash |
+ ((addr_bits ^ (length << 8) ^ ((byte0 << 8) | byte1)) << 16);
+ }
public boolean equals(byte[] modUTF8Chars) {
int l = (int) getLength();
if (l != modUTF8Chars.length) return false;
while (l-- > 0) {
< prev index next >