< prev index next >

src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 28,38 **** #include "gc/shared/stringdedup/stringDedup.hpp" #include "gc/shared/stringdedup/stringDedupTable.hpp" #include "gc/shared/suspendibleThreadSet.hpp" #include "logging/log.hpp" #include "memory/padded.inline.hpp" - #include "memory/universe.hpp" #include "oops/access.inline.hpp" #include "oops/arrayOop.inline.hpp" #include "oops/oop.inline.hpp" #include "oops/typeArrayOop.hpp" #include "runtime/mutexLocker.hpp" --- 28,37 ----
*** 350,367 **** bool latin1 = java_lang_String::is_latin1(java_string); unsigned int hash = 0; if (use_java_hash()) { ! if (!java_lang_String::hash_is_set(java_string)) { ! stat->inc_hashed(); ! } ! hash = java_lang_String::hash_code(java_string); ! } else { // Compute hash hash = hash_code(value, latin1); stat->inc_hashed(); } typeArrayOop existing_value = lookup_or_add(value, latin1, hash); if (oopDesc::equals_raw(existing_value, value)) { // Same value, already known --- 349,371 ---- bool latin1 = java_lang_String::is_latin1(java_string); unsigned int hash = 0; if (use_java_hash()) { ! // Get hash code from cache ! hash = java_lang_String::hash(java_string); ! } ! ! if (hash == 0) { // Compute hash hash = hash_code(value, latin1); stat->inc_hashed(); + + if (use_java_hash() && hash != 0) { + // Store hash code in cache + java_lang_String::set_hash(java_string, hash); + } } typeArrayOop existing_value = lookup_or_add(value, latin1, hash); if (oopDesc::equals_raw(existing_value, value)) { // Same value, already known
*** 476,486 **** removed += unlink_or_oops_do(cl, table_half + partition_begin, table_half + partition_end, worker_id); } // Delayed update to avoid contention on the table lock if (removed > 0) { ! MutexLocker ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag); _table->_entries -= removed; _entries_removed += removed; } } --- 480,490 ---- removed += unlink_or_oops_do(cl, table_half + partition_begin, table_half + partition_end, worker_id); } // Delayed update to avoid contention on the table lock if (removed > 0) { ! MutexLockerEx ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag); _table->_entries -= removed; _entries_removed += removed; } }
< prev index next >