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
551 typeArrayOop value1 = (*entry1)->obj();
552 bool latin1_1 = (*entry1)->latin1();
553 G1StringDedupEntry** entry2 = (*entry1)->next_addr();
554 while (*entry2 != NULL) {
555 typeArrayOop value2 = (*entry2)->obj();
556 bool latin1_2 = (*entry2)->latin1();
557 guarantee(latin1_1 != latin1_2 || !equals(value1, value2), "Table entries must not have identical arrays");
558 entry2 = (*entry2)->next_addr();
559 }
560 entry1 = (*entry1)->next_addr();
561 }
562 }
563 }
564
565 void G1StringDedupTable::trim_entry_cache() {
566 MutexLockerEx ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag);
567 size_t max_cache_size = (size_t)(_table->_size * _max_cache_factor);
568 _entry_cache->trim(max_cache_size);
569 }
570
571 void G1StringDedupTable::print_statistics(outputStream* st) {
572 st->print_cr(
573 " [Table]\n"
574 " [Memory Usage: " G1_STRDEDUP_BYTES_FORMAT_NS "]\n"
575 " [Size: " SIZE_FORMAT ", Min: " SIZE_FORMAT ", Max: " SIZE_FORMAT "]\n"
576 " [Entries: " UINTX_FORMAT ", Load: " G1_STRDEDUP_PERCENT_FORMAT_NS ", Cached: " UINTX_FORMAT ", Added: " UINTX_FORMAT ", Removed: " UINTX_FORMAT "]\n"
577 " [Resize Count: " UINTX_FORMAT ", Shrink Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS "), Grow Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS ")]\n"
578 " [Rehash Count: " UINTX_FORMAT ", Rehash Threshold: " UINTX_FORMAT ", Hash Seed: 0x%x]\n"
579 " [Age Threshold: " UINTX_FORMAT "]",
580 G1_STRDEDUP_BYTES_PARAM(_table->_size * sizeof(G1StringDedupEntry*) + (_table->_entries + _entry_cache->size()) * sizeof(G1StringDedupEntry)),
581 _table->_size, _min_size, _max_size,
582 _table->_entries, (double)_table->_entries / (double)_table->_size * 100.0, _entry_cache->size(), _entries_added, _entries_removed,
583 _resize_count, _table->_shrink_threshold, _shrink_load_factor * 100.0, _table->_grow_threshold, _grow_load_factor * 100.0,
584 _rehash_count, _rehash_threshold, _table->_hash_seed,
585 StringDeduplicationAgeThreshold);
586 }
|
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
552 typeArrayOop value1 = (*entry1)->obj();
553 bool latin1_1 = (*entry1)->latin1();
554 G1StringDedupEntry** entry2 = (*entry1)->next_addr();
555 while (*entry2 != NULL) {
556 typeArrayOop value2 = (*entry2)->obj();
557 bool latin1_2 = (*entry2)->latin1();
558 guarantee(latin1_1 != latin1_2 || !equals(value1, value2), "Table entries must not have identical arrays");
559 entry2 = (*entry2)->next_addr();
560 }
561 entry1 = (*entry1)->next_addr();
562 }
563 }
564 }
565
566 void G1StringDedupTable::trim_entry_cache() {
567 MutexLockerEx ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag);
568 size_t max_cache_size = (size_t)(_table->_size * _max_cache_factor);
569 _entry_cache->trim(max_cache_size);
570 }
571
572 void G1StringDedupTable::print_statistics() {
573 log_trace(gc, stringdedup)(
574 " [Table]\n"
575 " [Memory Usage: " G1_STRDEDUP_BYTES_FORMAT_NS "]\n"
576 " [Size: " SIZE_FORMAT ", Min: " SIZE_FORMAT ", Max: " SIZE_FORMAT "]\n"
577 " [Entries: " UINTX_FORMAT ", Load: " G1_STRDEDUP_PERCENT_FORMAT_NS ", Cached: " UINTX_FORMAT ", Added: " UINTX_FORMAT ", Removed: " UINTX_FORMAT "]\n"
578 " [Resize Count: " UINTX_FORMAT ", Shrink Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS "), Grow Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS ")]\n"
579 " [Rehash Count: " UINTX_FORMAT ", Rehash Threshold: " UINTX_FORMAT ", Hash Seed: 0x%x]\n"
580 " [Age Threshold: " UINTX_FORMAT "]",
581 G1_STRDEDUP_BYTES_PARAM(_table->_size * sizeof(G1StringDedupEntry*) + (_table->_entries + _entry_cache->size()) * sizeof(G1StringDedupEntry)),
582 _table->_size, _min_size, _max_size,
583 _table->_entries, (double)_table->_entries / (double)_table->_size * 100.0, _entry_cache->size(), _entries_added, _entries_removed,
584 _resize_count, _table->_shrink_threshold, _shrink_load_factor * 100.0, _table->_grow_threshold, _grow_load_factor * 100.0,
585 _rehash_count, _rehash_threshold, _table->_hash_seed,
586 StringDeduplicationAgeThreshold);
587 }
|