src/hotspot/share/gc/g1/g1RootClosures.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 52141 de6dc206a92b
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
    33 
    33 
    34 public:
    34 public:
    35   G1EvacuationClosures(G1CollectedHeap* g1h,
    35   G1EvacuationClosures(G1CollectedHeap* g1h,
    36                        G1ParScanThreadState* pss,
    36                        G1ParScanThreadState* pss,
    37                        bool in_young_gc) :
    37                        bool in_young_gc) :
    38       _closures(g1h, pss, in_young_gc, /* cld_claim */ ClassLoaderData::_claim_none) {}
    38       _closures(g1h, pss, in_young_gc) {}
    39 
    39 
    40   OopClosure* weak_oops()   { return &_closures._oops; }
    40   OopClosure* weak_oops()   { return &_closures._oops; }
    41   OopClosure* strong_oops() { return &_closures._oops; }
    41   OopClosure* strong_oops() { return &_closures._oops; }
    42 
    42 
    43   CLDClosure* weak_clds()             { return &_closures._clds; }
    43   CLDClosure* weak_clds()             { return &_closures._clds; }
    44   CLDClosure* strong_clds()           { return &_closures._clds; }
    44   CLDClosure* strong_clds()           { return &_closures._clds; }
    45   CLDClosure* second_pass_weak_clds() { return NULL; }
       
    46 
    45 
    47   CodeBlobClosure* strong_codeblobs()      { return &_closures._codeblobs; }
    46   CodeBlobClosure* strong_codeblobs()      { return &_closures._codeblobs; }
    48   CodeBlobClosure* weak_codeblobs()        { return &_closures._codeblobs; }
    47   CodeBlobClosure* weak_codeblobs()        { return &_closures._codeblobs; }
    49 
       
    50   OopClosure* raw_strong_oops() { return &_closures._oops; }
       
    51 
    48 
    52   bool trace_metadata()         { return false; }
    49   bool trace_metadata()         { return false; }
    53 };
    50 };
    54 
    51 
    55 // Closures used during initial mark.
    52 // Closures used during initial mark.
    58 template <G1Mark MarkWeak>
    55 template <G1Mark MarkWeak>
    59 class G1InitialMarkClosures : public G1EvacuationRootClosures {
    56 class G1InitialMarkClosures : public G1EvacuationRootClosures {
    60   G1SharedClosures<G1MarkFromRoot> _strong;
    57   G1SharedClosures<G1MarkFromRoot> _strong;
    61   G1SharedClosures<MarkWeak>       _weak;
    58   G1SharedClosures<MarkWeak>       _weak;
    62 
    59 
    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:
    60 public:
    74   G1InitialMarkClosures(G1CollectedHeap* g1h,
    61   G1InitialMarkClosures(G1CollectedHeap* g1h,
    75                         G1ParScanThreadState* pss) :
    62                         G1ParScanThreadState* pss) :
    76       _strong(g1h, pss, /* process_only_dirty_klasses */ false, /* cld_claim */ ClassLoaderData::_claim_strong),
    63       _strong(g1h, pss, /* process_only_dirty_klasses */ false),
    77       _weak(g1h, pss,   /* process_only_dirty_klasses */ false, /* cld_claim */ ClassLoaderData::_claim_strong) {}
    64       _weak(g1h, pss,   /* process_only_dirty_klasses */ false) {}
    78 
    65 
    79   OopClosure* weak_oops()   { return &_weak._oops; }
    66   OopClosure* weak_oops()   { return &_weak._oops; }
    80   OopClosure* strong_oops() { return &_strong._oops; }
    67   OopClosure* strong_oops() { return &_strong._oops; }
    81 
    68 
    82   // If MarkWeak is G1MarkPromotedFromRoot then the weak CLDs must be processed in a second pass.
    69   CLDClosure* weak_clds()             { return &_weak._clds; }
    83   CLDClosure* weak_clds()             { return null_if<G1MarkPromotedFromRoot>(&_weak._clds); }
       
    84   CLDClosure* strong_clds()           { return &_strong._clds; }
    70   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 
    71 
    90   CodeBlobClosure* strong_codeblobs()      { return &_strong._codeblobs; }
    72   CodeBlobClosure* strong_codeblobs()      { return &_strong._codeblobs; }
    91   CodeBlobClosure* weak_codeblobs()        { return &_weak._codeblobs; }
    73   CodeBlobClosure* weak_codeblobs()        { return &_weak._codeblobs; }
    92 
       
    93   OopClosure* raw_strong_oops() { return &_strong._oops; }
       
    94 
    74 
    95   // If we are not marking all weak roots then we are tracing
    75   // If we are not marking all weak roots then we are tracing
    96   // which metadata is alive.
    76   // which metadata is alive.
    97   bool trace_metadata()         { return MarkWeak == G1MarkPromotedFromRoot; }
    77   bool trace_metadata()         { return MarkWeak == G1MarkPromotedFromRoot; }
    98 };
    78 };