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_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_INLINE_HPP
25 #define SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_INLINE_HPP
26
27 #include "gc/shenandoah/shenandoahAsserts.hpp"
28 #include "gc/shenandoah/shenandoahForwarding.hpp"
29 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
30 #include "gc/shenandoah/shenandoahConcurrentMark.hpp"
31 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
32 #include "gc/shenandoah/shenandoahStringDedup.inline.hpp"
33 #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
34 #include "memory/iterator.inline.hpp"
35 #include "oops/oop.inline.hpp"
36 #include "runtime/prefetch.inline.hpp"
37
38 template <class T>
39 void ShenandoahConcurrentMark::do_task(ShenandoahObjToScanQueue* q, T* cl, jushort* live_data, ShenandoahMarkTask* task) {
40 oop obj = task->obj();
41
42 shenandoah_assert_not_forwarded_except(NULL, obj, _heap->is_concurrent_traversal_in_progress() && _heap->cancelled_gc());
43 shenandoah_assert_marked(NULL, obj);
44 shenandoah_assert_not_in_cset_except(NULL, obj, _heap->cancelled_gc());
45
46 if (task->is_not_chunked()) {
47 if (obj->is_instance()) {
48 // Case 1: Normal oop, process as usual.
52 // time we visit it, start the chunked processing.
53 do_chunked_array_start<T>(q, cl, obj);
54 } else {
55 // Case 3: Primitive array. Do nothing, no oops there. We use the same
56 // performance tweak TypeArrayKlass::oop_oop_iterate_impl is using:
57 // We skip iterating over the klass pointer since we know that
58 // Universe::TypeArrayKlass never moves.
59 assert (obj->is_typeArray(), "should be type array");
60 }
61 // Count liveness the last: push the outstanding work to the queues first
62 count_liveness(live_data, obj);
63 } else {
64 // Case 4: Array chunk, has sensible chunk id. Process it.
65 do_chunked_array<T>(q, cl, obj, task->chunk(), task->pow());
66 }
67 }
68
69 inline void ShenandoahConcurrentMark::count_liveness(jushort* live_data, oop obj) {
70 size_t region_idx = _heap->heap_region_index_containing(obj);
71 ShenandoahHeapRegion* region = _heap->get_region(region_idx);
72 size_t size = obj->size() + ShenandoahForwarding::word_size();
73
74 if (!region->is_humongous_start()) {
75 assert(!region->is_humongous(), "Cannot have continuations here");
76 size_t max = (1 << (sizeof(jushort) * 8)) - 1;
77 if (size >= max) {
78 // too big, add to region data directly
79 region->increase_live_data_gc_words(size);
80 } else {
81 jushort cur = live_data[region_idx];
82 size_t new_val = cur + size;
83 if (new_val >= max) {
84 // overflow, flush to region data
85 region->increase_live_data_gc_words(new_val);
86 live_data[region_idx] = 0;
87 } else {
88 // still good, remember in locals
89 live_data[region_idx] = (jushort) new_val;
90 }
91 }
92 } else {
|
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_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_INLINE_HPP
25 #define SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_INLINE_HPP
26
27 #include "gc/shenandoah/shenandoahAsserts.hpp"
28 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
29 #include "gc/shenandoah/shenandoahConcurrentMark.hpp"
30 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
31 #include "gc/shenandoah/shenandoahStringDedup.inline.hpp"
32 #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
33 #include "memory/iterator.inline.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "runtime/prefetch.inline.hpp"
36
37 template <class T>
38 void ShenandoahConcurrentMark::do_task(ShenandoahObjToScanQueue* q, T* cl, jushort* live_data, ShenandoahMarkTask* task) {
39 oop obj = task->obj();
40
41 shenandoah_assert_not_forwarded_except(NULL, obj, _heap->is_concurrent_traversal_in_progress() && _heap->cancelled_gc());
42 shenandoah_assert_marked(NULL, obj);
43 shenandoah_assert_not_in_cset_except(NULL, obj, _heap->cancelled_gc());
44
45 if (task->is_not_chunked()) {
46 if (obj->is_instance()) {
47 // Case 1: Normal oop, process as usual.
51 // time we visit it, start the chunked processing.
52 do_chunked_array_start<T>(q, cl, obj);
53 } else {
54 // Case 3: Primitive array. Do nothing, no oops there. We use the same
55 // performance tweak TypeArrayKlass::oop_oop_iterate_impl is using:
56 // We skip iterating over the klass pointer since we know that
57 // Universe::TypeArrayKlass never moves.
58 assert (obj->is_typeArray(), "should be type array");
59 }
60 // Count liveness the last: push the outstanding work to the queues first
61 count_liveness(live_data, obj);
62 } else {
63 // Case 4: Array chunk, has sensible chunk id. Process it.
64 do_chunked_array<T>(q, cl, obj, task->chunk(), task->pow());
65 }
66 }
67
68 inline void ShenandoahConcurrentMark::count_liveness(jushort* live_data, oop obj) {
69 size_t region_idx = _heap->heap_region_index_containing(obj);
70 ShenandoahHeapRegion* region = _heap->get_region(region_idx);
71 size_t size = obj->size();
72
73 if (!region->is_humongous_start()) {
74 assert(!region->is_humongous(), "Cannot have continuations here");
75 size_t max = (1 << (sizeof(jushort) * 8)) - 1;
76 if (size >= max) {
77 // too big, add to region data directly
78 region->increase_live_data_gc_words(size);
79 } else {
80 jushort cur = live_data[region_idx];
81 size_t new_val = cur + size;
82 if (new_val >= max) {
83 // overflow, flush to region data
84 region->increase_live_data_gc_words(new_val);
85 live_data[region_idx] = 0;
86 } else {
87 // still good, remember in locals
88 live_data[region_idx] = (jushort) new_val;
89 }
90 }
91 } else {
|