1 /*
2 * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
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 inline void PSScavenge::save_to_space_top_before_gc() {
26 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
27 _to_space_top_before_gc = heap->young_gen()->to_space()->top();
28 }
29
30 template <class T> inline bool PSScavenge::should_scavenge(T* p) {
31 T heap_oop = oopDesc::load_heap_oop(p);
32 if (oopDesc::is_null(heap_oop)) return false;
33 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
34 return PSScavenge::is_obj_in_young((HeapWord*)obj);
35 }
36
37 template <class T>
38 inline bool PSScavenge::should_scavenge(T* p, MutableSpace* to_space) {
39 if (should_scavenge(p)) {
40 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
41 // Skip objects copied to to_space since the scavenge started.
42 HeapWord* const addr = (HeapWord*)obj;
43 return addr < to_space_top_before_gc() || addr >= to_space->end();
44 }
60 template <class T>
61 inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm,
62 T* p) {
63 assert(should_scavenge(p, true), "revisiting object?");
64
65 oop o = oopDesc::load_decode_heap_oop_not_null(p);
66 oop new_obj = o->is_forwarded()
67 ? o->forwardee()
68 : pm->copy_to_survivor_space(o);
69 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
70
71 // We cannot mark without test, as some code passes us pointers
72 // that are outside the heap.
73 if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) &&
74 Universe::heap()->is_in_reserved(p)) {
75 if (PSScavenge::is_obj_in_young((HeapWord*)new_obj)) {
76 card_table()->inline_write_ref_field_gc(p, new_obj);
77 }
78 }
79 }
|
1 /*
2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
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_PSSCAVENGE_INLINE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP
27
28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
29 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
30 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
31 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
32
33 inline void PSScavenge::save_to_space_top_before_gc() {
34 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
35 _to_space_top_before_gc = heap->young_gen()->to_space()->top();
36 }
37
38 template <class T> inline bool PSScavenge::should_scavenge(T* p) {
39 T heap_oop = oopDesc::load_heap_oop(p);
40 if (oopDesc::is_null(heap_oop)) return false;
41 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
42 return PSScavenge::is_obj_in_young((HeapWord*)obj);
43 }
44
45 template <class T>
46 inline bool PSScavenge::should_scavenge(T* p, MutableSpace* to_space) {
47 if (should_scavenge(p)) {
48 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
49 // Skip objects copied to to_space since the scavenge started.
50 HeapWord* const addr = (HeapWord*)obj;
51 return addr < to_space_top_before_gc() || addr >= to_space->end();
52 }
68 template <class T>
69 inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm,
70 T* p) {
71 assert(should_scavenge(p, true), "revisiting object?");
72
73 oop o = oopDesc::load_decode_heap_oop_not_null(p);
74 oop new_obj = o->is_forwarded()
75 ? o->forwardee()
76 : pm->copy_to_survivor_space(o);
77 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
78
79 // We cannot mark without test, as some code passes us pointers
80 // that are outside the heap.
81 if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) &&
82 Universe::heap()->is_in_reserved(p)) {
83 if (PSScavenge::is_obj_in_young((HeapWord*)new_obj)) {
84 card_table()->inline_write_ref_field_gc(p, new_obj);
85 }
86 }
87 }
88
89 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP
|