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