< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahMark.hpp

Print this page

  1 /*
  2  * Copyright (c) 2021, 2022, Red Hat, Inc. All rights reserved.

  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 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 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHMARK_HPP
 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHMARK_HPP
 27 

 28 #include "gc/shared/stringdedup/stringDedup.hpp"
 29 #include "gc/shared/taskTerminator.hpp"
 30 #include "gc/shenandoah/shenandoahHeap.hpp"
 31 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
 32 
 33 enum StringDedupMode {
 34   NO_DEDUP,      // Do not do anything for String deduplication
 35   ENQUEUE_DEDUP, // Enqueue candidate Strings for deduplication, if meet age threshold
 36   ALWAYS_DEDUP   // Enqueue Strings for deduplication
 37 };
 38 
 39 class ShenandoahMarkingContext;
 40 class ShenandoahReferenceProcessor;
 41 
 42 // Base class for mark
 43 // Mark class does not maintain states. Instead, mark states are
 44 // maintained by task queues, mark bitmap and SATB buffers (concurrent mark)
 45 class ShenandoahMark: public StackObj {
 46 protected:

 47   ShenandoahObjToScanQueueSet* const _task_queues;

 48 
 49 protected:
 50   ShenandoahMark();
 51 
 52 public:
 53   template<class T>
 54   static inline void mark_through_ref(T* p, ShenandoahObjToScanQueue* q, ShenandoahMarkingContext* const mark_context, bool weak);
 55 
 56   static void clear();
 57 
 58   // Loom support
 59   void start_mark();
 60   void end_mark();
 61 
 62   // Helpers
 63   inline ShenandoahObjToScanQueueSet* task_queues() const;




 64   inline ShenandoahObjToScanQueue* get_queue(uint index) const;



 65 
 66 // ---------- Marking loop and tasks
 67 private:
 68   template <class T, StringDedupMode STRING_DEDUP>
 69   inline void do_task(ShenandoahObjToScanQueue* q, T* cl, ShenandoahLiveData* live_data, StringDedup::Requests* const req, ShenandoahMarkTask* task);


 70 
 71   template <class T>
 72   inline void do_chunked_array_start(ShenandoahObjToScanQueue* q, T* cl, oop array, bool weak);
 73 
 74   template <class T>
 75   inline void do_chunked_array(ShenandoahObjToScanQueue* q, T* cl, oop array, int chunk, int pow, bool weak);
 76 
 77   inline void count_liveness(ShenandoahLiveData* live_data, oop obj);

 78 
 79   template <class T, bool CANCELLABLE,StringDedupMode STRING_DEDUP>
 80   void mark_loop_work(T* cl, ShenandoahLiveData* live_data, uint worker_id, TaskTerminator *t, StringDedup::Requests* const req);
 81 
 82   template <bool CANCELLABLE, StringDedupMode STRING_DEDUP>
 83   void mark_loop_prework(uint worker_id, TaskTerminator *terminator, ShenandoahReferenceProcessor *rp, StringDedup::Requests* const req);







 84 
 85   template <StringDedupMode STRING_DEDUP>
 86   inline void dedup_string(oop obj, StringDedup::Requests* const req);
 87 protected:
 88   void mark_loop(uint worker_id, TaskTerminator* terminator, ShenandoahReferenceProcessor *rp,




 89                  bool cancellable, StringDedupMode dedup_mode, StringDedup::Requests* const req);
 90 };
 91 
 92 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARK_HPP

  1 /*
  2  * Copyright (c) 2021, 2022, Red Hat, Inc. All rights reserved.
  3  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHMARK_HPP
 27 #define SHARE_GC_SHENANDOAH_SHENANDOAHMARK_HPP
 28 
 29 #include "gc/shared/ageTable.hpp"
 30 #include "gc/shared/stringdedup/stringDedup.hpp"
 31 #include "gc/shared/taskTerminator.hpp"
 32 #include "gc/shenandoah/shenandoahHeap.hpp"
 33 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
 34 
 35 enum StringDedupMode {
 36   NO_DEDUP,      // Do not do anything for String deduplication
 37   ENQUEUE_DEDUP, // Enqueue candidate Strings for deduplication, if meet age threshold
 38   ALWAYS_DEDUP   // Enqueue Strings for deduplication
 39 };
 40 
 41 class ShenandoahMarkingContext;
 42 class ShenandoahReferenceProcessor;
 43 
 44 // Base class for mark
 45 // Mark class does not maintain states. Instead, mark states are
 46 // maintained by task queues, mark bitmap and SATB buffers (concurrent mark)
 47 class ShenandoahMark: public StackObj {
 48 protected:
 49   ShenandoahGeneration* const _generation;
 50   ShenandoahObjToScanQueueSet* const _task_queues;
 51   ShenandoahObjToScanQueueSet* const _old_gen_task_queues;
 52 
 53 protected:
 54   ShenandoahMark(ShenandoahGeneration* generation);
 55 
 56 public:
 57   template<class T, ShenandoahGenerationType GENERATION>
 58   static inline void mark_through_ref(T* p, ShenandoahObjToScanQueue* q, ShenandoahObjToScanQueue* old_q, ShenandoahMarkingContext* const mark_context, bool weak);


 59 
 60   // Loom support
 61   void start_mark();
 62   void end_mark();
 63 
 64   // Helpers
 65   inline ShenandoahObjToScanQueueSet* task_queues() const;
 66   ShenandoahObjToScanQueueSet* old_task_queues() {
 67     return _old_gen_task_queues;
 68   }
 69 
 70   inline ShenandoahObjToScanQueue* get_queue(uint index) const;
 71   inline ShenandoahObjToScanQueue* get_old_queue(uint index) const;
 72 
 73   inline ShenandoahGeneration* generation() { return _generation; };
 74 

 75 private:
 76 // ---------- Marking loop and tasks
 77 
 78   template <class T, ShenandoahGenerationType GENERATION, StringDedupMode STRING_DEDUP>
 79   inline void do_task(ShenandoahObjToScanQueue* q, T* cl, ShenandoahLiveData* live_data, StringDedup::Requests* const req, ShenandoahMarkTask* task, uint worker_id);
 80 
 81   template <class T>
 82   inline void do_chunked_array_start(ShenandoahObjToScanQueue* q, T* cl, oop array, bool weak);
 83 
 84   template <class T>
 85   inline void do_chunked_array(ShenandoahObjToScanQueue* q, T* cl, oop array, int chunk, int pow, bool weak);
 86 
 87   template <ShenandoahGenerationType GENERATION>
 88   inline void count_liveness(ShenandoahLiveData* live_data, oop obj, uint worker_id);
 89 
 90   template <class T, ShenandoahGenerationType GENERATION, bool CANCELLABLE, StringDedupMode STRING_DEDUP>
 91   void mark_loop_work(T* cl, ShenandoahLiveData* live_data, uint worker_id, TaskTerminator *t, StringDedup::Requests* const req);
 92 
 93   template <ShenandoahGenerationType GENERATION, bool CANCELLABLE, StringDedupMode STRING_DEDUP>
 94   void mark_loop_prework(uint worker_id, TaskTerminator *terminator, ShenandoahReferenceProcessor *rp, StringDedup::Requests* const req, bool update_refs);
 95 
 96   template <ShenandoahGenerationType GENERATION>
 97   static bool in_generation(ShenandoahHeap* const heap, oop obj);
 98 
 99   static void mark_ref(ShenandoahObjToScanQueue* q,
100                        ShenandoahMarkingContext* const mark_context,
101                        bool weak, oop obj);
102 
103   template <StringDedupMode STRING_DEDUP>
104   inline void dedup_string(oop obj, StringDedup::Requests* const req);
105 protected:
106   template<bool CANCELLABLE, StringDedupMode STRING_DEDUP>
107   void mark_loop(ShenandoahGenerationType generation, uint worker_id, TaskTerminator* terminator, ShenandoahReferenceProcessor *rp,
108                  StringDedup::Requests* const req);
109 
110   void mark_loop(ShenandoahGenerationType generation, uint worker_id, TaskTerminator* terminator, ShenandoahReferenceProcessor *rp,
111                  bool cancellable, StringDedupMode dedup_mode, StringDedup::Requests* const req);
112 };
113 
114 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARK_HPP
< prev index next >