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, /* must_claim_cld */ false) {}
39
40 OopClosure* weak_oops() { return &_closures._buffered_oops; }
41 OopClosure* strong_oops() { return &_closures._buffered_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 void flush() { _closures._buffered_oops.done(); }
51 double closure_app_seconds() { return _closures._buffered_oops.closure_app_seconds(); }
52
53 OopClosure* raw_strong_oops() { return &_closures._oops; }
54
55 bool trace_metadata() { return false; }
56 };
57
58 // Closures used during initial mark.
59 // The treatment of "weak" roots is selectable through the template parameter,
60 // this is usually used to control unloading of classes and interned strings.
61 template <G1Mark MarkWeak>
62 class G1InitialMarkClosures : public G1EvacuationRootClosures {
63 G1SharedClosures<G1MarkFromRoot> _strong;
64 G1SharedClosures<MarkWeak> _weak;
65
66 // Filter method to help with returning the appropriate closures
67 // depending on the class template parameter.
68 template <G1Mark Mark, typename T>
69 T* null_if(T* t) {
70 if (Mark == MarkWeak) {
71 return NULL;
72 }
73 return t;
74 }
75
76 public:
77 G1InitialMarkClosures(G1CollectedHeap* g1h,
78 G1ParScanThreadState* pss) :
79 _strong(g1h, pss, /* process_only_dirty_klasses */ false, /* must_claim_cld */ true),
80 _weak(g1h, pss, /* process_only_dirty_klasses */ false, /* must_claim_cld */ true) {}
81
82 OopClosure* weak_oops() { return &_weak._buffered_oops; }
83 OopClosure* strong_oops() { return &_strong._buffered_oops; }
84
85 // If MarkWeak is G1MarkPromotedFromRoot then the weak CLDs must be processed in a second pass.
86 CLDClosure* weak_clds() { return null_if<G1MarkPromotedFromRoot>(&_weak._clds); }
87 CLDClosure* strong_clds() { return &_strong._clds; }
88
89 // If MarkWeak is G1MarkFromRoot then all CLDs are processed by the weak and strong variants
90 // return a NULL closure for the following specialized versions in that case.
91 CLDClosure* second_pass_weak_clds() { return null_if<G1MarkFromRoot>(&_weak._clds); }
92
93 CodeBlobClosure* strong_codeblobs() { return &_strong._codeblobs; }
94 CodeBlobClosure* weak_codeblobs() { return &_weak._codeblobs; }
95
96 void flush() {
97 _strong._buffered_oops.done();
98 _weak._buffered_oops.done();
99 }
100
101 double closure_app_seconds() {
102 return _strong._buffered_oops.closure_app_seconds() +
103 _weak._buffered_oops.closure_app_seconds();
104 }
105
106 OopClosure* raw_strong_oops() { return &_strong._oops; }
107
108 // If we are not marking all weak roots then we are tracing
109 // which metadata is alive.
110 bool trace_metadata() { return MarkWeak == G1MarkPromotedFromRoot; }
111 };
112
113 G1EvacuationRootClosures* G1EvacuationRootClosures::create_root_closures(G1ParScanThreadState* pss, G1CollectedHeap* g1h) {
114 G1EvacuationRootClosures* res = NULL;
115 if (g1h->collector_state()->in_initial_mark_gc()) {
116 if (ClassUnloadingWithConcurrentMark) {
117 res = new G1InitialMarkClosures<G1MarkPromotedFromRoot>(g1h, pss);
118 } else {
119 res = new G1InitialMarkClosures<G1MarkFromRoot>(g1h, pss);
120 }
121 } else {
122 res = new G1EvacuationClosures(g1h, pss, g1h->collector_state()->in_young_only_phase());
123 }
124 return res;
|
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, /* must_claim_cld */ false) {}
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 OopClosure* raw_strong_oops() { return &_closures._oops; }
51
52 bool trace_metadata() { return false; }
53 };
54
55 // Closures used during initial mark.
56 // The treatment of "weak" roots is selectable through the template parameter,
57 // this is usually used to control unloading of classes and interned strings.
58 template <G1Mark MarkWeak>
59 class G1InitialMarkClosures : public G1EvacuationRootClosures {
60 G1SharedClosures<G1MarkFromRoot> _strong;
61 G1SharedClosures<MarkWeak> _weak;
62
63 // Filter method to help with returning the appropriate closures
64 // depending on the class template parameter.
65 template <G1Mark Mark, typename T>
66 T* null_if(T* t) {
67 if (Mark == MarkWeak) {
68 return NULL;
69 }
70 return t;
71 }
72
73 public:
74 G1InitialMarkClosures(G1CollectedHeap* g1h,
75 G1ParScanThreadState* pss) :
76 _strong(g1h, pss, /* process_only_dirty_klasses */ false, /* must_claim_cld */ true),
77 _weak(g1h, pss, /* process_only_dirty_klasses */ false, /* must_claim_cld */ true) {}
78
79 OopClosure* weak_oops() { return &_weak._oops; }
80 OopClosure* strong_oops() { return &_strong._oops; }
81
82 // If MarkWeak is G1MarkPromotedFromRoot then the weak CLDs must be processed in a second pass.
83 CLDClosure* weak_clds() { return null_if<G1MarkPromotedFromRoot>(&_weak._clds); }
84 CLDClosure* strong_clds() { return &_strong._clds; }
85
86 // If MarkWeak is G1MarkFromRoot then all CLDs are processed by the weak and strong variants
87 // return a NULL closure for the following specialized versions in that case.
88 CLDClosure* second_pass_weak_clds() { return null_if<G1MarkFromRoot>(&_weak._clds); }
89
90 CodeBlobClosure* strong_codeblobs() { return &_strong._codeblobs; }
91 CodeBlobClosure* weak_codeblobs() { return &_weak._codeblobs; }
92
93 OopClosure* raw_strong_oops() { return &_strong._oops; }
94
95 // If we are not marking all weak roots then we are tracing
96 // which metadata is alive.
97 bool trace_metadata() { return MarkWeak == G1MarkPromotedFromRoot; }
98 };
99
100 G1EvacuationRootClosures* G1EvacuationRootClosures::create_root_closures(G1ParScanThreadState* pss, G1CollectedHeap* g1h) {
101 G1EvacuationRootClosures* res = NULL;
102 if (g1h->collector_state()->in_initial_mark_gc()) {
103 if (ClassUnloadingWithConcurrentMark) {
104 res = new G1InitialMarkClosures<G1MarkPromotedFromRoot>(g1h, pss);
105 } else {
106 res = new G1InitialMarkClosures<G1MarkFromRoot>(g1h, pss);
107 }
108 } else {
109 res = new G1EvacuationClosures(g1h, pss, g1h->collector_state()->in_young_only_phase());
110 }
111 return res;
|