325 UTF8::convert_to_unicode(utf8_string, chars, length);
326 Handle string;
327 oop result = intern(string, chars, length, CHECK_NULL);
328 return result;
329 }
330
331 oop StringTable::intern(Handle string_or_null_h, const jchar* name, int len, TRAPS) {
332 // shared table always uses java_lang_String::hash_code
333 unsigned int hash = java_lang_String::hash_code(name, len);
334 oop found_string = lookup_shared(name, len, hash);
335 if (found_string != NULL) {
336 return found_string;
337 }
338 if (_alt_hash) {
339 hash = hash_string(name, len, true);
340 }
341 found_string = do_lookup(name, len, hash);
342 if (found_string != NULL) {
343 return found_string;
344 }
345 return do_intern(string_or_null_h, name, len, hash, CHECK_NULL);
346 }
347
348 oop StringTable::do_intern(Handle string_or_null_h, const jchar* name,
349 int len, uintx hash, TRAPS) {
350 HandleMark hm(THREAD); // cleanup strings created
351 Handle string_h;
352
353 if (!string_or_null_h.is_null()) {
354 string_h = string_or_null_h;
355 } else {
356 string_h = java_lang_String::create_from_unicode(name, len, CHECK_NULL);
357 }
358
359 // Deduplicate the string before it is interned. Note that we should never
360 // deduplicate a string after it has been interned. Doing so will counteract
361 // compiler optimizations done on e.g. interned string literals.
362 Universe::heap()->deduplicate_string(string_h());
363
364 assert(java_lang_String::equals(string_h(), name, len),
365 "string must be properly initialized");
|
325 UTF8::convert_to_unicode(utf8_string, chars, length);
326 Handle string;
327 oop result = intern(string, chars, length, CHECK_NULL);
328 return result;
329 }
330
331 oop StringTable::intern(Handle string_or_null_h, const jchar* name, int len, TRAPS) {
332 // shared table always uses java_lang_String::hash_code
333 unsigned int hash = java_lang_String::hash_code(name, len);
334 oop found_string = lookup_shared(name, len, hash);
335 if (found_string != NULL) {
336 return found_string;
337 }
338 if (_alt_hash) {
339 hash = hash_string(name, len, true);
340 }
341 found_string = do_lookup(name, len, hash);
342 if (found_string != NULL) {
343 return found_string;
344 }
345 return do_intern(string_or_null_h, name, len, hash, THREAD);
346 }
347
348 oop StringTable::do_intern(Handle string_or_null_h, const jchar* name,
349 int len, uintx hash, TRAPS) {
350 HandleMark hm(THREAD); // cleanup strings created
351 Handle string_h;
352
353 if (!string_or_null_h.is_null()) {
354 string_h = string_or_null_h;
355 } else {
356 string_h = java_lang_String::create_from_unicode(name, len, CHECK_NULL);
357 }
358
359 // Deduplicate the string before it is interned. Note that we should never
360 // deduplicate a string after it has been interned. Doing so will counteract
361 // compiler optimizations done on e.g. interned string literals.
362 Universe::heap()->deduplicate_string(string_h());
363
364 assert(java_lang_String::equals(string_h(), name, len),
365 "string must be properly initialized");
|