216 oop StringTable::intern(Handle string_or_null, jchar* name,
217 int len, TRAPS) {
218 oop found_string = lookup_shared(name, len);
219 if (found_string != NULL) {
220 return found_string;
221 }
222
223 unsigned int hashValue = hash_string(name, len);
224 int index = the_table()->hash_to_index(hashValue);
225 found_string = the_table()->lookup_in_main_table(index, name, len, hashValue);
226
227 // Found
228 if (found_string != NULL) {
229 if (found_string != string_or_null()) {
230 ensure_string_alive(found_string);
231 }
232 return found_string;
233 }
234
235 debug_only(StableMemoryChecker smc(name, len * sizeof(name[0])));
236 assert(!Universe::heap()->is_in_reserved(name),
237 "proposed name of symbol must be stable");
238
239 Handle string;
240 // try to reuse the string if possible
241 if (!string_or_null.is_null()) {
242 string = string_or_null;
243 } else {
244 string = java_lang_String::create_from_unicode(name, len, CHECK_NULL);
245 }
246
247 #if INCLUDE_ALL_GCS
248 if (G1StringDedup::is_enabled()) {
249 // Deduplicate the string before it is interned. Note that we should never
250 // deduplicate a string after it has been interned. Doing so will counteract
251 // compiler optimizations done on e.g. interned string literals.
252 G1StringDedup::deduplicate(string());
253 }
254 #endif
255
256 // Grab the StringTable_lock before getting the_table() because it could
|
216 oop StringTable::intern(Handle string_or_null, jchar* name,
217 int len, TRAPS) {
218 oop found_string = lookup_shared(name, len);
219 if (found_string != NULL) {
220 return found_string;
221 }
222
223 unsigned int hashValue = hash_string(name, len);
224 int index = the_table()->hash_to_index(hashValue);
225 found_string = the_table()->lookup_in_main_table(index, name, len, hashValue);
226
227 // Found
228 if (found_string != NULL) {
229 if (found_string != string_or_null()) {
230 ensure_string_alive(found_string);
231 }
232 return found_string;
233 }
234
235 debug_only(StableMemoryChecker smc(name, len * sizeof(name[0])));
236 assert(!GC::gc()->heap()->is_in_reserved(name),
237 "proposed name of symbol must be stable");
238
239 Handle string;
240 // try to reuse the string if possible
241 if (!string_or_null.is_null()) {
242 string = string_or_null;
243 } else {
244 string = java_lang_String::create_from_unicode(name, len, CHECK_NULL);
245 }
246
247 #if INCLUDE_ALL_GCS
248 if (G1StringDedup::is_enabled()) {
249 // Deduplicate the string before it is interned. Note that we should never
250 // deduplicate a string after it has been interned. Doing so will counteract
251 // compiler optimizations done on e.g. interned string literals.
252 G1StringDedup::deduplicate(string());
253 }
254 #endif
255
256 // Grab the StringTable_lock before getting the_table() because it could
|