mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8150752: Share Class Data
Reviewed-by: acorn, hseigel, mschoene
This commit is contained in:
parent
99c24f5f1c
commit
2a09a3923a
8 changed files with 98 additions and 26 deletions
|
@ -238,6 +238,29 @@ Symbol* SymbolTable::lookup(int index, const char* name,
|
|||
}
|
||||
}
|
||||
|
||||
u4 SymbolTable::encode_shared(Symbol* sym) {
|
||||
assert(DumpSharedSpaces, "called only during dump time");
|
||||
uintx base_address = uintx(MetaspaceShared::shared_rs()->base());
|
||||
uintx offset = uintx(sym) - base_address;
|
||||
assert(offset < 0x7fffffff, "sanity");
|
||||
return u4(offset);
|
||||
}
|
||||
|
||||
Symbol* SymbolTable::decode_shared(u4 offset) {
|
||||
assert(!DumpSharedSpaces, "called only during runtime");
|
||||
uintx base_address = _shared_table.base_address();
|
||||
Symbol* sym = (Symbol*)(base_address + offset);
|
||||
|
||||
#ifndef PRODUCT
|
||||
const char* s = (const char*)sym->bytes();
|
||||
int len = sym->utf8_length();
|
||||
unsigned int hash = hash_symbol(s, len);
|
||||
assert(sym == lookup_shared(s, len, hash), "must be shared symbol");
|
||||
#endif
|
||||
|
||||
return sym;
|
||||
}
|
||||
|
||||
// Pick hashing algorithm.
|
||||
unsigned int SymbolTable::hash_symbol(const char* s, int len) {
|
||||
return use_alternate_hashcode() ?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue