--- a/hotspot/src/share/vm/oops/symbol.hpp Wed Aug 12 14:18:12 2015 -0400
+++ b/hotspot/src/share/vm/oops/symbol.hpp Fri Aug 14 10:10:35 2015 -0700
@@ -106,23 +106,18 @@
#define PERM_REFCOUNT -1
#endif
-// We separate the fields in SymbolBase from Symbol::_body so that
-// Symbol::size(int) can correctly calculate the space needed.
-class SymbolBase : public MetaspaceObj {
- public:
+class Symbol : public MetaspaceObj {
+ friend class VMStructs;
+ friend class SymbolTable;
+ friend class MoveSymbols;
+
+ private:
ATOMIC_SHORT_PAIR(
volatile short _refcount, // needs atomic operation
unsigned short _length // number of UTF8 characters in the symbol (does not need atomic op)
);
- int _identity_hash;
-};
-
-class Symbol : private SymbolBase {
- friend class VMStructs;
- friend class SymbolTable;
- friend class MoveSymbols;
- private:
- jbyte _body[1];
+ short _identity_hash;
+ jbyte _body[2];
enum {
// max_symbol_length is constrained by type of _length
@@ -130,7 +125,7 @@
};
static int size(int length) {
- size_t sz = heap_word_size(sizeof(SymbolBase) + (length > 0 ? length : 0));
+ size_t sz = heap_word_size(sizeof(Symbol) + (length > 2 ? length - 2 : 0));
return align_object_size(sz);
}
@@ -154,8 +149,11 @@
// Returns the largest size symbol we can safely hold.
static int max_length() { return max_symbol_length; }
-
- int identity_hash() { return _identity_hash; }
+ unsigned identity_hash() {
+ unsigned addr_bits = (unsigned)((uintptr_t)this >> (LogMinObjAlignmentInBytes + 3));
+ return ((unsigned)_identity_hash & 0xffff) |
+ ((addr_bits ^ (_length << 8) ^ (( _body[0] << 8) | _body[1])) << 16);
+ }
// For symbol table alternate hashing
unsigned int new_hash(juint seed);