13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/altHashing.hpp"
27 #include "classfile/javaClasses.inline.hpp"
28 #include "gc/g1/g1CollectedHeap.inline.hpp"
29 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
30 #include "gc/g1/g1StringDedup.hpp"
31 #include "gc/g1/g1StringDedupTable.hpp"
32 #include "gc/shared/gcLocker.hpp"
33 #include "memory/padded.inline.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "oops/typeArrayOop.hpp"
36 #include "runtime/mutexLocker.hpp"
37
38 //
39 // Freelist in the deduplication table entry cache. Links table
40 // entries together using their _next fields.
41 //
42 class G1StringDedupEntryFreeList : public CHeapObj<mtGC> {
43 private:
44 G1StringDedupEntry* _list;
45 size_t _length;
46
47 public:
48 G1StringDedupEntryFreeList() :
49 _list(NULL),
50 _length(0) {
51 }
52
536 G1StringDedupEntry** entry1 = _table->bucket(bucket);
537 while (*entry1 != NULL) {
538 typeArrayOop value1 = (*entry1)->obj();
539 G1StringDedupEntry** entry2 = (*entry1)->next_addr();
540 while (*entry2 != NULL) {
541 typeArrayOop value2 = (*entry2)->obj();
542 guarantee(!equals(value1, value2), "Table entries must not have identical arrays");
543 entry2 = (*entry2)->next_addr();
544 }
545 entry1 = (*entry1)->next_addr();
546 }
547 }
548 }
549
550 void G1StringDedupTable::trim_entry_cache() {
551 MutexLockerEx ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag);
552 size_t max_cache_size = (size_t)(_table->_size * _max_cache_factor);
553 _entry_cache->trim(max_cache_size);
554 }
555
556 void G1StringDedupTable::print_statistics(outputStream* st) {
557 st->print_cr(
558 " [Table]\n"
559 " [Memory Usage: " G1_STRDEDUP_BYTES_FORMAT_NS "]\n"
560 " [Size: " SIZE_FORMAT ", Min: " SIZE_FORMAT ", Max: " SIZE_FORMAT "]\n"
561 " [Entries: " UINTX_FORMAT ", Load: " G1_STRDEDUP_PERCENT_FORMAT_NS ", Cached: " UINTX_FORMAT ", Added: " UINTX_FORMAT ", Removed: " UINTX_FORMAT "]\n"
562 " [Resize Count: " UINTX_FORMAT ", Shrink Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS "), Grow Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS ")]\n"
563 " [Rehash Count: " UINTX_FORMAT ", Rehash Threshold: " UINTX_FORMAT ", Hash Seed: 0x%x]\n"
564 " [Age Threshold: " UINTX_FORMAT "]",
565 G1_STRDEDUP_BYTES_PARAM(_table->_size * sizeof(G1StringDedupEntry*) + (_table->_entries + _entry_cache->size()) * sizeof(G1StringDedupEntry)),
566 _table->_size, _min_size, _max_size,
567 _table->_entries, (double)_table->_entries / (double)_table->_size * 100.0, _entry_cache->size(), _entries_added, _entries_removed,
568 _resize_count, _table->_shrink_threshold, _shrink_load_factor * 100.0, _table->_grow_threshold, _grow_load_factor * 100.0,
569 _rehash_count, _rehash_threshold, _table->_hash_seed,
570 StringDeduplicationAgeThreshold);
571 }
|
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/altHashing.hpp"
27 #include "classfile/javaClasses.inline.hpp"
28 #include "gc/g1/g1CollectedHeap.inline.hpp"
29 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
30 #include "gc/g1/g1StringDedup.hpp"
31 #include "gc/g1/g1StringDedupTable.hpp"
32 #include "gc/shared/gcLocker.hpp"
33 #include "logging/log.hpp"
34 #include "memory/padded.inline.hpp"
35 #include "oops/oop.inline.hpp"
36 #include "oops/typeArrayOop.hpp"
37 #include "runtime/mutexLocker.hpp"
38
39 //
40 // Freelist in the deduplication table entry cache. Links table
41 // entries together using their _next fields.
42 //
43 class G1StringDedupEntryFreeList : public CHeapObj<mtGC> {
44 private:
45 G1StringDedupEntry* _list;
46 size_t _length;
47
48 public:
49 G1StringDedupEntryFreeList() :
50 _list(NULL),
51 _length(0) {
52 }
53
537 G1StringDedupEntry** entry1 = _table->bucket(bucket);
538 while (*entry1 != NULL) {
539 typeArrayOop value1 = (*entry1)->obj();
540 G1StringDedupEntry** entry2 = (*entry1)->next_addr();
541 while (*entry2 != NULL) {
542 typeArrayOop value2 = (*entry2)->obj();
543 guarantee(!equals(value1, value2), "Table entries must not have identical arrays");
544 entry2 = (*entry2)->next_addr();
545 }
546 entry1 = (*entry1)->next_addr();
547 }
548 }
549 }
550
551 void G1StringDedupTable::trim_entry_cache() {
552 MutexLockerEx ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag);
553 size_t max_cache_size = (size_t)(_table->_size * _max_cache_factor);
554 _entry_cache->trim(max_cache_size);
555 }
556
557 void G1StringDedupTable::print_statistics() {
558 log_trace(gc, stringdedup)(
559 " [Table]\n"
560 " [Memory Usage: " G1_STRDEDUP_BYTES_FORMAT_NS "]\n"
561 " [Size: " SIZE_FORMAT ", Min: " SIZE_FORMAT ", Max: " SIZE_FORMAT "]\n"
562 " [Entries: " UINTX_FORMAT ", Load: " G1_STRDEDUP_PERCENT_FORMAT_NS ", Cached: " UINTX_FORMAT ", Added: " UINTX_FORMAT ", Removed: " UINTX_FORMAT "]\n"
563 " [Resize Count: " UINTX_FORMAT ", Shrink Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS "), Grow Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS ")]\n"
564 " [Rehash Count: " UINTX_FORMAT ", Rehash Threshold: " UINTX_FORMAT ", Hash Seed: 0x%x]\n"
565 " [Age Threshold: " UINTX_FORMAT "]",
566 G1_STRDEDUP_BYTES_PARAM(_table->_size * sizeof(G1StringDedupEntry*) + (_table->_entries + _entry_cache->size()) * sizeof(G1StringDedupEntry)),
567 _table->_size, _min_size, _max_size,
568 _table->_entries, (double)_table->_entries / (double)_table->_size * 100.0, _entry_cache->size(), _entries_added, _entries_removed,
569 _resize_count, _table->_shrink_threshold, _shrink_load_factor * 100.0, _table->_grow_threshold, _grow_load_factor * 100.0,
570 _rehash_count, _rehash_threshold, _table->_hash_seed,
571 StringDeduplicationAgeThreshold);
572 }
|