8130135: backout 8087143 due to failures in 8130115

Reviewed-by: minqi, coleenp
This commit is contained in:
Daniel D. Daugherty 2015-06-30 09:39:53 -07:00
parent 037958ba9a
commit 7315d2ea19
4 changed files with 21 additions and 19 deletions

View file

@ -47,7 +47,7 @@ public class Symbol extends VMObject {
Type type = db.lookupType("Symbol"); Type type = db.lookupType("Symbol");
length = type.getCIntegerField("_length"); length = type.getCIntegerField("_length");
baseOffset = type.getField("_body").getOffset(); baseOffset = type.getField("_body").getOffset();
idHash = type.getJShortField("_identity_hash"); idHash = type.getCIntegerField("_identity_hash");
} }
// Format: // Format:
@ -81,9 +81,9 @@ public class Symbol extends VMObject {
return addr.getJByteAt(baseOffset + index); return addr.getJByteAt(baseOffset + index);
} }
private static JShortField idHash; private static CIntegerField idHash;
public short identityHash() { return (short)idHash.getValue(this.addr); } public int identityHash() { return (int)idHash.getValue(this.addr); }
public boolean equals(byte[] modUTF8Chars) { public boolean equals(byte[] modUTF8Chars) {
int l = (int) getLength(); int l = (int) getLength();

View file

@ -35,7 +35,7 @@
Symbol::Symbol(const u1* name, int length, int refcount) { Symbol::Symbol(const u1* name, int length, int refcount) {
_refcount = refcount; _refcount = refcount;
_length = length; _length = length;
_identity_hash = (short)os::random(); _identity_hash = os::random();
for (int i = 0; i < _length; i++) { for (int i = 0; i < _length; i++) {
byte_at_put(i, name[i]); byte_at_put(i, name[i]);
} }

View file

@ -102,18 +102,23 @@
// type without virtual functions. // type without virtual functions.
class ClassLoaderData; class ClassLoaderData;
class Symbol : public MetaspaceObj { // We separate the fields in SymbolBase from Symbol::_body so that
friend class VMStructs; // Symbol::size(int) can correctly calculate the space needed.
friend class SymbolTable; class SymbolBase : public MetaspaceObj {
friend class MoveSymbols; public:
private:
ATOMIC_SHORT_PAIR( ATOMIC_SHORT_PAIR(
volatile short _refcount, // needs atomic operation volatile short _refcount, // needs atomic operation
unsigned short _length // number of UTF8 characters in the symbol (does not need atomic op) unsigned short _length // number of UTF8 characters in the symbol (does not need atomic op)
); );
short _identity_hash; int _identity_hash;
jbyte _body[2]; };
class Symbol : private SymbolBase {
friend class VMStructs;
friend class SymbolTable;
friend class MoveSymbols;
private:
jbyte _body[1];
enum { enum {
// max_symbol_length is constrained by type of _length // max_symbol_length is constrained by type of _length
@ -121,7 +126,7 @@ class Symbol : public MetaspaceObj {
}; };
static int size(int length) { static int size(int length) {
size_t sz = heap_word_size(sizeof(Symbol) + (length > 2 ? length - 2 : 0)); size_t sz = heap_word_size(sizeof(SymbolBase) + (length > 0 ? length : 0));
return align_object_size(sz); return align_object_size(sz);
} }
@ -145,11 +150,8 @@ class Symbol : public MetaspaceObj {
// Returns the largest size symbol we can safely hold. // Returns the largest size symbol we can safely hold.
static int max_length() { return max_symbol_length; } static int max_length() { return max_symbol_length; }
unsigned identity_hash() {
unsigned addr_bits = (unsigned)((uintptr_t)this >> (LogMinObjAlignmentInBytes + 3)); int identity_hash() { return _identity_hash; }
return (unsigned)_identity_hash |
((addr_bits ^ (_length << 8) ^ (( _body[0] << 8) | _body[1])) << 16);
}
// For symbol table alternate hashing // For symbol table alternate hashing
unsigned int new_hash(juint seed); unsigned int new_hash(juint seed);

View file

@ -403,7 +403,7 @@ typedef CompactHashtable<Symbol*, char> SymbolCompactHashTable;
nonstatic_field(ObjArrayKlass, _element_klass, Klass*) \ nonstatic_field(ObjArrayKlass, _element_klass, Klass*) \
nonstatic_field(ObjArrayKlass, _bottom_klass, Klass*) \ nonstatic_field(ObjArrayKlass, _bottom_klass, Klass*) \
volatile_nonstatic_field(Symbol, _refcount, short) \ volatile_nonstatic_field(Symbol, _refcount, short) \
nonstatic_field(Symbol, _identity_hash, short) \ nonstatic_field(Symbol, _identity_hash, int) \
nonstatic_field(Symbol, _length, unsigned short) \ nonstatic_field(Symbol, _length, unsigned short) \
unchecked_nonstatic_field(Symbol, _body, sizeof(jbyte)) /* NOTE: no type */ \ unchecked_nonstatic_field(Symbol, _body, sizeof(jbyte)) /* NOTE: no type */ \
nonstatic_field(TypeArrayKlass, _max_length, int) \ nonstatic_field(TypeArrayKlass, _max_length, int) \