370 StringTableLookupOop lookup(THREAD, hash, string_h); |
370 StringTableLookupOop lookup(THREAD, hash, string_h); |
371 StringTableGet stg(THREAD); |
371 StringTableGet stg(THREAD); |
372 |
372 |
373 bool rehash_warning; |
373 bool rehash_warning; |
374 do { |
374 do { |
375 if (_local_table->get(THREAD, lookup, stg, &rehash_warning)) { |
375 // Callers have already looked up the String using the jchar* name, so just go to add. |
376 update_needs_rehash(rehash_warning); |
|
377 return stg.get_res_oop(); |
|
378 } |
|
379 WeakHandle<vm_string_table_data> wh = WeakHandle<vm_string_table_data>::create(string_h); |
376 WeakHandle<vm_string_table_data> wh = WeakHandle<vm_string_table_data>::create(string_h); |
380 // The hash table takes ownership of the WeakHandle, even if it's not inserted. |
377 // The hash table takes ownership of the WeakHandle, even if it's not inserted. |
381 if (_local_table->insert(THREAD, lookup, wh, &rehash_warning)) { |
378 if (_local_table->insert(THREAD, lookup, wh, &rehash_warning)) { |
382 update_needs_rehash(rehash_warning); |
379 update_needs_rehash(rehash_warning); |
383 return wh.resolve(); |
380 return wh.resolve(); |
|
381 } |
|
382 // In case another thread did a concurrent add, return value already in the table. |
|
383 // This could fail if the String got gc'ed concurrently, so loop back until success. |
|
384 if (_local_table->get(THREAD, lookup, stg, &rehash_warning)) { |
|
385 update_needs_rehash(rehash_warning); |
|
386 return stg.get_res_oop(); |
384 } |
387 } |
385 } while(true); |
388 } while(true); |
386 } |
389 } |
387 |
390 |
388 void StringTable::oops_do(OopClosure* f) { |
391 void StringTable::oops_do(OopClosure* f) { |