mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings. Co-authored-by: Brent Christian <brent.christian@oracle.com> Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com> Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com> Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com> Co-authored-by: Roger Riggs <roger.riggs@oracle.com> Co-authored-by: Xueming Shen <xueming.shen@oracle.com> Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com> Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com> Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
This commit is contained in:
parent
4e24e2cc6c
commit
7af927f9c1
74 changed files with 4838 additions and 1683 deletions
|
@ -94,11 +94,16 @@ volatile int StringTable::_parallel_claimed_idx = 0;
|
|||
CompactHashtable<oop, char> StringTable::_shared_table;
|
||||
|
||||
// Pick hashing algorithm
|
||||
unsigned int StringTable::hash_string(const jchar* s, int len) {
|
||||
template<typename T>
|
||||
unsigned int StringTable::hash_string(const T* s, int len) {
|
||||
return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) :
|
||||
java_lang_String::hash_code(s, len);
|
||||
}
|
||||
|
||||
// Explicit instantiation for all supported types.
|
||||
template unsigned int StringTable::hash_string<jchar>(const jchar* s, int len);
|
||||
template unsigned int StringTable::hash_string<jbyte>(const jbyte* s, int len);
|
||||
|
||||
oop StringTable::lookup_shared(jchar* name, int len) {
|
||||
// java_lang_String::hash_code() was used to compute hash values in the shared table. Don't
|
||||
// use the hash value from StringTable::hash_string() as it might use alternate hashcode.
|
||||
|
@ -409,17 +414,25 @@ void StringTable::dump(outputStream* st, bool verbose) {
|
|||
for ( ; p != NULL; p = p->next()) {
|
||||
oop s = p->literal();
|
||||
typeArrayOop value = java_lang_String::value(s);
|
||||
int offset = java_lang_String::offset(s);
|
||||
int length = java_lang_String::length(s);
|
||||
bool is_latin1 = java_lang_String::is_latin1(s);
|
||||
|
||||
if (length <= 0) {
|
||||
st->print("%d: ", length);
|
||||
} else {
|
||||
ResourceMark rm(THREAD);
|
||||
jchar* chars = (jchar*)value->char_at_addr(offset);
|
||||
int utf8_length = UNICODE::utf8_length(chars, length);
|
||||
char* utf8_string = NEW_RESOURCE_ARRAY(char, utf8_length + 1);
|
||||
UNICODE::convert_to_utf8(chars, length, utf8_string);
|
||||
int utf8_length;
|
||||
char* utf8_string;
|
||||
|
||||
if (!is_latin1) {
|
||||
jchar* chars = value->char_at_addr(0);
|
||||
utf8_length = UNICODE::utf8_length(chars, length);
|
||||
utf8_string = UNICODE::as_utf8(chars, length);
|
||||
} else {
|
||||
jbyte* bytes = value->byte_at_addr(0);
|
||||
utf8_length = UNICODE::utf8_length(bytes, length);
|
||||
utf8_string = UNICODE::as_utf8(bytes, length);
|
||||
}
|
||||
|
||||
st->print("%d: ", utf8_length);
|
||||
HashtableTextDump::put_utf8(st, utf8_string, utf8_length);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue