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 } 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