236 } |
236 } |
237 return sym; |
237 return sym; |
238 } |
238 } |
239 } |
239 } |
240 |
240 |
|
241 u4 SymbolTable::encode_shared(Symbol* sym) { |
|
242 assert(DumpSharedSpaces, "called only during dump time"); |
|
243 uintx base_address = uintx(MetaspaceShared::shared_rs()->base()); |
|
244 uintx offset = uintx(sym) - base_address; |
|
245 assert(offset < 0x7fffffff, "sanity"); |
|
246 return u4(offset); |
|
247 } |
|
248 |
|
249 Symbol* SymbolTable::decode_shared(u4 offset) { |
|
250 assert(!DumpSharedSpaces, "called only during runtime"); |
|
251 uintx base_address = _shared_table.base_address(); |
|
252 Symbol* sym = (Symbol*)(base_address + offset); |
|
253 |
|
254 #ifndef PRODUCT |
|
255 const char* s = (const char*)sym->bytes(); |
|
256 int len = sym->utf8_length(); |
|
257 unsigned int hash = hash_symbol(s, len); |
|
258 assert(sym == lookup_shared(s, len, hash), "must be shared symbol"); |
|
259 #endif |
|
260 |
|
261 return sym; |
|
262 } |
|
263 |
241 // Pick hashing algorithm. |
264 // Pick hashing algorithm. |
242 unsigned int SymbolTable::hash_symbol(const char* s, int len) { |
265 unsigned int SymbolTable::hash_symbol(const char* s, int len) { |
243 return use_alternate_hashcode() ? |
266 return use_alternate_hashcode() ? |
244 AltHashing::murmur3_32(seed(), (const jbyte*)s, len) : |
267 AltHashing::murmur3_32(seed(), (const jbyte*)s, len) : |
245 java_lang_String::hash_code((const jbyte*)s, len); |
268 java_lang_String::hash_code((const jbyte*)s, len); |