Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp
+++ new/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp
1 1 /*
2 - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
2 + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP
26 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP
27 27
28 28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
29 29 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
30 30 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
31 +#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
31 32 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
32 33
33 34 inline void PSScavenge::save_to_space_top_before_gc() {
34 35 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
35 36 _to_space_top_before_gc = heap->young_gen()->to_space()->top();
36 37 }
37 38
38 39 template <class T> inline bool PSScavenge::should_scavenge(T* p) {
39 40 T heap_oop = oopDesc::load_heap_oop(p);
40 41 if (oopDesc::is_null(heap_oop)) return false;
41 42 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
42 43 return PSScavenge::is_obj_in_young((HeapWord*)obj);
43 44 }
44 45
45 46 template <class T>
46 47 inline bool PSScavenge::should_scavenge(T* p, MutableSpace* to_space) {
47 48 if (should_scavenge(p)) {
48 49 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
49 50 // Skip objects copied to to_space since the scavenge started.
50 51 HeapWord* const addr = (HeapWord*)obj;
51 52 return addr < to_space_top_before_gc() || addr >= to_space->end();
52 53 }
53 54 return false;
54 55 }
55 56
56 57 template <class T>
57 58 inline bool PSScavenge::should_scavenge(T* p, bool check_to_space) {
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
58 59 if (check_to_space) {
59 60 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
60 61 return should_scavenge(p, heap->young_gen()->to_space());
61 62 }
62 63 return should_scavenge(p);
63 64 }
64 65
65 66 // Attempt to "claim" oop at p via CAS, push the new obj if successful
66 67 // This version tests the oop* to make sure it is within the heap before
67 68 // attempting marking.
68 -template <class T>
69 +template <class T, bool promote_immediately>
69 70 inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm,
70 71 T* p) {
71 72 assert(should_scavenge(p, true), "revisiting object?");
72 73
73 74 oop o = oopDesc::load_decode_heap_oop_not_null(p);
74 75 oop new_obj = o->is_forwarded()
75 76 ? o->forwardee()
76 - : pm->copy_to_survivor_space(o);
77 + : pm->copy_to_survivor_space<promote_immediately>(o);
77 78 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
78 79
79 80 // We cannot mark without test, as some code passes us pointers
80 81 // that are outside the heap.
81 82 if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) &&
82 83 Universe::heap()->is_in_reserved(p)) {
83 84 if (PSScavenge::is_obj_in_young((HeapWord*)new_obj)) {
84 85 card_table()->inline_write_ref_field_gc(p, new_obj);
85 86 }
86 87 }
87 88 }
88 89
90 +template<bool promote_immediately>
89 91 class PSScavengeRootsClosure: public OopClosure {
90 92 private:
91 93 PSPromotionManager* _promotion_manager;
92 94
93 95 protected:
94 96 template <class T> void do_oop_work(T *p) {
95 97 if (PSScavenge::should_scavenge(p)) {
96 98 // We never card mark roots, maybe call a func without test?
97 - PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p);
99 + PSScavenge::copy_and_push_safe_barrier<T, promote_immediately>(_promotion_manager, p);
98 100 }
99 101 }
100 102 public:
101 103 PSScavengeRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
102 104 void do_oop(oop* p) { PSScavengeRootsClosure::do_oop_work(p); }
103 105 void do_oop(narrowOop* p) { PSScavengeRootsClosure::do_oop_work(p); }
104 106 };
105 107
108 +
106 109 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX