jcoomes@1746: /* coleenp@4037: * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. jcoomes@1746: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jcoomes@1746: * jcoomes@1746: * This code is free software; you can redistribute it and/or modify it jcoomes@1746: * under the terms of the GNU General Public License version 2 only, as jcoomes@1746: * published by the Free Software Foundation. jcoomes@1746: * jcoomes@1746: * This code is distributed in the hope that it will be useful, but WITHOUT jcoomes@1746: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jcoomes@1746: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jcoomes@1746: * version 2 for more details (a copy is included in the LICENSE file that jcoomes@1746: * accompanied this code). jcoomes@1746: * jcoomes@1746: * You should have received a copy of the GNU General Public License version jcoomes@1746: * 2 along with this work; if not, write to the Free Software Foundation, jcoomes@1746: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jcoomes@1746: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. jcoomes@1746: * jcoomes@1746: */ jcoomes@1746: stefank@2314: #ifndef SHARE_VM_OOPS_OBJARRAYKLASS_INLINE_HPP stefank@2314: #define SHARE_VM_OOPS_OBJARRAYKLASS_INLINE_HPP stefank@2314: coleenp@4037: #include "gc_implementation/shared/markSweep.inline.hpp" stefank@2314: #include "oops/objArrayKlass.hpp" jprovino@4542: #include "utilities/macros.hpp" jprovino@4542: #if INCLUDE_ALL_GCS stefank@2314: #include "gc_implementation/parallelScavenge/psCompactionManager.inline.hpp" stefank@2314: #include "gc_implementation/parallelScavenge/psParallelCompact.hpp" jprovino@4542: #endif // INCLUDE_ALL_GCS stefank@2314: coleenp@4142: void ObjArrayKlass::oop_follow_contents(oop obj, int index) { jcoomes@1746: if (UseCompressedOops) { jcoomes@1746: objarray_follow_contents(obj, index); jcoomes@1746: } else { jcoomes@1746: objarray_follow_contents(obj, index); jcoomes@1746: } jcoomes@1746: } jcoomes@1746: jcoomes@1746: template coleenp@4142: void ObjArrayKlass::objarray_follow_contents(oop obj, int index) { jcoomes@1746: objArrayOop a = objArrayOop(obj); jcoomes@1746: const size_t len = size_t(a->length()); jcoomes@1746: const size_t beg_index = size_t(index); jcoomes@1746: assert(beg_index < len || len == 0, "index too large"); jcoomes@1746: jcoomes@1746: const size_t stride = MIN2(len - beg_index, ObjArrayMarkingStride); jcoomes@1746: const size_t end_index = beg_index + stride; jcoomes@1746: T* const base = (T*)a->base(); jcoomes@1746: T* const beg = base + beg_index; jcoomes@1746: T* const end = base + end_index; jcoomes@1746: jcoomes@1746: // Push the non-NULL elements of the next stride on the marking stack. jcoomes@1746: for (T* e = beg; e < end; e++) { jcoomes@1746: MarkSweep::mark_and_push(e); jcoomes@1746: } jcoomes@1746: jcoomes@1746: if (end_index < len) { jcoomes@1746: MarkSweep::push_objarray(a, end_index); // Push the continuation. jcoomes@1746: } jcoomes@1746: } jcoomes@1746: jprovino@4542: #if INCLUDE_ALL_GCS coleenp@4142: void ObjArrayKlass::oop_follow_contents(ParCompactionManager* cm, oop obj, jcoomes@1746: int index) { jcoomes@1746: if (UseCompressedOops) { jcoomes@1746: objarray_follow_contents(cm, obj, index); jcoomes@1746: } else { jcoomes@1746: objarray_follow_contents(cm, obj, index); jcoomes@1746: } jcoomes@1746: } jcoomes@1746: jcoomes@1746: template coleenp@4142: void ObjArrayKlass::objarray_follow_contents(ParCompactionManager* cm, oop obj, jcoomes@1746: int index) { jcoomes@1746: objArrayOop a = objArrayOop(obj); jcoomes@1746: const size_t len = size_t(a->length()); jcoomes@1746: const size_t beg_index = size_t(index); jcoomes@1746: assert(beg_index < len || len == 0, "index too large"); jcoomes@1746: jcoomes@1746: const size_t stride = MIN2(len - beg_index, ObjArrayMarkingStride); jcoomes@1746: const size_t end_index = beg_index + stride; jcoomes@1746: T* const base = (T*)a->base(); jcoomes@1746: T* const beg = base + beg_index; jcoomes@1746: T* const end = base + end_index; jcoomes@1746: jcoomes@1746: // Push the non-NULL elements of the next stride on the marking stack. jcoomes@1746: for (T* e = beg; e < end; e++) { jcoomes@1746: PSParallelCompact::mark_and_push(cm, e); jcoomes@1746: } jcoomes@1746: jcoomes@1746: if (end_index < len) { jcoomes@1746: cm->push_objarray(a, end_index); // Push the continuation. jcoomes@1746: } jcoomes@1746: } jprovino@4542: #endif // INCLUDE_ALL_GCS stefank@2314: stefank@2314: #endif // SHARE_VM_OOPS_OBJARRAYKLASS_INLINE_HPP