< prev index next >

src/hotspot/share/gc/g1/g1OopStarChunkedList.inline.hpp

Print this page
rev 52675 : 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
Reviewed-by:
Contributed-by: erik.helin@oracle.com, stefan.johansson@oracle.com
rev 52676 : imported patch AMGC-impl
rev 52679 : imported patch AMGC-tsch-rev1-log
rev 52682 : [mq]: AMGC-kbar-rev1b


  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_G1_G1OOPSTARCHUNKEDLIST_INLINE_HPP
  26 #define SHARE_GC_G1_G1OOPSTARCHUNKEDLIST_INLINE_HPP
  27 
  28 #include "gc/g1/g1OopStarChunkedList.hpp"
  29 #include "gc/g1/g1CollectedHeap.inline.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "memory/iterator.hpp"
  32 
  33 template <typename T>
  34 inline void G1OopStarChunkedList::push(ChunkedList<T*, mtGC>** field, T* p) {
  35   ChunkedList<T*, mtGC>* list = *field;
  36   if (list == NULL) {
  37     *field = new ChunkedList<T*, mtGC>();

  38   } else if (list->is_full()) {
  39     ChunkedList<T*, mtGC>* next = new ChunkedList<T*, mtGC>();
  40     next->set_next_used(list);
  41     *field = next;

  42   }
  43 
  44   (*field)->push(p);
  45 }
  46 
  47 inline void G1OopStarChunkedList::push_root(narrowOop* p) {
  48   push(&_croots, p);
  49 }
  50 
  51 inline void G1OopStarChunkedList::push_root(oop* p) {
  52   push(&_roots, p);
  53 }
  54 
  55 inline void G1OopStarChunkedList::push_oop(narrowOop* p) {
  56   push(&_coops, p);
  57 }
  58 
  59 inline void G1OopStarChunkedList::push_oop(oop* p) {
  60   push(&_oops, p);
  61 }
  62 
  63 template <typename T>
  64 size_t G1OopStarChunkedList::delete_list(ChunkedList<T*, mtGC>* c) {
  65   size_t freed = 0;
  66   size_t chunk_size = sizeof(ChunkedList<T*, mtGC>);
  67   while (c != NULL) {
  68     ChunkedList<T*, mtGC>* next = c->next_used();
  69     freed += chunk_size;
  70     delete c;
  71     c = next;
  72   }
  73   return freed;
  74 }
  75 
  76 template <typename T>
  77 void G1OopStarChunkedList::chunks_do(ChunkedList<T*, mtGC>* head, OopClosure* cl) {
  78   for (ChunkedList<T*, mtGC>* c = head; c != NULL; c = c->next_used()) {
  79     for (size_t i = 0; i < c->size(); i++) {
  80       T* p = c->at(i);
  81       cl->do_oop(p);
  82     }
  83   }
  84 }
  85 
  86 #endif // SHARE_GC_G1_G1OOPSTARCHUNKEDLIST_INLINE_HPP


  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_G1_G1OOPSTARCHUNKEDLIST_INLINE_HPP
  26 #define SHARE_GC_G1_G1OOPSTARCHUNKEDLIST_INLINE_HPP
  27 
  28 #include "gc/g1/g1OopStarChunkedList.hpp"
  29 #include "gc/g1/g1CollectedHeap.inline.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "memory/iterator.hpp"
  32 
  33 template <typename T>
  34 inline void G1OopStarChunkedList::push(ChunkedList<T*, mtGC>** field, T* p) {
  35   ChunkedList<T*, mtGC>* list = *field;
  36   if (list == NULL) {
  37     *field = new ChunkedList<T*, mtGC>();
  38     _used_memory += sizeof(ChunkedList<T*, mtGC>);
  39   } else if (list->is_full()) {
  40     ChunkedList<T*, mtGC>* next = new ChunkedList<T*, mtGC>();
  41     next->set_next_used(list);
  42     *field = next;
  43     _used_memory += sizeof(ChunkedList<T*, mtGC>);
  44   }
  45 
  46   (*field)->push(p);
  47 }
  48 
  49 inline void G1OopStarChunkedList::push_root(narrowOop* p) {
  50   push(&_croots, p);
  51 }
  52 
  53 inline void G1OopStarChunkedList::push_root(oop* p) {
  54   push(&_roots, p);
  55 }
  56 
  57 inline void G1OopStarChunkedList::push_oop(narrowOop* p) {
  58   push(&_coops, p);
  59 }
  60 
  61 inline void G1OopStarChunkedList::push_oop(oop* p) {
  62   push(&_oops, p);
  63 }
  64 
  65 template <typename T>
  66 void G1OopStarChunkedList::delete_list(ChunkedList<T*, mtGC>* c) {


  67   while (c != NULL) {
  68     ChunkedList<T*, mtGC>* next = c->next_used();

  69     delete c;
  70     c = next;
  71   }

  72 }
  73 
  74 template <typename T>
  75 void G1OopStarChunkedList::chunks_do(ChunkedList<T*, mtGC>* head, OopClosure* cl) {
  76   for (ChunkedList<T*, mtGC>* c = head; c != NULL; c = c->next_used()) {
  77     for (size_t i = 0; i < c->size(); i++) {
  78       T* p = c->at(i);
  79       cl->do_oop(p);
  80     }
  81   }
  82 }
  83 
  84 #endif // SHARE_GC_G1_G1OOPSTARCHUNKEDLIST_INLINE_HPP
< prev index next >