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_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSCOMPACTIONMANAGER_INLINE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSCOMPACTIONMANAGER_INLINE_HPP
27
28 #include "gc_implementation/parallelScavenge/psCompactionManager.hpp"
29 #include "gc_implementation/parallelScavenge/psParallelCompact.inline.hpp"
30 #include "oops/objArrayOop.hpp"
31 #include "oops/oop.inline.hpp"
32 #include "utilities/debug.hpp"
33 #include "utilities/globalDefinitions.hpp"
34
35 void ParCompactionManager::push_objarray(oop obj, size_t index)
36 {
37 ObjArrayTask task(obj, index);
38 assert(task.is_valid(), "bad ObjArrayTask");
39 _objarray_stack.push(task);
40 }
41
42 void ParCompactionManager::push_region(size_t index)
43 {
44 #ifdef ASSERT
45 const ParallelCompactData& sd = PSParallelCompact::summary_data();
46 ParallelCompactData::RegionData* const region_ptr = sd.region(index);
47 assert(region_ptr->claimed(), "must be claimed");
48 assert(region_ptr->_pushed++ == 0, "should only be pushed once");
49 #endif
50 region_stack()->push(index);
51 }
52
53 inline void ParCompactionManager::follow_contents(oop obj) {
54 assert(PSParallelCompact::mark_bitmap()->is_marked(obj), "should be marked");
55 obj->pc_follow_contents(this);
56 }
57
58 template <class T>
59 inline void oop_pc_follow_contents_specialized(objArrayOop obj, int index, ParCompactionManager* cm) {
60 const size_t len = size_t(obj->length());
61 const size_t beg_index = size_t(index);
62 assert(beg_index < len || len == 0, "index too large");
63
64 const size_t stride = MIN2(len - beg_index, ObjArrayMarkingStride);
65 const size_t end_index = beg_index + stride;
66 T* const base = (T*)obj->base();
67 T* const beg = base + beg_index;
68 T* const end = base + end_index;
69
70 // Push the non-NULL elements of the next stride on the marking stack.
71 for (T* e = beg; e < end; e++) {
72 PSParallelCompact::mark_and_push<T>(cm, e);
73 }
74
75 if (end_index < len) {
76 cm->push_objarray(obj, end_index); // Push the continuation.
77 }
78 }
79
80 inline void ParCompactionManager::follow_contents(objArrayOop obj, int index) {
81 if (UseCompressedOops) {
82 oop_pc_follow_contents_specialized<narrowOop>(obj, index, this);
83 } else {
84 oop_pc_follow_contents_specialized<oop>(obj, index, this);
85 }
86 }
87
88 inline void ParCompactionManager::update_contents(oop obj) {
89 obj->pc_update_contents();
90 }
91
92 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSCOMPACTIONMANAGER_INLINE_HPP
|
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_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSCOMPACTIONMANAGER_INLINE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSCOMPACTIONMANAGER_INLINE_HPP
27
28 #include "gc_implementation/parallelScavenge/psCompactionManager.hpp"
29 #include "gc_implementation/parallelScavenge/psParallelCompact.inline.hpp"
30 #include "oops/objArrayOop.hpp"
31 #include "oops/oop.inline.hpp"
32 #include "utilities/debug.hpp"
33 #include "utilities/globalDefinitions.hpp"
34 #include "utilities/taskqueue.inline.hpp"
35
36 inline void ParCompactionManager::push(oop obj) {
37 _marking_stack.push(obj);
38 }
39
40 void ParCompactionManager::push_objarray(oop obj, size_t index)
41 {
42 ObjArrayTask task(obj, index);
43 assert(task.is_valid(), "bad ObjArrayTask");
44 _objarray_stack.push(task);
45 }
46
47 void ParCompactionManager::push_region(size_t index)
48 {
49 #ifdef ASSERT
50 const ParallelCompactData& sd = PSParallelCompact::summary_data();
51 ParallelCompactData::RegionData* const region_ptr = sd.region(index);
52 assert(region_ptr->claimed(), "must be claimed");
53 assert(region_ptr->_pushed++ == 0, "should only be pushed once");
54 #endif
55 region_stack()->push(index);
56 }
57
58 template <typename T>
59 inline void ParCompactionManager::mark_and_push(T* p) {
60 T heap_oop = oopDesc::load_heap_oop(p);
61 if (!oopDesc::is_null(heap_oop)) {
62 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
63 assert(ParallelScavengeHeap::heap()->is_in(obj), "should be in heap");
64
65 if (mark_bitmap()->is_unmarked(obj) && PSParallelCompact::mark_obj(obj)) {
66 push(obj);
67 }
68 }
69 }
70
71 template <typename T>
72 inline void ParCompactionManager::MarkAndPushClosure::do_oop_nv(T* p) {
73 _compaction_manager->mark_and_push(p);
74 }
75
76 inline void ParCompactionManager::MarkAndPushClosure::do_oop(oop* p) { do_oop_nv(p); }
77 inline void ParCompactionManager::MarkAndPushClosure::do_oop(narrowOop* p) { do_oop_nv(p); }
78
79 inline void ParCompactionManager::follow_klass(Klass* klass) {
80 oop holder = klass->klass_holder();
81 mark_and_push(&holder);
82 }
83
84 inline void ParCompactionManager::FollowStackClosure::do_void() {
85 _compaction_manager->follow_marking_stacks();
86 }
87
88 inline void ParCompactionManager::FollowKlassClosure::do_klass(Klass* klass) {
89 klass->oops_do(_mark_and_push_closure);
90 }
91
92 inline void ParCompactionManager::follow_contents(oop obj) {
93 assert(PSParallelCompact::mark_bitmap()->is_marked(obj), "should be marked");
94 obj->pc_follow_contents(this);
95 }
96
97 template <class T>
98 inline void oop_pc_follow_contents_specialized(objArrayOop obj, int index, ParCompactionManager* cm) {
99 const size_t len = size_t(obj->length());
100 const size_t beg_index = size_t(index);
101 assert(beg_index < len || len == 0, "index too large");
102
103 const size_t stride = MIN2(len - beg_index, ObjArrayMarkingStride);
104 const size_t end_index = beg_index + stride;
105 T* const base = (T*)obj->base();
106 T* const beg = base + beg_index;
107 T* const end = base + end_index;
108
109 // Push the non-NULL elements of the next stride on the marking stack.
110 for (T* e = beg; e < end; e++) {
111 cm->mark_and_push<T>(e);
112 }
113
114 if (end_index < len) {
115 cm->push_objarray(obj, end_index); // Push the continuation.
116 }
117 }
118
119 inline void ParCompactionManager::follow_contents(objArrayOop obj, int index) {
120 if (UseCompressedOops) {
121 oop_pc_follow_contents_specialized<narrowOop>(obj, index, this);
122 } else {
123 oop_pc_follow_contents_specialized<oop>(obj, index, this);
124 }
125 }
126
127 inline void ParCompactionManager::update_contents(oop obj) {
128 obj->pc_update_contents();
129 }
130
131 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSCOMPACTIONMANAGER_INLINE_HPP
|