< prev index next >

src/hotspot/share/gc/g1/g1RootClosures.cpp

CLD claiming v2

17  *                                                                                                                                   
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA                                                           
19  * or visit www.oracle.com if you need additional information or have any                                                            
20  * questions.                                                                                                                        
21  *                                                                                                                                   
22  */                                                                                                                                  
23 
24 #include "precompiled.hpp"                                                                                                           
25 #include "gc/g1/g1OopClosures.inline.hpp"                                                                                            
26 #include "gc/g1/g1RootClosures.hpp"                                                                                                  
27 #include "gc/g1/g1SharedClosures.hpp"                                                                                                
28 
29 // Closures used for standard G1 evacuation.                                                                                         
30 class G1EvacuationClosures : public G1EvacuationRootClosures {                                                                       
31   G1SharedClosures<G1MarkNone> _closures;                                                                                            
32 
33 public:                                                                                                                              
34   G1EvacuationClosures(G1CollectedHeap* g1h,                                                                                         
35                        G1ParScanThreadState* pss,                                                                                    
36                        bool in_young_gc) :                                                                                           
37       _closures(g1h, pss, in_young_gc, /* cld_claim_value */ ClassLoaderData::_claim_value_none) {}                                  
38 
39   OopClosure* weak_oops()   { return &_closures._oops; }                                                                             
40   OopClosure* strong_oops() { return &_closures._oops; }                                                                             
41 
42   CLDClosure* weak_clds()             { return &_closures._clds; }                                                                   
43   CLDClosure* strong_clds()           { return &_closures._clds; }                                                                   
44   CLDClosure* second_pass_weak_clds() { return NULL; }                                                                               
45 
46   CodeBlobClosure* strong_codeblobs()      { return &_closures._codeblobs; }                                                         
47   CodeBlobClosure* weak_codeblobs()        { return &_closures._codeblobs; }                                                         
48 
49   OopClosure* raw_strong_oops() { return &_closures._oops; }                                                                         
50 
51   bool trace_metadata()         { return false; }                                                                                    
52 };                                                                                                                                   
53 
54 // Closures used during initial mark.                                                                                                
55 // The treatment of "weak" roots is selectable through the template parameter,                                                       
56 // this is usually used to control unloading of classes and interned strings.                                                        
57 template <G1Mark MarkWeak>                                                                                                           
58 class G1InitialMarkClosures : public G1EvacuationRootClosures {                                                                      
59   G1SharedClosures<G1MarkFromRoot> _strong;                                                                                          
60   G1SharedClosures<MarkWeak>       _weak;                                                                                            
61 
62   // Filter method to help with returning the appropriate closures                                                                   
63   // depending on the class template parameter.                                                                                      
64   template <G1Mark Mark, typename T>                                                                                                 
65   T* null_if(T* t) {                                                                                                                 
66     if (Mark == MarkWeak) {                                                                                                          
67       return NULL;                                                                                                                   
68     }                                                                                                                                
69     return t;                                                                                                                        
70   }                                                                                                                                  
71 
72 public:                                                                                                                              
73   G1InitialMarkClosures(G1CollectedHeap* g1h,                                                                                        
74                         G1ParScanThreadState* pss) :                                                                                 
75       _strong(g1h, pss, /* process_only_dirty_klasses */ false, /* cld_claim_value */ ClassLoaderData::_claim_value_strong),         
76       _weak(g1h, pss,   /* process_only_dirty_klasses */ false, /* cld_claim_value */ ClassLoaderData::_claim_value_strong) {}       
77 
78   OopClosure* weak_oops()   { return &_weak._oops; }                                                                                 
79   OopClosure* strong_oops() { return &_strong._oops; }                                                                               
80 
81   // If MarkWeak is G1MarkPromotedFromRoot then the weak CLDs must be processed in a second pass.                                    
82   CLDClosure* weak_clds()             { return null_if<G1MarkPromotedFromRoot>(&_weak._clds); }                                      
83   CLDClosure* strong_clds()           { return &_strong._clds; }                                                                     
84 
85   // If MarkWeak is G1MarkFromRoot then all CLDs are processed by the weak and strong variants                                       
86   // return a NULL closure for the following specialized versions in that case.                                                      
87   CLDClosure* second_pass_weak_clds() { return null_if<G1MarkFromRoot>(&_weak._clds); }                                              
88 
89   CodeBlobClosure* strong_codeblobs()      { return &_strong._codeblobs; }                                                           
90   CodeBlobClosure* weak_codeblobs()        { return &_weak._codeblobs; }                                                             
91 
92   OopClosure* raw_strong_oops() { return &_strong._oops; }                                                                           
93 
94   // If we are not marking all weak roots then we are tracing                                                                        
95   // which metadata is alive.                                                                                                        

17  *
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.
21  *
22  */
23 
24 #include "precompiled.hpp"
25 #include "gc/g1/g1OopClosures.inline.hpp"
26 #include "gc/g1/g1RootClosures.hpp"
27 #include "gc/g1/g1SharedClosures.hpp"
28 
29 // Closures used for standard G1 evacuation.
30 class G1EvacuationClosures : public G1EvacuationRootClosures {
31   G1SharedClosures<G1MarkNone> _closures;
32 
33 public:
34   G1EvacuationClosures(G1CollectedHeap* g1h,
35                        G1ParScanThreadState* pss,
36                        bool in_young_gc) :
37       _closures(g1h, pss, in_young_gc, /* cld_claim */ ClassLoaderData::_claim_none) {}
38 
39   OopClosure* weak_oops()   { return &_closures._oops; }
40   OopClosure* strong_oops() { return &_closures._oops; }
41 
42   CLDClosure* weak_clds()             { return &_closures._clds; }
43   CLDClosure* strong_clds()           { return &_closures._clds; }
44   CLDClosure* second_pass_weak_clds() { return NULL; }
45 
46   CodeBlobClosure* strong_codeblobs()      { return &_closures._codeblobs; }
47   CodeBlobClosure* weak_codeblobs()        { return &_closures._codeblobs; }
48 
49   OopClosure* raw_strong_oops() { return &_closures._oops; }
50 
51   bool trace_metadata()         { return false; }
52 };
53 
54 // Closures used during initial mark.
55 // The treatment of "weak" roots is selectable through the template parameter,
56 // this is usually used to control unloading of classes and interned strings.
57 template <G1Mark MarkWeak>
58 class G1InitialMarkClosures : public G1EvacuationRootClosures {
59   G1SharedClosures<G1MarkFromRoot> _strong;
60   G1SharedClosures<MarkWeak>       _weak;
61 
62   // Filter method to help with returning the appropriate closures
63   // depending on the class template parameter.
64   template <G1Mark Mark, typename T>
65   T* null_if(T* t) {
66     if (Mark == MarkWeak) {
67       return NULL;
68     }
69     return t;
70   }
71 
72 public:
73   G1InitialMarkClosures(G1CollectedHeap* g1h,
74                         G1ParScanThreadState* pss) :
75       _strong(g1h, pss, /* process_only_dirty_klasses */ false, /* cld_claim */ ClassLoaderData::_claim_strong),
76       _weak(g1h, pss,   /* process_only_dirty_klasses */ false, /* cld_claim */ ClassLoaderData::_claim_strong) {}
77 
78   OopClosure* weak_oops()   { return &_weak._oops; }
79   OopClosure* strong_oops() { return &_strong._oops; }
80 
81   // If MarkWeak is G1MarkPromotedFromRoot then the weak CLDs must be processed in a second pass.
82   CLDClosure* weak_clds()             { return null_if<G1MarkPromotedFromRoot>(&_weak._clds); }
83   CLDClosure* strong_clds()           { return &_strong._clds; }
84 
85   // If MarkWeak is G1MarkFromRoot then all CLDs are processed by the weak and strong variants
86   // return a NULL closure for the following specialized versions in that case.
87   CLDClosure* second_pass_weak_clds() { return null_if<G1MarkFromRoot>(&_weak._clds); }
88 
89   CodeBlobClosure* strong_codeblobs()      { return &_strong._codeblobs; }
90   CodeBlobClosure* weak_codeblobs()        { return &_weak._codeblobs; }
91 
92   OopClosure* raw_strong_oops() { return &_strong._oops; }
93 
94   // If we are not marking all weak roots then we are tracing
95   // which metadata is alive.
< prev index next >