author | tschatzl |
Wed, 18 Apr 2018 11:36:48 +0200 | |
changeset 49806 | 2d62570a615c |
parent 49592 | 77fb0be7d19f |
permissions | -rw-r--r-- |
23472 | 1 |
/* |
47647
64dba69fc528
8189276: Make SuspendibleThreadSet and related code available to other GCs
rkennke
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. |
23472 | 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" |
|
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
26 |
#include "classfile/stringTable.hpp" |
30764 | 27 |
#include "gc/g1/g1StringDedup.hpp" |
28 |
#include "gc/g1/g1StringDedupQueue.hpp" |
|
29 |
#include "gc/g1/g1StringDedupTable.hpp" |
|
30 |
#include "gc/g1/g1StringDedupThread.hpp" |
|
47647
64dba69fc528
8189276: Make SuspendibleThreadSet and related code available to other GCs
rkennke
parents:
47216
diff
changeset
|
31 |
#include "gc/shared/suspendibleThreadSet.hpp" |
35061 | 32 |
#include "logging/log.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47647
diff
changeset
|
33 |
#include "oops/access.inline.hpp" |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
34 |
#include "oops/oop.inline.hpp" |
40655
9f644073d3a0
8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents:
39690
diff
changeset
|
35 |
#include "runtime/atomic.hpp" |
23472 | 36 |
|
37 |
G1StringDedupThread* G1StringDedupThread::_thread = NULL; |
|
38 |
||
39 |
G1StringDedupThread::G1StringDedupThread() : |
|
40 |
ConcurrentGCThread() { |
|
29464
02c245ad3ec9
8073545: Use shorter and more descriptive names for GC worker threads
david
parents:
25351
diff
changeset
|
41 |
set_name("G1 StrDedup"); |
23472 | 42 |
create_and_start(); |
43 |
} |
|
44 |
||
45 |
G1StringDedupThread::~G1StringDedupThread() { |
|
46 |
ShouldNotReachHere(); |
|
47 |
} |
|
48 |
||
49 |
void G1StringDedupThread::create() { |
|
50 |
assert(G1StringDedup::is_enabled(), "String deduplication not enabled"); |
|
51 |
assert(_thread == NULL, "One string deduplication thread allowed"); |
|
52 |
_thread = new G1StringDedupThread(); |
|
53 |
} |
|
54 |
||
55 |
G1StringDedupThread* G1StringDedupThread::thread() { |
|
56 |
assert(G1StringDedup::is_enabled(), "String deduplication not enabled"); |
|
57 |
assert(_thread != NULL, "String deduplication thread not created"); |
|
58 |
return _thread; |
|
59 |
} |
|
60 |
||
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
61 |
class G1StringDedupSharedClosure: public OopClosure { |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
62 |
private: |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
63 |
G1StringDedupStat& _stat; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
64 |
|
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
65 |
public: |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
66 |
G1StringDedupSharedClosure(G1StringDedupStat& stat) : _stat(stat) {} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
67 |
|
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
68 |
virtual void do_oop(oop* p) { ShouldNotReachHere(); } |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
69 |
virtual void do_oop(narrowOop* p) { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47647
diff
changeset
|
70 |
oop java_string = RawAccess<>::oop_load(p); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
71 |
G1StringDedupTable::deduplicate(java_string, _stat); |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
72 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
73 |
}; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
74 |
|
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
75 |
// The CDS archive does not include the string dedupication table. Only the string |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
76 |
// table is saved in the archive. The shared strings from CDS archive need to be |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
77 |
// added to the string dedupication table before deduplication occurs. That is |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
78 |
// done in the begining of the G1StringDedupThread (see G1StringDedupThread::run() |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
79 |
// below). |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
80 |
void G1StringDedupThread::deduplicate_shared_strings(G1StringDedupStat& stat) { |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
81 |
G1StringDedupSharedClosure sharedStringDedup(stat); |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
82 |
StringTable::shared_oops_do(&sharedStringDedup); |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
83 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
84 |
|
37081
7656f5356a5d
8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents:
35061
diff
changeset
|
85 |
void G1StringDedupThread::run_service() { |
23472 | 86 |
G1StringDedupStat total_stat; |
87 |
||
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30770
diff
changeset
|
88 |
deduplicate_shared_strings(total_stat); |
23472 | 89 |
|
90 |
// Main loop |
|
91 |
for (;;) { |
|
92 |
G1StringDedupStat stat; |
|
93 |
||
94 |
stat.mark_idle(); |
|
95 |
||
96 |
// Wait for the queue to become non-empty |
|
97 |
G1StringDedupQueue::wait(); |
|
37081
7656f5356a5d
8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents:
35061
diff
changeset
|
98 |
if (should_terminate()) { |
24093
095cc0a63ed9
8037112: gc/g1/TestHumongousAllocInitialMark.java caused SIGSEGV
pliden
parents:
23472
diff
changeset
|
99 |
break; |
095cc0a63ed9
8037112: gc/g1/TestHumongousAllocInitialMark.java caused SIGSEGV
pliden
parents:
23472
diff
changeset
|
100 |
} |
23472 | 101 |
|
24094 | 102 |
{ |
103 |
// Include thread in safepoints |
|
30613
a7815bb05ae2
8079579: Add SuspendibleThreadSetLeaver and make SuspendibleThreadSet::joint()/leave() private
pliden
parents:
29464
diff
changeset
|
104 |
SuspendibleThreadSetJoiner sts_join; |
23472 | 105 |
|
24094 | 106 |
stat.mark_exec(); |
39690
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
107 |
print_start(stat); |
23472 | 108 |
|
24094 | 109 |
// Process the queue |
110 |
for (;;) { |
|
111 |
oop java_string = G1StringDedupQueue::pop(); |
|
112 |
if (java_string == NULL) { |
|
113 |
break; |
|
114 |
} |
|
115 |
||
116 |
G1StringDedupTable::deduplicate(java_string, stat); |
|
117 |
||
118 |
// Safepoint this thread if needed |
|
30613
a7815bb05ae2
8079579: Add SuspendibleThreadSetLeaver and make SuspendibleThreadSet::joint()/leave() private
pliden
parents:
29464
diff
changeset
|
119 |
if (sts_join.should_yield()) { |
24094 | 120 |
stat.mark_block(); |
30613
a7815bb05ae2
8079579: Add SuspendibleThreadSetLeaver and make SuspendibleThreadSet::joint()/leave() private
pliden
parents:
29464
diff
changeset
|
121 |
sts_join.yield(); |
24094 | 122 |
stat.mark_unblock(); |
123 |
} |
|
23472 | 124 |
} |
125 |
||
24094 | 126 |
stat.mark_done(); |
23472 | 127 |
|
24094 | 128 |
total_stat.add(stat); |
39690
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
129 |
print_end(stat, total_stat); |
24094 | 130 |
} |
39452
eebe070746ad
8158871: Long response times with G1 and StringDeduplication
pliden
parents:
37081
diff
changeset
|
131 |
|
eebe070746ad
8158871: Long response times with G1 and StringDeduplication
pliden
parents:
37081
diff
changeset
|
132 |
G1StringDedupTable::clean_entry_cache(); |
23472 | 133 |
} |
24093
095cc0a63ed9
8037112: gc/g1/TestHumongousAllocInitialMark.java caused SIGSEGV
pliden
parents:
23472
diff
changeset
|
134 |
} |
095cc0a63ed9
8037112: gc/g1/TestHumongousAllocInitialMark.java caused SIGSEGV
pliden
parents:
23472
diff
changeset
|
135 |
|
37081
7656f5356a5d
8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents:
35061
diff
changeset
|
136 |
void G1StringDedupThread::stop_service() { |
24093
095cc0a63ed9
8037112: gc/g1/TestHumongousAllocInitialMark.java caused SIGSEGV
pliden
parents:
23472
diff
changeset
|
137 |
G1StringDedupQueue::cancel_wait(); |
23472 | 138 |
} |
139 |
||
39690
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
140 |
void G1StringDedupThread::print_start(const G1StringDedupStat& last_stat) { |
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
141 |
G1StringDedupStat::print_start(last_stat); |
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
142 |
} |
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
143 |
|
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
144 |
void G1StringDedupThread::print_end(const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) { |
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
145 |
G1StringDedupStat::print_end(last_stat, total_stat); |
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
146 |
if (log_is_enabled(Debug, gc, stringdedup)) { |
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
147 |
G1StringDedupStat::print_statistics(last_stat, false); |
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
148 |
G1StringDedupStat::print_statistics(total_stat, true); |
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
149 |
G1StringDedupTable::print_statistics(); |
09a3ee292336
8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents:
39452
diff
changeset
|
150 |
G1StringDedupQueue::print_statistics(); |
23472 | 151 |
} |
152 |
} |