src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.hpp
changeset 52925 9c18c9d839d3
child 53244 9807daeb47c4
equal deleted inserted replaced
52924:420ff459906f 52925:9c18c9d839d3
       
     1 /*
       
     2  * Copyright (c) 2013, 2018, Red Hat, Inc. All rights reserved.
       
     3  *
       
     4  * This code is free software; you can redistribute it and/or modify it
       
     5  * under the terms of the GNU General Public License version 2 only, as
       
     6  * published by the Free Software Foundation.
       
     7  *
       
     8  * This code is distributed in the hope that it will be useful, but WITHOUT
       
     9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    11  * version 2 for more details (a copy is included in the LICENSE file that
       
    12  * accompanied this code).
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License version
       
    15  * 2 along with this work; if not, write to the Free Software Foundation,
       
    16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    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 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_HPP
       
    25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_HPP
       
    26 
       
    27 #include "gc/shared/taskqueue.hpp"
       
    28 #include "gc/shenandoah/shenandoahOopClosures.hpp"
       
    29 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
       
    30 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
       
    31 
       
    32 class ShenandoahStrDedupQueue;
       
    33 
       
    34 class ShenandoahConcurrentMark: public CHeapObj<mtGC> {
       
    35   friend class ShenandoahTraversalGC;
       
    36 private:
       
    37   ShenandoahHeap* _heap;
       
    38   ShenandoahObjToScanQueueSet* _task_queues;
       
    39 
       
    40 public:
       
    41   void initialize(uint workers);
       
    42   void cancel();
       
    43 
       
    44 // ---------- Marking loop and tasks
       
    45 //
       
    46 private:
       
    47   template <class T>
       
    48   inline void do_task(ShenandoahObjToScanQueue* q, T* cl, jushort* live_data, ShenandoahMarkTask* task);
       
    49 
       
    50   template <class T>
       
    51   inline void do_chunked_array_start(ShenandoahObjToScanQueue* q, T* cl, oop array);
       
    52 
       
    53   template <class T>
       
    54   inline void do_chunked_array(ShenandoahObjToScanQueue* q, T* cl, oop array, int chunk, int pow);
       
    55 
       
    56   inline void count_liveness(jushort* live_data, oop obj);
       
    57 
       
    58   template <class T, bool CANCELLABLE>
       
    59   void mark_loop_work(T* cl, jushort* live_data, uint worker_id, ShenandoahTaskTerminator *t);
       
    60 
       
    61   template <bool CANCELLABLE>
       
    62   void mark_loop_prework(uint worker_id, ShenandoahTaskTerminator *terminator, ReferenceProcessor *rp, bool strdedup);
       
    63 
       
    64 public:
       
    65   void mark_loop(uint worker_id, ShenandoahTaskTerminator* terminator, ReferenceProcessor *rp,
       
    66                  bool cancellable, bool strdedup) {
       
    67     if (cancellable) {
       
    68       mark_loop_prework<true>(worker_id, terminator, rp, strdedup);
       
    69     } else {
       
    70       mark_loop_prework<false>(worker_id, terminator, rp, strdedup);
       
    71     }
       
    72   }
       
    73 
       
    74   template<class T, UpdateRefsMode UPDATE_REFS, StringDedupMode STRING_DEDUP>
       
    75   static inline void mark_through_ref(T* p, ShenandoahHeap* heap, ShenandoahObjToScanQueue* q, ShenandoahMarkingContext* const mark_context);
       
    76 
       
    77   void mark_from_roots();
       
    78   void finish_mark_from_roots(bool full_gc);
       
    79 
       
    80   void mark_roots(ShenandoahPhaseTimings::Phase root_phase);
       
    81   void update_roots(ShenandoahPhaseTimings::Phase root_phase);
       
    82 
       
    83 // ---------- Weak references
       
    84 //
       
    85 private:
       
    86   void weak_refs_work(bool full_gc);
       
    87   void weak_refs_work_doit(bool full_gc);
       
    88 
       
    89 public:
       
    90   void preclean_weak_refs();
       
    91 
       
    92 // ---------- Concurrent code cache
       
    93 //
       
    94 private:
       
    95   ShenandoahSharedFlag _claimed_codecache;
       
    96 
       
    97 public:
       
    98   void concurrent_scan_code_roots(uint worker_id, ReferenceProcessor* rp);
       
    99   bool claim_codecache();
       
   100   void clear_claim_codecache();
       
   101 
       
   102 // ---------- Helpers
       
   103 // Used from closures, need to be public
       
   104 //
       
   105 public:
       
   106   ShenandoahObjToScanQueue* get_queue(uint worker_id);
       
   107   ShenandoahObjToScanQueueSet* task_queues() { return _task_queues; }
       
   108 
       
   109 };
       
   110 
       
   111 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_HPP