7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #ifndef SHARE_VM_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP
25 #define SHARE_VM_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP
26
27 #include "gc/parallel/parMarkBitMap.hpp"
28 #include "gc/parallel/psCompactionManager.hpp"
29 #include "gc/parallel/psParallelCompact.inline.hpp"
30 #include "gc/shared/taskqueue.inline.hpp"
31 #include "oops/access.inline.hpp"
32 #include "oops/arrayOop.inline.hpp"
33 #include "oops/compressedOops.inline.hpp"
34 #include "oops/objArrayOop.inline.hpp"
35 #include "oops/oop.inline.hpp"
36 #include "utilities/debug.hpp"
37 #include "utilities/globalDefinitions.hpp"
38
39 inline bool ParCompactionManager::steal(int queue_num, oop& t) {
40 return stack_array()->steal(queue_num, t);
41 }
42
43 inline bool ParCompactionManager::steal_objarray(int queue_num, ObjArrayTask& t) {
44 return _objarray_queues->steal(queue_num, t);
45 }
|
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #ifndef SHARE_VM_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP
25 #define SHARE_VM_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP
26
27 #include "classfile/javaClasses.inline.hpp"
28 #include "gc/parallel/parMarkBitMap.hpp"
29 #include "gc/parallel/psCompactionManager.hpp"
30 #include "gc/parallel/psParallelCompact.inline.hpp"
31 #include "gc/shared/taskqueue.inline.hpp"
32 #include "oops/access.inline.hpp"
33 #include "oops/arrayOop.inline.hpp"
34 #include "oops/compressedOops.inline.hpp"
35 #include "oops/objArrayOop.inline.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "utilities/debug.hpp"
38 #include "utilities/globalDefinitions.hpp"
39
40 inline bool ParCompactionManager::steal(int queue_num, oop& t) {
41 return stack_array()->steal(queue_num, t);
42 }
43
44 inline bool ParCompactionManager::steal_objarray(int queue_num, ObjArrayTask& t) {
45 return _objarray_queues->steal(queue_num, t);
46 }
|
66 ParallelCompactData::RegionData* const region_ptr = sd.region(index);
67 assert(region_ptr->claimed(), "must be claimed");
68 assert(region_ptr->_pushed++ == 0, "should only be pushed once");
69 #endif
70 region_stack()->push(index);
71 }
72
73 template <typename T>
74 inline void ParCompactionManager::mark_and_push(T* p) {
75 T heap_oop = RawAccess<>::oop_load(p);
76 if (!CompressedOops::is_null(heap_oop)) {
77 oop obj = CompressedOops::decode_not_null(heap_oop);
78 assert(ParallelScavengeHeap::heap()->is_in(obj), "should be in heap");
79
80 if (mark_bitmap()->is_unmarked(obj) && PSParallelCompact::mark_obj(obj)) {
81 push(obj);
82 }
83 }
84 }
85
86 template <typename T>
87 inline void ParCompactionManager::MarkAndPushClosure::do_oop_work(T* p) {
88 _compaction_manager->mark_and_push(p);
89 }
90
91 inline void ParCompactionManager::MarkAndPushClosure::do_oop(oop* p) { do_oop_work(p); }
92 inline void ParCompactionManager::MarkAndPushClosure::do_oop(narrowOop* p) { do_oop_work(p); }
93
94 inline void ParCompactionManager::follow_klass(Klass* klass) {
95 oop holder = klass->klass_holder();
96 mark_and_push(&holder);
97 }
98
99 inline void ParCompactionManager::FollowStackClosure::do_void() {
100 _compaction_manager->follow_marking_stacks();
101 }
102
103 inline void ParCompactionManager::follow_class_loader(ClassLoaderData* cld) {
104 MarkAndPushClosure mark_and_push_closure(this);
105
106 cld->oops_do(&mark_and_push_closure, true);
107 }
108
109 inline void ParCompactionManager::follow_contents(oop obj) {
110 assert(PSParallelCompact::mark_bitmap()->is_marked(obj), "should be marked");
111 obj->pc_follow_contents(this);
112 }
113
114 template <class T>
115 inline void oop_pc_follow_contents_specialized(objArrayOop obj, int index, ParCompactionManager* cm) {
116 const size_t len = size_t(obj->length());
117 const size_t beg_index = size_t(index);
118 assert(beg_index < len || len == 0, "index too large");
119
120 const size_t stride = MIN2(len - beg_index, (size_t)ObjArrayMarkingStride);
121 const size_t end_index = beg_index + stride;
122 T* const base = (T*)obj->base_raw();
123 T* const beg = base + beg_index;
124 T* const end = base + end_index;
125
126 if (end_index < len) {
127 cm->push_objarray(obj, end_index); // Push the continuation.
128 }
129
130 // Push the non-NULL elements of the next stride on the marking stack.
131 for (T* e = beg; e < end; e++) {
132 cm->mark_and_push<T>(e);
133 }
134 }
135
136 inline void ParCompactionManager::follow_contents(objArrayOop obj, int index) {
137 if (UseCompressedOops) {
138 oop_pc_follow_contents_specialized<narrowOop>(obj, index, this);
139 } else {
140 oop_pc_follow_contents_specialized<oop>(obj, index, this);
141 }
142 }
143
144 inline void ParCompactionManager::update_contents(oop obj) {
145 obj->pc_update_contents(this);
146 }
147
148 #endif // SHARE_VM_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP
|
67 ParallelCompactData::RegionData* const region_ptr = sd.region(index);
68 assert(region_ptr->claimed(), "must be claimed");
69 assert(region_ptr->_pushed++ == 0, "should only be pushed once");
70 #endif
71 region_stack()->push(index);
72 }
73
74 template <typename T>
75 inline void ParCompactionManager::mark_and_push(T* p) {
76 T heap_oop = RawAccess<>::oop_load(p);
77 if (!CompressedOops::is_null(heap_oop)) {
78 oop obj = CompressedOops::decode_not_null(heap_oop);
79 assert(ParallelScavengeHeap::heap()->is_in(obj), "should be in heap");
80
81 if (mark_bitmap()->is_unmarked(obj) && PSParallelCompact::mark_obj(obj)) {
82 push(obj);
83 }
84 }
85 }
86
87 inline void ParCompactionManager::follow_klass(Klass* klass) {
88 oop holder = klass->klass_holder();
89 mark_and_push(&holder);
90 }
91
92 inline void ParCompactionManager::FollowStackClosure::do_void() {
93 _compaction_manager->follow_marking_stacks();
94 }
95
96
97
98 template <typename T>
99 inline void follow_array_specialized(objArrayOop obj, int index, ParCompactionManager* cm) {
100 const size_t len = size_t(obj->length());
101 const size_t beg_index = size_t(index);
102 assert(beg_index < len || len == 0, "index too large");
103
104 const size_t stride = MIN2(len - beg_index, (size_t)ObjArrayMarkingStride);
105 const size_t end_index = beg_index + stride;
106 T* const base = (T*)obj->base_raw();
107 T* const beg = base + beg_index;
108 T* const end = base + end_index;
109
110 if (end_index < len) {
111 cm->push_objarray(obj, end_index); // Push the continuation.
112 }
113
114 // Push the non-NULL elements of the next stride on the marking stack.
115 for (T* e = beg; e < end; e++) {
116 cm->mark_and_push<T>(e);
117 }
118 }
119
120 inline void ParCompactionManager::follow_array(objArrayOop obj, int index) {
121 if (UseCompressedOops) {
122 follow_array_specialized<narrowOop>(obj, index, this);
123 } else {
124 follow_array_specialized<oop>(obj, index, this);
125 }
126 }
127
128 inline void ParCompactionManager::update_contents(oop obj) {
129 obj->pc_update_contents(this);
130 }
131
132 class PSMarkAndPushClosure: public OopClosure {
133 private:
134 ParCompactionManager* _compaction_manager;
135 public:
136 PSMarkAndPushClosure(ParCompactionManager* cm) : _compaction_manager(cm) { }
137
138 template <typename T> void do_oop_nv(T* p) { _compaction_manager->mark_and_push(p); }
139 virtual void do_oop(oop* p) { do_oop_nv(p); }
140 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
141
142 // This closure provides its own oop verification code.
143 debug_only(virtual bool should_verify_oops() { return false; })
144 };
145
146 class PSIterateMarkAndPushClosure: public MetadataVisitingOopIterateClosure {
147 private:
148 ParCompactionManager* _compaction_manager;
149 public:
150 PSIterateMarkAndPushClosure(ParCompactionManager* cm, ReferenceProcessor* rp) : MetadataVisitingOopIterateClosure(rp),
151
152 template <typename T> void do_oop_nv(T* p) { _compaction_manager->mark_and_push(p); }
153 virtual void do_oop(oop* p) { do_oop_nv(p); }
154 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
155
156 void do_klass_nv(Klass* k) { _compaction_manager->follow_klass(k); }
157 void do_cld_nv(ClassLoaderData* cld) { _compaction_manager->follow_class_loader(cld); }
158
159 // This closure provides its own oop verification code.
160 debug_only(virtual bool should_verify_oops() { return false; })
161 };
162
163 inline void ParCompactionManager::follow_class_loader(ClassLoaderData* cld) {
164 PSMarkAndPushClosure mark_and_push_closure(this);
165 cld->oops_do(&mark_and_push_closure, true);
166 }
167
168 inline void ParCompactionManager::follow_contents(oop obj) {
169 assert(PSParallelCompact::mark_bitmap()->is_marked(obj), "should be marked");
170 if (obj->is_objArray()) {
171 follow_array(objArrayOop(obj), 0);
172 } else {
173 PSIterateMarkAndPushClosure cl(this, PSParallelCompact::ref_processor());
174 obj->oop_iterate(&cl);
175 }
176 }
177
178 #endif // SHARE_VM_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP
|