| 1 | /* | 
|---|
| 2 | * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. | 
|---|
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 
|---|
| 4 | * | 
|---|
| 5 | * This code is free software; you can redistribute it and/or modify it | 
|---|
| 6 | * under the terms of the GNU General Public License version 2 only, as | 
|---|
| 7 | * published by the Free Software Foundation. | 
|---|
| 8 | * | 
|---|
| 9 | * This code is distributed in the hope that it will be useful, but WITHOUT | 
|---|
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 
|---|
| 11 | * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License | 
|---|
| 12 | * version 2 for more details (a copy is included in the LICENSE file that | 
|---|
| 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 |  | 
|---|
| 27 | #include "gc/g1/g1CollectedHeap.inline.hpp" | 
|---|
| 28 | #include "gc/g1/g1StringDedupStat.hpp" | 
|---|
| 29 | #include "logging/log.hpp" | 
|---|
| 30 |  | 
|---|
| 31 | G1StringDedupStat::G1StringDedupStat() : StringDedupStat(), | 
|---|
| 32 | _deduped_young(0), | 
|---|
| 33 | _deduped_young_bytes(0), | 
|---|
| 34 | _deduped_old(0), | 
|---|
| 35 | _deduped_old_bytes(0), | 
|---|
| 36 | _heap(G1CollectedHeap::heap()) { | 
|---|
| 37 | } | 
|---|
| 38 |  | 
|---|
| 39 |  | 
|---|
| 40 |  | 
|---|
| 41 | void G1StringDedupStat::deduped(oop obj, uintx bytes) { | 
|---|
| 42 | StringDedupStat::deduped(obj, bytes); | 
|---|
| 43 | if (_heap->is_in_young(obj)) { | 
|---|
| 44 | _deduped_young ++; | 
|---|
| 45 | _deduped_young_bytes += bytes; | 
|---|
| 46 | } else { | 
|---|
| 47 | _deduped_old ++; | 
|---|
| 48 | _deduped_old_bytes += bytes; | 
|---|
| 49 | } | 
|---|
| 50 | } | 
|---|
| 51 |  | 
|---|
| 52 | void G1StringDedupStat::add(const StringDedupStat* const stat) { | 
|---|
| 53 | StringDedupStat::add(stat); | 
|---|
| 54 | const G1StringDedupStat* const g1_stat = (const G1StringDedupStat* const)stat; | 
|---|
| 55 | _deduped_young += g1_stat->_deduped_young; | 
|---|
| 56 | _deduped_young_bytes += g1_stat->_deduped_young_bytes; | 
|---|
| 57 | _deduped_old += g1_stat->_deduped_old; | 
|---|
| 58 | _deduped_old_bytes += g1_stat->_deduped_old_bytes; | 
|---|
| 59 | } | 
|---|
| 60 |  | 
|---|
| 61 | void G1StringDedupStat::print_statistics(bool total) const { | 
|---|
| 62 | StringDedupStat::print_statistics(total); | 
|---|
| 63 |  | 
|---|
| 64 | double deduped_young_percent       = percent_of(_deduped_young, _deduped); | 
|---|
| 65 | double deduped_young_bytes_percent = percent_of(_deduped_young_bytes, _deduped_bytes); | 
|---|
| 66 | double deduped_old_percent         = percent_of(_deduped_old, _deduped); | 
|---|
| 67 | double deduped_old_bytes_percent   = percent_of(_deduped_old_bytes, _deduped_bytes); | 
|---|
| 68 |  | 
|---|
| 69 | log_debug(gc, stringdedup)( "      Young:      "STRDEDUP_OBJECTS_FORMAT "("STRDEDUP_PERCENT_FORMAT ") "STRDEDUP_BYTES_FORMAT "("STRDEDUP_PERCENT_FORMAT ")", | 
|---|
| 70 | _deduped_young, deduped_young_percent, STRDEDUP_BYTES_PARAM(_deduped_young_bytes), deduped_young_bytes_percent); | 
|---|
| 71 | log_debug(gc, stringdedup)( "      Old:        "STRDEDUP_OBJECTS_FORMAT "("STRDEDUP_PERCENT_FORMAT ") "STRDEDUP_BYTES_FORMAT "("STRDEDUP_PERCENT_FORMAT ")", | 
|---|
| 72 | _deduped_old, deduped_old_percent, STRDEDUP_BYTES_PARAM(_deduped_old_bytes), deduped_old_bytes_percent); | 
|---|
| 73 |  | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|
| 76 | void G1StringDedupStat::reset() { | 
|---|
| 77 | StringDedupStat::reset(); | 
|---|
| 78 | _deduped_young = 0; | 
|---|
| 79 | _deduped_young_bytes = 0; | 
|---|
| 80 | _deduped_old = 0; | 
|---|
| 81 | _deduped_old_bytes = 0; | 
|---|
| 82 | } | 
|---|
| 83 |  | 
|---|