-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
master
https://github.com/openjdk/jdk/blob/7f02f07f754c942735ba15d70858cd1661a658c0/src/hotspot/share/classfile/stringTable.cpp#L332-L342
oop StringTable::intern(oop string, TRAPS) {
if (string == nullptr) return nullptr;
ResourceMark rm(THREAD);
int length;
Handle h_string (THREAD, string);
jchar* chars = java_lang_String::as_unicode_string(string, length,
CHECK_NULL);
oop result = intern(h_string, chars, length, CHECK_NULL);
return result;
}
The "chars" are used for computing the hashcode. However, we can just call java_lang_String::hash_code(oop), which will compute the hashcode for us without making the extra allocation.
==========================
Fixing this will help improve start-up time, as the following one-liner today causes about 4400 calls to String::intern().
import java.text.*;
class DateFormatTest {
public static void main(String args[]) {
SimpleDateFormat t = new SimpleDateFormat();
}
}
oop StringTable::intern(oop string, TRAPS) {
if (string == nullptr) return nullptr;
ResourceMark rm(THREAD);
int length;
Handle h_string (THREAD, string);
jchar* chars = java_lang_String::as_unicode_string(string, length,
CHECK_NULL);
oop result = intern(h_string, chars, length, CHECK_NULL);
return result;
}
The "chars" are used for computing the hashcode. However, we can just call java_lang_String::hash_code(oop), which will compute the hashcode for us without making the extra allocation.
==========================
Fixing this will help improve start-up time, as the following one-liner today causes about 4400 calls to String::intern().
import java.text.*;
class DateFormatTest {
public static void main(String args[]) {
SimpleDateFormat t = new SimpleDateFormat();
}
}
- relates to
-
JDK-8326865 Avoid copying in StringTable::intern(Symbol*, TRAPS)
- Resolved
-
JDK-8327825 StringTable::intern is slow
- Resolved
- links to
-
Commit(master) openjdk/jdk/75c651f8
-
Review(master) openjdk/jdk/21325