--- old/src/hotspot/share/classfile/compactHashtable.cpp 2018-09-18 21:28:55.503606893 -0700 +++ new/src/hotspot/share/classfile/compactHashtable.cpp 2018-09-18 21:28:55.271597957 -0700 @@ -181,34 +181,6 @@ soc->do_ptr((void**)&_entries); } -bool SimpleCompactHashtable::exists(u4 value) { - assert(!DumpSharedSpaces, "run-time only"); - - if (_entry_count == 0) { - return false; - } - - unsigned int hash = (unsigned int)value; - int index = hash % _bucket_count; - u4 bucket_info = _buckets[index]; - u4 bucket_offset = BUCKET_OFFSET(bucket_info); - int bucket_type = BUCKET_TYPE(bucket_info); - u4* entry = _entries + bucket_offset; - - if (bucket_type == VALUE_ONLY_BUCKET_TYPE) { - return (entry[0] == value); - } else { - u4*entry_max = _entries + BUCKET_OFFSET(_buckets[index + 1]); - while (entry do_value(DECODE(_base_address, entry[0])); + iter->do_value(decode(entry[0])); } else { u4*entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]); while (entry < entry_max) { - iter->do_value(DECODE(_base_address, entry[1])); + iter->do_value(decode(entry[1])); entry += 2; } } --- old/src/hotspot/share/classfile/javaClasses.cpp 2018-09-18 21:28:56.483644641 -0700 +++ new/src/hotspot/share/classfile/javaClasses.cpp 2018-09-18 21:28:56.239635243 -0700 @@ -260,7 +260,7 @@ return h_obj; } -Handle java_lang_String::create_from_unicode(jchar* unicode, int length, TRAPS) { +Handle java_lang_String::create_from_unicode(const jchar* unicode, int length, TRAPS) { bool is_latin1 = CompactStrings && UNICODE::is_latin1(unicode, length); Handle h_obj = basic_create(length, is_latin1, CHECK_NH); typeArrayOop buffer = value(h_obj()); @@ -290,7 +290,7 @@ return h_obj; } -oop java_lang_String::create_oop_from_unicode(jchar* unicode, int length, TRAPS) { +oop java_lang_String::create_oop_from_unicode(const jchar* unicode, int length, TRAPS) { Handle h_obj = create_from_unicode(unicode, length, CHECK_0); return h_obj(); } @@ -662,7 +662,7 @@ } } -bool java_lang_String::equals(oop java_string, jchar* chars, int len) { +bool java_lang_String::equals(oop java_string, const jchar* chars, int len) { assert(java_string->klass() == SystemDictionary::String_klass(), "must be java_string"); typeArrayOop value = java_lang_String::value_no_keepalive(java_string); @@ -2588,7 +2588,7 @@ // Fill in class name ResourceMark rm(THREAD); const char* str = holder->external_name(); - oop classname = StringTable::intern((char*) str, CHECK); + oop classname = StringTable::intern(str, CHECK); java_lang_StackTraceElement::set_declaringClass(element(), classname); java_lang_StackTraceElement::set_declaringClassObject(element(), holder->java_mirror()); --- old/src/hotspot/share/classfile/javaClasses.hpp 2018-09-18 21:28:57.035665904 -0700 +++ new/src/hotspot/share/classfile/javaClasses.hpp 2018-09-18 21:28:56.779656043 -0700 @@ -114,8 +114,8 @@ static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN; // Instance creation - static Handle create_from_unicode(jchar* unicode, int len, TRAPS); - static oop create_oop_from_unicode(jchar* unicode, int len, TRAPS); + static Handle create_from_unicode(const jchar* unicode, int len, TRAPS); + static oop create_oop_from_unicode(const jchar* unicode, int len, TRAPS); static Handle create_from_str(const char* utf8_str, TRAPS); static oop create_oop_from_str(const char* utf8_str, TRAPS); static Handle create_from_symbol(Symbol* symbol, TRAPS); @@ -189,7 +189,7 @@ static unsigned int hash_code(oop java_string); - static bool equals(oop java_string, jchar* chars, int len); + static bool equals(oop java_string, const jchar* chars, int len); static bool equals(oop str1, oop str2); // Conversion between '.' and '/' formats --- old/src/hotspot/share/classfile/stringTable.cpp 2018-09-18 21:28:57.555685934 -0700 +++ new/src/hotspot/share/classfile/stringTable.cpp 2018-09-18 21:28:57.307676381 -0700 @@ -63,22 +63,19 @@ // If we have as many dead items as 50% of the number of bucket #define CLEAN_DEAD_HIGH_WATER_MARK 0.5 -// -------------------------------------------------------------------------- +#if INCLUDE_CDS_JAVA_HEAP inline oop read_string_from_compact_hashtable(address base_address, u4 offset) { assert(sizeof(narrowOop) == sizeof(offset), "must be"); narrowOop v = (narrowOop)offset; return HeapShared::decode_from_archive(v); } -inline bool string_equals_compact_hashtable_entry(oop value, const jchar* key, int len) { - return java_lang_String::equals(value, (jchar*)key, len); -} - static CompactHashtable< const jchar*, oop, read_string_from_compact_hashtable, - string_equals_compact_hashtable_entry + java_lang_String::equals > _shared_table; +#endif // -------------------------------------------------------------------------- StringTable* StringTable::_the_table = NULL; @@ -151,7 +148,7 @@ *is_dead = true; return false; } - bool equals = java_lang_String::equals(val_oop, (jchar*)_str, _len); + bool equals = java_lang_String::equals(val_oop, _str, _len); if (!equals) { return false; } @@ -253,7 +250,7 @@ return lookup(chars, length); } -oop StringTable::lookup(jchar* name, int len) { +oop StringTable::lookup(const jchar* name, int len) { unsigned int hash = java_lang_String::hash_code(name, len); oop string = StringTable::the_table()->lookup_shared(name, len, hash); if (string != NULL) { @@ -280,7 +277,7 @@ } }; -oop StringTable::do_lookup(jchar* name, int len, uintx hash) { +oop StringTable::do_lookup(const jchar* name, int len, uintx hash) { Thread* thread = Thread::current(); StringTableLookupJchar lookup(thread, hash, name, len); StringTableGet stg(thread); @@ -325,7 +322,7 @@ return result; } -oop StringTable::intern(Handle string_or_null_h, jchar* name, int len, TRAPS) { +oop StringTable::intern(Handle string_or_null_h, const jchar* name, int len, TRAPS) { // shared table always uses java_lang_String::hash_code unsigned int hash = java_lang_String::hash_code(name, len); oop found_string = StringTable::the_table()->lookup_shared(name, len, hash); @@ -363,7 +360,7 @@ } }; -oop StringTable::do_intern(Handle string_or_null_h, jchar* name, +oop StringTable::do_intern(Handle string_or_null_h, const jchar* name, int len, uintx hash, TRAPS) { HandleMark hm(THREAD); // cleanup strings created Handle string_h; @@ -792,7 +789,7 @@ // Sharing #if INCLUDE_CDS_JAVA_HEAP -oop StringTable::lookup_shared(jchar* name, int len, unsigned int hash) { +oop StringTable::lookup_shared(const jchar* name, int len, unsigned int hash) { assert(hash == java_lang_String::hash_code(name, len), "hash must be computed using java_lang_String::hash_code"); return _shared_table.lookup(name, hash, len); --- old/src/hotspot/share/classfile/stringTable.hpp 2018-09-18 21:28:58.079706117 -0700 +++ new/src/hotspot/share/classfile/stringTable.hpp 2018-09-18 21:28:57.831696564 -0700 @@ -85,9 +85,9 @@ StringTable(); - static oop intern(Handle string_or_null_h, jchar* name, int len, TRAPS); - oop do_intern(Handle string_or_null, jchar* name, int len, uintx hash, TRAPS); - oop do_lookup(jchar* name, int len, uintx hash); + static oop intern(Handle string_or_null_h, const jchar* name, int len, TRAPS); + oop do_intern(Handle string_or_null, const jchar* name, int len, uintx hash, TRAPS); + oop do_lookup(const jchar* name, int len, uintx hash); void concurrent_work(JavaThread* jt); void print_table_statistics(outputStream* st, const char* table_name); @@ -148,7 +148,7 @@ // Probing static oop lookup(Symbol* symbol); - static oop lookup(jchar* chars, int length); + static oop lookup(const jchar* chars, int length); // Interning static oop intern(Symbol* symbol, TRAPS); @@ -162,7 +162,7 @@ // Sharing private: - oop lookup_shared(jchar* name, int len, unsigned int hash) NOT_CDS_JAVA_HEAP_RETURN_(NULL); + oop lookup_shared(const jchar* name, int len, unsigned int hash) NOT_CDS_JAVA_HEAP_RETURN_(NULL); static void copy_shared_string_table(CompactStringTableWriter* ch_table) NOT_CDS_JAVA_HEAP_RETURN; public: static oop create_archived_string(oop s, Thread* THREAD) NOT_CDS_JAVA_HEAP_RETURN_(NULL); --- old/src/hotspot/share/utilities/utf8.cpp 2018-09-18 21:28:58.619726916 -0700 +++ new/src/hotspot/share/utilities/utf8.cpp 2018-09-18 21:28:58.363717056 -0700 @@ -401,7 +401,7 @@ return (c <= 0x00FF); } -bool UNICODE::is_latin1(jchar* base, int length) { +bool UNICODE::is_latin1(const jchar* base, int length) { for (int index = 0; index < length; index++) { if (base[index] > 0x00FF) { return false; @@ -434,7 +434,7 @@ } template -int UNICODE::utf8_length(T* base, int length) { +int UNICODE::utf8_length(const T* base, int length) { int result = 0; for (int index = 0; index < length; index++) { T c = base[index]; @@ -444,7 +444,7 @@ } template -char* UNICODE::as_utf8(T* base, int& length) { +char* UNICODE::as_utf8(const T* base, int& length) { int utf8_len = utf8_length(base, length); u_char* buf = NEW_RESOURCE_ARRAY(u_char, utf8_len + 1); char* result = as_utf8(base, length, (char*) buf, utf8_len + 1); @@ -454,7 +454,7 @@ return (char*) result; } -char* UNICODE::as_utf8(jchar* base, int length, char* buf, int buflen) { +char* UNICODE::as_utf8(const jchar* base, int length, char* buf, int buflen) { u_char* p = (u_char*)buf; for (int index = 0; index < length; index++) { jchar c = base[index]; @@ -466,7 +466,7 @@ return buf; } -char* UNICODE::as_utf8(jbyte* base, int length, char* buf, int buflen) { +char* UNICODE::as_utf8(const jbyte* base, int length, char* buf, int buflen) { u_char* p = (u_char*)buf; u_char* end = (u_char*)buf + buflen; for (int index = 0; index < length; index++) { @@ -496,7 +496,7 @@ // returns the quoted ascii length of a unicode string template -int UNICODE::quoted_ascii_length(T* base, int length) { +int UNICODE::quoted_ascii_length(const T* base, int length) { int result = 0; for (int i = 0; i < length; i++) { T c = base[i]; @@ -529,11 +529,11 @@ } // Explicit instantiation for all supported types. -template int UNICODE::utf8_length(jbyte* base, int length); -template int UNICODE::utf8_length(jchar* base, int length); -template char* UNICODE::as_utf8(jbyte* base, int& length); -template char* UNICODE::as_utf8(jchar* base, int& length); -template int UNICODE::quoted_ascii_length(jbyte* base, int length); -template int UNICODE::quoted_ascii_length(jchar* base, int length); +template int UNICODE::utf8_length(const jbyte* base, int length); +template int UNICODE::utf8_length(const jchar* base, int length); +template char* UNICODE::as_utf8(const jbyte* base, int& length); +template char* UNICODE::as_utf8(const jchar* base, int& length); +template int UNICODE::quoted_ascii_length(const jbyte* base, int length); +template int UNICODE::quoted_ascii_length(const jchar* base, int length); template void UNICODE::as_quoted_ascii(const jbyte* base, int length, char* buf, int buflen); template void UNICODE::as_quoted_ascii(const jchar* base, int length, char* buf, int buflen); --- old/src/hotspot/share/utilities/utf8.hpp 2018-09-18 21:28:59.139746947 -0700 +++ new/src/hotspot/share/utilities/utf8.hpp 2018-09-18 21:28:58.883737086 -0700 @@ -90,14 +90,14 @@ static bool is_latin1(jchar c); // checks if the given string can be encoded as latin1 - static bool is_latin1(jchar* base, int length); + static bool is_latin1(const jchar* base, int length); // returns the utf8 size of a unicode character static int utf8_size(jchar c); static int utf8_size(jbyte c); // returns the utf8 length of a unicode string - template static int utf8_length(T* base, int length); + template static int utf8_length(const T* base, int length); // converts a unicode string to utf8 string static void convert_to_utf8(const jchar* base, int length, char* utf8_buffer); @@ -105,12 +105,12 @@ // converts a unicode string to a utf8 string; result is allocated // in resource area unless a buffer is provided. The unicode 'length' // parameter is set to the length of the result utf8 string. - template static char* as_utf8(T* base, int& length); - static char* as_utf8(jchar* base, int length, char* buf, int buflen); - static char* as_utf8(jbyte* base, int length, char* buf, int buflen); + template static char* as_utf8(const T* base, int& length); + static char* as_utf8(const jchar* base, int length, char* buf, int buflen); + static char* as_utf8(const jbyte* base, int length, char* buf, int buflen); // returns the quoted ascii length of a unicode string - template static int quoted_ascii_length(T* base, int length); + template static int quoted_ascii_length(const T* base, int length); // converts a unicode string to quoted ascii template static void as_quoted_ascii(const T* base, int length, char* buf, int buflen);