21 * questions. |
21 * questions. |
22 * |
22 * |
23 */ |
23 */ |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
|
26 #include "classfile/stringTable.hpp" |
26 #include "gc/g1/g1Log.hpp" |
27 #include "gc/g1/g1Log.hpp" |
27 #include "gc/g1/g1StringDedup.hpp" |
28 #include "gc/g1/g1StringDedup.hpp" |
28 #include "gc/g1/g1StringDedupQueue.hpp" |
29 #include "gc/g1/g1StringDedupQueue.hpp" |
29 #include "gc/g1/g1StringDedupTable.hpp" |
30 #include "gc/g1/g1StringDedupTable.hpp" |
30 #include "gc/g1/g1StringDedupThread.hpp" |
31 #include "gc/g1/g1StringDedupThread.hpp" |
31 #include "gc/g1/suspendibleThreadSet.hpp" |
32 #include "gc/g1/suspendibleThreadSet.hpp" |
|
33 #include "oops/oop.inline.hpp" |
32 #include "runtime/atomic.inline.hpp" |
34 #include "runtime/atomic.inline.hpp" |
33 |
35 |
34 G1StringDedupThread* G1StringDedupThread::_thread = NULL; |
36 G1StringDedupThread* G1StringDedupThread::_thread = NULL; |
35 |
37 |
36 G1StringDedupThread::G1StringDedupThread() : |
38 G1StringDedupThread::G1StringDedupThread() : |
53 assert(G1StringDedup::is_enabled(), "String deduplication not enabled"); |
55 assert(G1StringDedup::is_enabled(), "String deduplication not enabled"); |
54 assert(_thread != NULL, "String deduplication thread not created"); |
56 assert(_thread != NULL, "String deduplication thread not created"); |
55 return _thread; |
57 return _thread; |
56 } |
58 } |
57 |
59 |
|
60 class G1StringDedupSharedClosure: public OopClosure { |
|
61 private: |
|
62 G1StringDedupStat& _stat; |
|
63 |
|
64 public: |
|
65 G1StringDedupSharedClosure(G1StringDedupStat& stat) : _stat(stat) {} |
|
66 |
|
67 virtual void do_oop(oop* p) { ShouldNotReachHere(); } |
|
68 virtual void do_oop(narrowOop* p) { |
|
69 oop java_string = oopDesc::load_decode_heap_oop(p); |
|
70 G1StringDedupTable::deduplicate(java_string, _stat); |
|
71 } |
|
72 }; |
|
73 |
|
74 // The CDS archive does not include the string dedupication table. Only the string |
|
75 // table is saved in the archive. The shared strings from CDS archive need to be |
|
76 // added to the string dedupication table before deduplication occurs. That is |
|
77 // done in the begining of the G1StringDedupThread (see G1StringDedupThread::run() |
|
78 // below). |
|
79 void G1StringDedupThread::deduplicate_shared_strings(G1StringDedupStat& stat) { |
|
80 G1StringDedupSharedClosure sharedStringDedup(stat); |
|
81 StringTable::shared_oops_do(&sharedStringDedup); |
|
82 } |
|
83 |
58 void G1StringDedupThread::run() { |
84 void G1StringDedupThread::run() { |
59 G1StringDedupStat total_stat; |
85 G1StringDedupStat total_stat; |
60 |
86 |
61 initialize_in_thread(); |
87 initialize_in_thread(); |
62 wait_for_universe_init(); |
88 wait_for_universe_init(); |
|
89 deduplicate_shared_strings(total_stat); |
63 |
90 |
64 // Main loop |
91 // Main loop |
65 for (;;) { |
92 for (;;) { |
66 G1StringDedupStat stat; |
93 G1StringDedupStat stat; |
67 |
94 |