src/hotspot/share/gc/g1/g1OopStarChunkedList.inline.hpp
changeset 52897 495c05ee2a9a
child 54465 c4f16445675a
equal deleted inserted replaced
52896:98408c7c0b73 52897:495c05ee2a9a
       
     1 /*
       
     2  * Copyright (c) 2018, Oracle and/or its affiliates. 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_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