358 bool latin1 = java_lang_String::is_latin1(java_string);
359 unsigned int hash = 0;
360
361 if (use_java_hash()) {
362 // Get hash code from cache
363 hash = java_lang_String::hash(java_string);
364 }
365
366 if (hash == 0) {
367 // Compute hash
368 hash = hash_code(value, latin1);
369 stat->inc_hashed();
370
371 if (use_java_hash() && hash != 0) {
372 // Store hash code in cache
373 java_lang_String::set_hash(java_string, hash);
374 }
375 }
376
377 typeArrayOop existing_value = lookup_or_add(value, latin1, hash);
378 if (existing_value == value) {
379 // Same value, already known
380 stat->inc_known();
381 return;
382 }
383
384 // Get size of value array
385 uintx size_in_bytes = value->size() * HeapWordSize;
386 stat->inc_new(size_in_bytes);
387
388 if (existing_value != NULL) {
389 // Existing value found, deduplicate string
390 java_lang_String::set_value(java_string, existing_value);
391 stat->deduped(value, size_in_bytes);
392 }
393 }
394
395 bool StringDedupTable::is_resizing() {
396 return _resized_table != NULL;
397 }
398
|
358 bool latin1 = java_lang_String::is_latin1(java_string);
359 unsigned int hash = 0;
360
361 if (use_java_hash()) {
362 // Get hash code from cache
363 hash = java_lang_String::hash(java_string);
364 }
365
366 if (hash == 0) {
367 // Compute hash
368 hash = hash_code(value, latin1);
369 stat->inc_hashed();
370
371 if (use_java_hash() && hash != 0) {
372 // Store hash code in cache
373 java_lang_String::set_hash(java_string, hash);
374 }
375 }
376
377 typeArrayOop existing_value = lookup_or_add(value, latin1, hash);
378 if (oopDesc::unsafe_equals(existing_value, value)) {
379 // Same value, already known
380 stat->inc_known();
381 return;
382 }
383
384 // Get size of value array
385 uintx size_in_bytes = value->size() * HeapWordSize;
386 stat->inc_new(size_in_bytes);
387
388 if (existing_value != NULL) {
389 // Existing value found, deduplicate string
390 java_lang_String::set_value(java_string, existing_value);
391 stat->deduped(value, size_in_bytes);
392 }
393 }
394
395 bool StringDedupTable::is_resizing() {
396 return _resized_table != NULL;
397 }
398
|