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 "gc/g1/g1OopClosures.inline.hpp"
27 #include "gc/g1/g1RootClosures.hpp"
28 #include "gc/g1/g1SharedClosures.hpp"
29
30 // Closures used for standard G1 evacuation.
31 class G1EvacuationClosures : public G1EvacuationRootClosures {
32 G1SharedClosures<G1MarkNone> _closures;
33
34 public:
35 G1EvacuationClosures(G1CollectedHeap* g1h,
36 G1ParScanThreadState* pss,
37 bool in_young_gc) :
38 _closures(g1h, pss, in_young_gc, /* cld_claim */ ClassLoaderData::_claim_none) {}
39
40 OopClosure* weak_oops() { return &_closures._oops; }
41 OopClosure* strong_oops() { return &_closures._oops; }
42
43 CLDClosure* weak_clds() { return &_closures._clds; }
44 CLDClosure* strong_clds() { return &_closures._clds; }
45 CLDClosure* second_pass_weak_clds() { return NULL; }
46
47 CodeBlobClosure* strong_codeblobs() { return &_closures._codeblobs; }
48 CodeBlobClosure* weak_codeblobs() { return &_closures._codeblobs; }
49
50 bool trace_metadata() { return false; }
51 };
52
53 // Closures used during initial mark.
54 // The treatment of "weak" roots is selectable through the template parameter,
55 // this is usually used to control unloading of classes and interned strings.
56 template <G1Mark MarkWeak>
57 class G1InitialMarkClosures : public G1EvacuationRootClosures {
58 G1SharedClosures<G1MarkFromRoot> _strong;
59 G1SharedClosures<MarkWeak> _weak;
60
61 // Filter method to help with returning the appropriate closures
62 // depending on the class template parameter.
63 template <G1Mark Mark, typename T>
64 T* null_if(T* t) {
65 if (Mark == MarkWeak) {
66 return NULL;
67 }
68 return t;
69 }
70
71 public:
72 G1InitialMarkClosures(G1CollectedHeap* g1h,
73 G1ParScanThreadState* pss) :
74 _strong(g1h, pss, /* process_only_dirty_klasses */ false, /* cld_claim */ ClassLoaderData::_claim_strong),
75 _weak(g1h, pss, /* process_only_dirty_klasses */ false, /* cld_claim */ ClassLoaderData::_claim_strong) {}
76
77 OopClosure* weak_oops() { return &_weak._oops; }
78 OopClosure* strong_oops() { return &_strong._oops; }
79
80 // If MarkWeak is G1MarkPromotedFromRoot then the weak CLDs must be processed in a second pass.
81 CLDClosure* weak_clds() { return null_if<G1MarkPromotedFromRoot>(&_weak._clds); }
82 CLDClosure* strong_clds() { return &_strong._clds; }
83
84 // If MarkWeak is G1MarkFromRoot then all CLDs are processed by the weak and strong variants
85 // return a NULL closure for the following specialized versions in that case.
86 CLDClosure* second_pass_weak_clds() { return null_if<G1MarkFromRoot>(&_weak._clds); }
87
88 CodeBlobClosure* strong_codeblobs() { return &_strong._codeblobs; }
89 CodeBlobClosure* weak_codeblobs() { return &_weak._codeblobs; }
90
91 // If we are not marking all weak roots then we are tracing
92 // which metadata is alive.
93 bool trace_metadata() { return MarkWeak == G1MarkPromotedFromRoot; }
94 };
95
96 G1EvacuationRootClosures* G1EvacuationRootClosures::create_root_closures(G1ParScanThreadState* pss, G1CollectedHeap* g1h) {
97 G1EvacuationRootClosures* res = NULL;
98 if (g1h->collector_state()->in_initial_mark_gc()) {
99 if (ClassUnloadingWithConcurrentMark) {
100 res = new G1InitialMarkClosures<G1MarkPromotedFromRoot>(g1h, pss);
101 } else {
102 res = new G1InitialMarkClosures<G1MarkFromRoot>(g1h, pss);
103 }
104 } else {
105 res = new G1EvacuationClosures(g1h, pss, g1h->collector_state()->in_young_only_phase());
106 }
|
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 "gc/g1/g1OopClosures.inline.hpp"
27 #include "gc/g1/g1RootClosures.hpp"
28 #include "gc/g1/g1SharedClosures.hpp"
29
30 // Closures used for standard G1 evacuation.
31 class G1EvacuationClosures : public G1EvacuationRootClosures {
32 G1SharedClosures<G1MarkNone> _closures;
33
34 public:
35 G1EvacuationClosures(G1CollectedHeap* g1h,
36 G1ParScanThreadState* pss,
37 bool in_young_gc) :
38 _closures(g1h, pss, in_young_gc) {}
39
40 OopClosure* weak_oops() { return &_closures._oops; }
41 OopClosure* strong_oops() { return &_closures._oops; }
42
43 CLDClosure* weak_clds() { return &_closures._clds; }
44 CLDClosure* strong_clds() { return &_closures._clds; }
45
46 CodeBlobClosure* strong_codeblobs() { return &_closures._codeblobs; }
47 CodeBlobClosure* weak_codeblobs() { return &_closures._codeblobs; }
48
49 bool trace_metadata() { return false; }
50 };
51
52 // Closures used during initial mark.
53 // The treatment of "weak" roots is selectable through the template parameter,
54 // this is usually used to control unloading of classes and interned strings.
55 template <G1Mark MarkWeak>
56 class G1InitialMarkClosures : public G1EvacuationRootClosures {
57 G1SharedClosures<G1MarkFromRoot> _strong;
58 G1SharedClosures<MarkWeak> _weak;
59
60 public:
61 G1InitialMarkClosures(G1CollectedHeap* g1h,
62 G1ParScanThreadState* pss) :
63 _strong(g1h, pss, /* process_only_dirty_klasses */ false),
64 _weak(g1h, pss, /* process_only_dirty_klasses */ false) {}
65
66 OopClosure* weak_oops() { return &_weak._oops; }
67 OopClosure* strong_oops() { return &_strong._oops; }
68
69 CLDClosure* weak_clds() { return &_weak._clds; }
70 CLDClosure* strong_clds() { return &_strong._clds; }
71
72 CodeBlobClosure* strong_codeblobs() { return &_strong._codeblobs; }
73 CodeBlobClosure* weak_codeblobs() { return &_weak._codeblobs; }
74
75 // If we are not marking all weak roots then we are tracing
76 // which metadata is alive.
77 bool trace_metadata() { return MarkWeak == G1MarkPromotedFromRoot; }
78 };
79
80 G1EvacuationRootClosures* G1EvacuationRootClosures::create_root_closures(G1ParScanThreadState* pss, G1CollectedHeap* g1h) {
81 G1EvacuationRootClosures* res = NULL;
82 if (g1h->collector_state()->in_initial_mark_gc()) {
83 if (ClassUnloadingWithConcurrentMark) {
84 res = new G1InitialMarkClosures<G1MarkPromotedFromRoot>(g1h, pss);
85 } else {
86 res = new G1InitialMarkClosures<G1MarkFromRoot>(g1h, pss);
87 }
88 } else {
89 res = new G1EvacuationClosures(g1h, pss, g1h->collector_state()->in_young_only_phase());
90 }
|