objArrayKlass.inline.hpp revision 5776:de6a9e811145
1101282Smdodd/*
2204977Simp * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3101282Smdodd * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4101282Smdodd *
5101282Smdodd * This code is free software; you can redistribute it and/or modify it
6101282Smdodd * under the terms of the GNU General Public License version 2 only, as
7101282Smdodd * published by the Free Software Foundation.
8101282Smdodd *
9101282Smdodd * This code is distributed in the hope that it will be useful, but WITHOUT
10101282Smdodd * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11101282Smdodd * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12101282Smdodd * version 2 for more details (a copy is included in the LICENSE file that
13101282Smdodd * accompanied this code).
14101282Smdodd *
15101282Smdodd * You should have received a copy of the GNU General Public License version
16101282Smdodd * 2 along with this work; if not, write to the Free Software Foundation,
17101282Smdodd * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18101282Smdodd *
19101282Smdodd * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20101282Smdodd * or visit www.oracle.com if you need additional information or have any
21101282Smdodd * questions.
22101282Smdodd *
23101282Smdodd */
24101282Smdodd
25101282Smdodd#ifndef SHARE_VM_OOPS_OBJARRAYKLASS_INLINE_HPP
26101282Smdodd#define SHARE_VM_OOPS_OBJARRAYKLASS_INLINE_HPP
27101282Smdodd
28168569Sdelphij#include "gc_implementation/shared/markSweep.inline.hpp"
29168569Sdelphij#include "oops/objArrayKlass.hpp"
30240005Szont#include "utilities/macros.hpp"
31240005Szont#if INCLUDE_ALL_GCS
32240005Szont#include "gc_implementation/parallelScavenge/psCompactionManager.inline.hpp"
33240005Szont#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
34240005Szont#endif // INCLUDE_ALL_GCS
35240005Szont
36240005Szontvoid ObjArrayKlass::oop_follow_contents(oop obj, int index) {
37101282Smdodd  if (UseCompressedOops) {
38168569Sdelphij    objarray_follow_contents<narrowOop>(obj, index);
39168569Sdelphij  } else {
40168569Sdelphij    objarray_follow_contents<oop>(obj, index);
41168569Sdelphij  }
42168569Sdelphij}
43168569Sdelphij
44240562Szonttemplate <class T>
45240562Szontvoid ObjArrayKlass::objarray_follow_contents(oop obj, int index) {
46240562Szont  objArrayOop a = objArrayOop(obj);
47168569Sdelphij  const size_t len = size_t(a->length());
48168569Sdelphij  const size_t beg_index = size_t(index);
49101282Smdodd  assert(beg_index < len || len == 0, "index too large");
50101282Smdodd
51239501Szont  const size_t stride = MIN2(len - beg_index, ObjArrayMarkingStride);
52101282Smdodd  const size_t end_index = beg_index + stride;
53168569Sdelphij  T* const base = (T*)a->base();
54168569Sdelphij  T* const beg = base + beg_index;
55153963Sbrian  T* const end = base + end_index;
56101282Smdodd
57101285Smdodd  // Push the non-NULL elements of the next stride on the marking stack.
58101373Smdodd  for (T* e = beg; e < end; e++) {
59168569Sdelphij    MarkSweep::mark_and_push<T>(e);
60168569Sdelphij  }
61240005Szont
62168569Sdelphij  if (end_index < len) {
63101282Smdodd    MarkSweep::push_objarray(a, end_index); // Push the continuation.
64158630Spav  }
65247338Sdelphij}
66158630Spav
67158630Spav#if INCLUDE_ALL_GCS
68158630Spavvoid ObjArrayKlass::oop_follow_contents(ParCompactionManager* cm, oop obj,
69158630Spav                                        int index) {
70158630Spav  if (UseCompressedOops) {
71158630Spav    objarray_follow_contents<narrowOop>(cm, obj, index);
72158630Spav  } else {
73158630Spav    objarray_follow_contents<oop>(cm, obj, index);
74168569Sdelphij  }
75247338Sdelphij}
76192025Sdds
77192025Sddstemplate <class T>
78192025Sddsvoid ObjArrayKlass::objarray_follow_contents(ParCompactionManager* cm, oop obj,
79192025Sdds                                             int index) {
80192025Sdds  objArrayOop a = objArrayOop(obj);
81192025Sdds  const size_t len = size_t(a->length());
82192025Sdds  const size_t beg_index = size_t(index);
83192025Sdds  assert(beg_index < len || len == 0, "index too large");
84192025Sdds
85240005Szont  const size_t stride = MIN2(len - beg_index, ObjArrayMarkingStride);
86240005Szont  const size_t end_index = beg_index + stride;
87240005Szont  T* const base = (T*)a->base();
88240005Szont  T* const beg = base + beg_index;
89240005Szont  T* const end = base + end_index;
90240005Szont
91240393Szont  // 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
103