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 #include "classfile/stringTable.hpp"
27 #include "gc/g1/g1Log.hpp"
28 #include "gc/g1/g1StringDedup.hpp"
29 #include "gc/g1/g1StringDedupQueue.hpp"
30 #include "gc/g1/g1StringDedupTable.hpp"
31 #include "gc/g1/g1StringDedupThread.hpp"
32 #include "gc/g1/suspendibleThreadSet.hpp"
33 #include "oops/oop.inline.hpp"
34 #include "runtime/atomic.inline.hpp"
35
36 G1StringDedupThread* G1StringDedupThread::_thread = NULL;
37
38 G1StringDedupThread::G1StringDedupThread() :
39 ConcurrentGCThread() {
40 set_name("G1 StrDedup");
41 create_and_start();
42 }
43
44 G1StringDedupThread::~G1StringDedupThread() {
45 ShouldNotReachHere();
46 }
47
48 void G1StringDedupThread::create() {
49 assert(G1StringDedup::is_enabled(), "String deduplication not enabled");
50 assert(_thread == NULL, "One string deduplication thread allowed");
51 _thread = new G1StringDedupThread();
52 }
112 if (java_string == NULL) {
113 break;
114 }
115
116 G1StringDedupTable::deduplicate(java_string, stat);
117
118 // Safepoint this thread if needed
119 if (sts_join.should_yield()) {
120 stat.mark_block();
121 sts_join.yield();
122 stat.mark_unblock();
123 }
124 }
125
126 G1StringDedupTable::trim_entry_cache();
127
128 stat.mark_done();
129
130 // Print statistics
131 total_stat.add(stat);
132 print(gclog_or_tty, stat, total_stat);
133 }
134 }
135
136 terminate();
137 }
138
139 void G1StringDedupThread::stop() {
140 {
141 MonitorLockerEx ml(Terminator_lock);
142 _thread->_should_terminate = true;
143 }
144
145 G1StringDedupQueue::cancel_wait();
146
147 {
148 MonitorLockerEx ml(Terminator_lock);
149 while (!_thread->_has_terminated) {
150 ml.wait();
151 }
152 }
153 }
154
155 void G1StringDedupThread::print(outputStream* st, const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) {
156 if (G1Log::fine() || PrintStringDeduplicationStatistics) {
157 G1StringDedupStat::print_summary(st, last_stat, total_stat);
158 if (PrintStringDeduplicationStatistics) {
159 G1StringDedupStat::print_statistics(st, last_stat, false);
160 G1StringDedupStat::print_statistics(st, total_stat, true);
161 G1StringDedupTable::print_statistics(st);
162 G1StringDedupQueue::print_statistics(st);
163 }
164 }
165 }
|
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 #include "classfile/stringTable.hpp"
27 #include "gc/g1/g1StringDedup.hpp"
28 #include "gc/g1/g1StringDedupQueue.hpp"
29 #include "gc/g1/g1StringDedupTable.hpp"
30 #include "gc/g1/g1StringDedupThread.hpp"
31 #include "gc/g1/suspendibleThreadSet.hpp"
32 #include "logging/log.hpp"
33 #include "oops/oop.inline.hpp"
34 #include "runtime/atomic.inline.hpp"
35
36 G1StringDedupThread* G1StringDedupThread::_thread = NULL;
37
38 G1StringDedupThread::G1StringDedupThread() :
39 ConcurrentGCThread() {
40 set_name("G1 StrDedup");
41 create_and_start();
42 }
43
44 G1StringDedupThread::~G1StringDedupThread() {
45 ShouldNotReachHere();
46 }
47
48 void G1StringDedupThread::create() {
49 assert(G1StringDedup::is_enabled(), "String deduplication not enabled");
50 assert(_thread == NULL, "One string deduplication thread allowed");
51 _thread = new G1StringDedupThread();
52 }
112 if (java_string == NULL) {
113 break;
114 }
115
116 G1StringDedupTable::deduplicate(java_string, stat);
117
118 // Safepoint this thread if needed
119 if (sts_join.should_yield()) {
120 stat.mark_block();
121 sts_join.yield();
122 stat.mark_unblock();
123 }
124 }
125
126 G1StringDedupTable::trim_entry_cache();
127
128 stat.mark_done();
129
130 // Print statistics
131 total_stat.add(stat);
132 print(stat, total_stat);
133 }
134 }
135
136 terminate();
137 }
138
139 void G1StringDedupThread::stop() {
140 {
141 MonitorLockerEx ml(Terminator_lock);
142 _thread->_should_terminate = true;
143 }
144
145 G1StringDedupQueue::cancel_wait();
146
147 {
148 MonitorLockerEx ml(Terminator_lock);
149 while (!_thread->_has_terminated) {
150 ml.wait();
151 }
152 }
153 }
154
155 void G1StringDedupThread::print(const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) {
156 if (log_is_enabled(Info, gc, stringdedup)) {
157 G1StringDedupStat::print_summary(last_stat, total_stat);
158 if (log_is_enabled(Debug, gc, stringdedup)) {
159 G1StringDedupStat::print_statistics(last_stat, false);
160 G1StringDedupStat::print_statistics(total_stat, true);
161 G1StringDedupTable::print_statistics();
162 G1StringDedupQueue::print_statistics();
163 }
164 }
165 }
|