< prev index next >
src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp
Print this page
rev 57656 : 8236878: Use atomic instruction to update StringDedupTable's entries and entries_removed counters
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2020, 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.
@@ -213,11 +213,11 @@
const double StringDedupTable::_max_cache_factor = 0.1; // Cache a maximum of 10% of the table size
const uintx StringDedupTable::_rehash_multiple = 60; // Hash bucket has 60 times more collisions than expected
const uintx StringDedupTable::_rehash_threshold = (uintx)(_rehash_multiple * _grow_load_factor);
uintx StringDedupTable::_entries_added = 0;
-uintx StringDedupTable::_entries_removed = 0;
+volatile uintx StringDedupTable::_entries_removed = 0;
uintx StringDedupTable::_resize_count = 0;
uintx StringDedupTable::_rehash_count = 0;
StringDedupTable* StringDedupTable::_resized_table = NULL;
StringDedupTable* StringDedupTable::_rehashed_table = NULL;
@@ -477,13 +477,13 @@
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;
+ assert_locked_or_safepoint_weak(StringDedupTable_lock);
+ Atomic::sub(&_table->_entries, removed);
+ Atomic::add(&_entries_removed, removed);
}
}
uintx StringDedupTable::unlink_or_oops_do(StringDedupUnlinkOrOopsDoClosure* cl,
size_t partition_begin,
< prev index next >