108 109 class Symbol : public MetaspaceObj { 110 friend class VMStructs; 111 friend class SymbolTable; 112 friend class MoveSymbols; 113 114 private: 115 ATOMIC_SHORT_PAIR( 116 volatile short _refcount, // needs atomic operation 117 unsigned short _length // number of UTF8 characters in the symbol (does not need atomic op) 118 ); 119 short _identity_hash; 120 jbyte _body[2]; 121 122 enum { 123 // max_symbol_length is constrained by type of _length 124 max_symbol_length = (1 << 16) -1 125 }; 126 127 static int size(int length) { 128 size_t sz = heap_word_size(sizeof(Symbol) + (length > 2 ? length - 2 : 0)); 129 return align_object_size(sz); 130 } 131 132 void byte_at_put(int index, int value) { 133 assert(index >=0 && index < _length, "symbol index overflow"); 134 _body[index] = value; 135 } 136 137 Symbol(const u1* name, int length, int refcount); 138 void* operator new(size_t size, int len, TRAPS) throw(); 139 void* operator new(size_t size, int len, Arena* arena, TRAPS) throw(); 140 void* operator new(size_t size, int len, ClassLoaderData* loader_data, TRAPS) throw(); 141 142 void operator delete(void* p); 143 144 public: 145 // Low-level access (used with care, since not GC-safe) 146 const jbyte* base() const { return &_body[0]; } 147 148 int size() { return size(utf8_length()); } 149 | 108 109 class Symbol : public MetaspaceObj { 110 friend class VMStructs; 111 friend class SymbolTable; 112 friend class MoveSymbols; 113 114 private: 115 ATOMIC_SHORT_PAIR( 116 volatile short _refcount, // needs atomic operation 117 unsigned short _length // number of UTF8 characters in the symbol (does not need atomic op) 118 ); 119 short _identity_hash; 120 jbyte _body[2]; 121 122 enum { 123 // max_symbol_length is constrained by type of _length 124 max_symbol_length = (1 << 16) -1 125 }; 126 127 static int size(int length) { 128 // minimum number of natural words needed to hold these bits (no non-heap version) 129 return heap_word_size(sizeof(Symbol) + (length > 2 ? length - 2 : 0)); 130 } 131 132 void byte_at_put(int index, int value) { 133 assert(index >=0 && index < _length, "symbol index overflow"); 134 _body[index] = value; 135 } 136 137 Symbol(const u1* name, int length, int refcount); 138 void* operator new(size_t size, int len, TRAPS) throw(); 139 void* operator new(size_t size, int len, Arena* arena, TRAPS) throw(); 140 void* operator new(size_t size, int len, ClassLoaderData* loader_data, TRAPS) throw(); 141 142 void operator delete(void* p); 143 144 public: 145 // Low-level access (used with care, since not GC-safe) 146 const jbyte* base() const { return &_body[0]; } 147 148 int size() { return size(utf8_length()); } 149 |