author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 38302 | hotspot/src/share/vm/gc/parallel/psScavenge.inline.hpp@1c18282d702d |
child 47580 | 96392e113a0a |
permissions | -rw-r--r-- |
1 | 1 |
/* |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
29208
diff
changeset
|
2 |
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_PARALLEL_PSSCAVENGE_INLINE_HPP |
26 |
#define SHARE_VM_GC_PARALLEL_PSSCAVENGE_INLINE_HPP |
|
7397 | 27 |
|
30764 | 28 |
#include "gc/parallel/cardTableExtension.hpp" |
29 |
#include "gc/parallel/parallelScavengeHeap.hpp" |
|
30 |
#include "gc/parallel/psPromotionManager.inline.hpp" |
|
31 |
#include "gc/parallel/psScavenge.hpp" |
|
35061 | 32 |
#include "logging/log.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
33 |
#include "memory/iterator.hpp" |
37248 | 34 |
#include "memory/resourceArea.hpp" |
24098
48f07e2c74de
8039957: Replace the last few %p usages with PTR_FORMAT in the GC code
stefank
parents:
20282
diff
changeset
|
35 |
#include "utilities/globalDefinitions.hpp" |
7397 | 36 |
|
1 | 37 |
inline void PSScavenge::save_to_space_top_before_gc() { |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
29208
diff
changeset
|
38 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 39 |
_to_space_top_before_gc = heap->young_gen()->to_space()->top(); |
40 |
} |
|
41 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
42 |
template <class T> inline bool PSScavenge::should_scavenge(T* p) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
43 |
T heap_oop = oopDesc::load_heap_oop(p); |
17852
59b05e1db547
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
13728
diff
changeset
|
44 |
return PSScavenge::is_obj_in_young(heap_oop); |
1 | 45 |
} |
46 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
47 |
template <class T> |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
48 |
inline bool PSScavenge::should_scavenge(T* p, MutableSpace* to_space) { |
1 | 49 |
if (should_scavenge(p)) { |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
50 |
oop obj = oopDesc::load_decode_heap_oop_not_null(p); |
1 | 51 |
// Skip objects copied to to_space since the scavenge started. |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
52 |
HeapWord* const addr = (HeapWord*)obj; |
1 | 53 |
return addr < to_space_top_before_gc() || addr >= to_space->end(); |
54 |
} |
|
55 |
return false; |
|
56 |
} |
|
57 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
58 |
template <class T> |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
59 |
inline bool PSScavenge::should_scavenge(T* p, bool check_to_space) { |
1 | 60 |
if (check_to_space) { |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
29208
diff
changeset
|
61 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 62 |
return should_scavenge(p, heap->young_gen()->to_space()); |
63 |
} |
|
64 |
return should_scavenge(p); |
|
65 |
} |
|
66 |
||
11753 | 67 |
template<bool promote_immediately> |
68 |
class PSRootsClosure: public OopClosure { |
|
8728
3f1bcd33068e
6962931: move interned strings out of the perm gen
jcoomes
parents:
7397
diff
changeset
|
69 |
private: |
3f1bcd33068e
6962931: move interned strings out of the perm gen
jcoomes
parents:
7397
diff
changeset
|
70 |
PSPromotionManager* _promotion_manager; |
3f1bcd33068e
6962931: move interned strings out of the perm gen
jcoomes
parents:
7397
diff
changeset
|
71 |
|
3f1bcd33068e
6962931: move interned strings out of the perm gen
jcoomes
parents:
7397
diff
changeset
|
72 |
protected: |
3f1bcd33068e
6962931: move interned strings out of the perm gen
jcoomes
parents:
7397
diff
changeset
|
73 |
template <class T> void do_oop_work(T *p) { |
3f1bcd33068e
6962931: move interned strings out of the perm gen
jcoomes
parents:
7397
diff
changeset
|
74 |
if (PSScavenge::should_scavenge(p)) { |
3f1bcd33068e
6962931: move interned strings out of the perm gen
jcoomes
parents:
7397
diff
changeset
|
75 |
// We never card mark roots, maybe call a func without test? |
29208
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
24424
diff
changeset
|
76 |
_promotion_manager->copy_and_push_safe_barrier<T, promote_immediately>(p); |
8728
3f1bcd33068e
6962931: move interned strings out of the perm gen
jcoomes
parents:
7397
diff
changeset
|
77 |
} |
3f1bcd33068e
6962931: move interned strings out of the perm gen
jcoomes
parents:
7397
diff
changeset
|
78 |
} |
3f1bcd33068e
6962931: move interned strings out of the perm gen
jcoomes
parents:
7397
diff
changeset
|
79 |
public: |
11753 | 80 |
PSRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { } |
81 |
void do_oop(oop* p) { PSRootsClosure::do_oop_work(p); } |
|
82 |
void do_oop(narrowOop* p) { PSRootsClosure::do_oop_work(p); } |
|
8728
3f1bcd33068e
6962931: move interned strings out of the perm gen
jcoomes
parents:
7397
diff
changeset
|
83 |
}; |
3f1bcd33068e
6962931: move interned strings out of the perm gen
jcoomes
parents:
7397
diff
changeset
|
84 |
|
11753 | 85 |
typedef PSRootsClosure</*promote_immediately=*/false> PSScavengeRootsClosure; |
86 |
typedef PSRootsClosure</*promote_immediately=*/true> PSPromoteRootsClosure; |
|
87 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
88 |
// Scavenges a single oop in a Klass. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
89 |
class PSScavengeFromKlassClosure: public OopClosure { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
90 |
private: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
91 |
PSPromotionManager* _pm; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
92 |
// Used to redirty a scanned klass if it has oops |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
93 |
// pointing to the young generation after being scanned. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
94 |
Klass* _scanned_klass; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
95 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
96 |
PSScavengeFromKlassClosure(PSPromotionManager* pm) : _pm(pm), _scanned_klass(NULL) { } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
97 |
void do_oop(narrowOop* p) { ShouldNotReachHere(); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
98 |
void do_oop(oop* p) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
99 |
ParallelScavengeHeap* psh = ParallelScavengeHeap::heap(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
100 |
assert(!psh->is_in_reserved(p), "GC barrier needed"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
101 |
if (PSScavenge::should_scavenge(p)) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
102 |
assert(PSScavenge::should_scavenge(p, true), "revisiting object?"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
103 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
104 |
oop o = *p; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
105 |
oop new_obj; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
106 |
if (o->is_forwarded()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
107 |
new_obj = o->forwardee(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
108 |
} else { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
109 |
new_obj = _pm->copy_to_survivor_space</*promote_immediately=*/false>(o); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
110 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
111 |
oopDesc::encode_store_heap_oop_not_null(p, new_obj); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
112 |
|
17852
59b05e1db547
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
13728
diff
changeset
|
113 |
if (PSScavenge::is_obj_in_young(new_obj)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
114 |
do_klass_barrier(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
115 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
116 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
117 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
118 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
119 |
void set_scanned_klass(Klass* klass) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
120 |
assert(_scanned_klass == NULL || klass == NULL, "Should always only handling one klass at a time"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
121 |
_scanned_klass = klass; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
122 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
123 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
124 |
private: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
125 |
void do_klass_barrier() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
126 |
assert(_scanned_klass != NULL, "Should not be called without having a scanned klass"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
127 |
_scanned_klass->record_modified_oops(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
128 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
129 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
130 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
131 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
132 |
// Scavenges the oop in a Klass. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
133 |
class PSScavengeKlassClosure: public KlassClosure { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
134 |
private: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
135 |
PSScavengeFromKlassClosure _oop_closure; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
136 |
protected: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
137 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
138 |
PSScavengeKlassClosure(PSPromotionManager* pm) : _oop_closure(pm) { } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
139 |
void do_klass(Klass* klass) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
140 |
// If the klass has not been dirtied we know that there's |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
141 |
// no references into the young gen and we can skip it. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
142 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
143 |
if (klass->has_modified_oops()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
144 |
// Clean the klass since we're going to scavenge all the metadata. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
145 |
klass->clear_modified_oops(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
146 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
147 |
// Setup the promotion manager to redirty this klass |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
148 |
// if references are left in the young gen. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
149 |
_oop_closure.set_scanned_klass(klass); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
150 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
151 |
klass->oops_do(&_oop_closure); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
152 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
153 |
_oop_closure.set_scanned_klass(NULL); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
154 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
155 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
156 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11753
diff
changeset
|
157 |
|
30764 | 158 |
#endif // SHARE_VM_GC_PARALLEL_PSSCAVENGE_INLINE_HPP |