1 /* 2 * Copyright (c) 2010, 2013, 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_VM_OOPS_OBJARRAYKLASS_INLINE_HPP 26 #define SHARE_VM_OOPS_OBJARRAYKLASS_INLINE_HPP 27 28 #include "gc_implementation/shared/markSweep.inline.hpp" 29 #include "oops/objArrayKlass.hpp" 30 #include "utilities/macros.hpp" 31 #if INCLUDE_ALL_GCS 32 #include "gc_implementation/parallelScavenge/psCompactionManager.inline.hpp" 33 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp" 34 #endif // INCLUDE_ALL_GCS 35 36 void ObjArrayKlass::oop_follow_contents(oop obj, int index) { 37 if (UseCompressedOops) { 38 objarray_follow_contents<narrowOop>(obj, index); 39 } else { 40 objarray_follow_contents<oop>(obj, index); 41 } 42 } 43 44 template <class T> 45 void ObjArrayKlass::objarray_follow_contents(oop obj, int index) { 46 objArrayOop a = objArrayOop(obj); 47 const size_t len = size_t(a->length()); 48 const size_t beg_index = size_t(index); 49 assert(beg_index < len || len == 0, "index too large"); 50 51 const size_t stride = MIN2(len - beg_index, ObjArrayMarkingStride); 52 const size_t end_index = beg_index + stride; 53 T* const base = (T*)a->base(); 54 T* const beg = base + beg_index; 55 T* const end = base + end_index; 56 57 // Push the non-NULL elements of the next stride on the marking stack. 58 for (T* e = beg; e < end; e++) { 59 MarkSweep::mark_and_push<T>(e); 60 } 61 62 if (end_index < len) { 63 MarkSweep::push_objarray(a, end_index); // Push the continuation. 64 } 65 } 66 67 #if INCLUDE_ALL_GCS 68 void ObjArrayKlass::oop_follow_contents(ParCompactionManager* cm, oop obj, 69 int index) { 70 if (UseCompressedOops) { 71 objarray_follow_contents<narrowOop>(cm, obj, index); 72 } else { 73 objarray_follow_contents<oop>(cm, obj, index); 74 } 75 } 76 77 template <class T> 78 void ObjArrayKlass::objarray_follow_contents(ParCompactionManager* cm, oop obj, 79 int index) { 80 objArrayOop a = objArrayOop(obj); 81 const size_t len = size_t(a->length()); 82 const size_t beg_index = size_t(index); 83 assert(beg_index < len || len == 0, "index too large"); 84 85 const size_t stride = MIN2(len - beg_index, ObjArrayMarkingStride); 86 const size_t end_index = beg_index + stride; 87 T* const base = (T*)a->base(); 88 T* const beg = base + beg_index; 89 T* const end = base + end_index; 90 91 // Push the non-NULL elements of the next stride on the marking stack. 92 for (T* e = beg; e < end; e++) { 93 PSParallelCompact::mark_and_push<T>(cm, e); 94 } 95 96 if (end_index < len) { 97 cm->push_objarray(a, end_index); // Push the continuation. 98 } 99 } 100 #endif // INCLUDE_ALL_GCS 101 102 #endif // SHARE_VM_OOPS_OBJARRAYKLASS_INLINE_HPP