author | coleenp |
Thu, 10 Jan 2019 15:13:51 -0500 | |
changeset 53244 | 9807daeb47c4 |
parent 52117 | a2edf32cd813 |
child 57777 | 90ead0febf56 |
child 58678 | 9cf78a70fa4f |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52117
diff
changeset
|
2 |
* Copyright (c) 2002, 2019, 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:
3262
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3262
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:
3262
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52117
diff
changeset
|
25 |
#ifndef SHARE_GC_PARALLEL_PSPROMOTIONMANAGER_INLINE_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52117
diff
changeset
|
26 |
#define SHARE_GC_PARALLEL_PSPROMOTIONMANAGER_INLINE_HPP |
7397 | 27 |
|
30764 | 28 |
#include "gc/parallel/parallelScavengeHeap.hpp" |
46502
116a09d8f142
8180755: Remove use of bitMap.inline.hpp include from instanceKlass.hpp and c1_ValueSet.hpp
tschatzl
parents:
35901
diff
changeset
|
29 |
#include "gc/parallel/parMarkBitMap.inline.hpp" |
30764 | 30 |
#include "gc/parallel/psOldGen.hpp" |
31 |
#include "gc/parallel/psPromotionLAB.inline.hpp" |
|
32 |
#include "gc/parallel/psPromotionManager.hpp" |
|
52117
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
33 |
#include "gc/parallel/psScavenge.inline.hpp" |
30764 | 34 |
#include "gc/shared/taskqueue.inline.hpp" |
35061 | 35 |
#include "logging/log.hpp" |
52117
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
36 |
#include "memory/iterator.inline.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47216
diff
changeset
|
37 |
#include "oops/access.inline.hpp" |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29792
diff
changeset
|
38 |
#include "oops/oop.inline.hpp" |
7397 | 39 |
|
31330
77061bb01b18
8081382: Make flags ParallelGCThreads and ConcGCThreads of type uint
david
parents:
30764
diff
changeset
|
40 |
inline PSPromotionManager* PSPromotionManager::manager_array(uint index) { |
1 | 41 |
assert(_manager_array != NULL, "access of NULL manager_array"); |
31330
77061bb01b18
8081382: Make flags ParallelGCThreads and ConcGCThreads of type uint
david
parents:
30764
diff
changeset
|
42 |
assert(index <= ParallelGCThreads, "out of range manager_array access"); |
19285
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18025
diff
changeset
|
43 |
return &_manager_array[index]; |
1 | 44 |
} |
45 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
46 |
template <class T> |
30566
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
47 |
inline void PSPromotionManager::push_depth(T* p) { |
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
48 |
claimed_stack_depth()->push(p); |
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
49 |
} |
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
50 |
|
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
51 |
template <class T> |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
52 |
inline void PSPromotionManager::claim_or_forward_internal_depth(T* p) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
53 |
if (p != NULL) { // XXX: error if p != NULL here |
50728 | 54 |
oop o = RawAccess<IS_NOT_NULL>::oop_load(p); |
1 | 55 |
if (o->is_forwarded()) { |
56 |
o = o->forwardee(); |
|
57 |
// Card mark |
|
17852
59b05e1db547
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
13925
diff
changeset
|
58 |
if (PSScavenge::is_obj_in_young(o)) { |
1 | 59 |
PSScavenge::card_table()->inline_write_ref_field_gc(p, o); |
60 |
} |
|
50728 | 61 |
RawAccess<IS_NOT_NULL>::oop_store(p, o); |
1 | 62 |
} else { |
63 |
push_depth(p); |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
67 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
68 |
template <class T> |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
69 |
inline void PSPromotionManager::claim_or_forward_depth(T* p) { |
29208
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
70 |
assert(should_scavenge(p, true), "revisiting object?"); |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
71 |
assert(ParallelScavengeHeap::heap()->is_in(p), "pointer outside heap"); |
1 | 72 |
|
73 |
claim_or_forward_internal_depth(p); |
|
74 |
} |
|
75 |
||
28177
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
76 |
inline void PSPromotionManager::promotion_trace_event(oop new_obj, oop old_obj, |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
77 |
size_t obj_size, |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
78 |
uint age, bool tenured, |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
79 |
const PSPromotionLAB* lab) { |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
80 |
// Skip if memory allocation failed |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
81 |
if (new_obj != NULL) { |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
82 |
const ParallelScavengeTracer* gc_tracer = PSScavenge::gc_tracer(); |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
83 |
|
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
84 |
if (lab != NULL) { |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
85 |
// Promotion of object through newly allocated PLAB |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
86 |
if (gc_tracer->should_report_promotion_in_new_plab_event()) { |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
87 |
size_t obj_bytes = obj_size * HeapWordSize; |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
88 |
size_t lab_size = lab->capacity(); |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
89 |
gc_tracer->report_promotion_in_new_plab_event(old_obj->klass(), obj_bytes, |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
90 |
age, tenured, lab_size); |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
91 |
} |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
92 |
} else { |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
93 |
// Promotion of object directly to heap |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
94 |
if (gc_tracer->should_report_promotion_outside_plab_event()) { |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
95 |
size_t obj_bytes = obj_size * HeapWordSize; |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
96 |
gc_tracer->report_promotion_outside_plab_event(old_obj->klass(), obj_bytes, |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
97 |
age, tenured); |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
98 |
} |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
99 |
} |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
100 |
} |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
101 |
} |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
102 |
|
52117
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
103 |
class PSPushContentsClosure: public BasicOopIterateClosure { |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
104 |
PSPromotionManager* _pm; |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
105 |
public: |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
106 |
PSPushContentsClosure(PSPromotionManager* pm) : BasicOopIterateClosure(PSScavenge::reference_processor()), _pm(pm) {} |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
107 |
|
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
108 |
template <typename T> void do_oop_nv(T* p) { |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
109 |
if (PSScavenge::should_scavenge(p)) { |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
110 |
_pm->claim_or_forward_depth(p); |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
111 |
} |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
112 |
} |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
113 |
|
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
114 |
virtual void do_oop(oop* p) { do_oop_nv(p); } |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
115 |
virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
116 |
|
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
117 |
// Don't use the oop verification code in the oop_oop_iterate framework. |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
118 |
debug_only(virtual bool should_verify_oops() { return false; }) |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
119 |
}; |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
120 |
|
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
121 |
// |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
122 |
// This closure specialization will override the one that is defined in |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
123 |
// instanceRefKlass.inline.cpp. It swaps the order of oop_oop_iterate and |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
124 |
// oop_oop_iterate_ref_processing. Unfortunately G1 and Parallel behaves |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
125 |
// significantly better (especially in the Derby benchmark) using opposite |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
126 |
// order of these function calls. |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
127 |
// |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
128 |
template <> |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
129 |
inline void InstanceRefKlass::oop_oop_iterate_reverse<oop, PSPushContentsClosure>(oop obj, PSPushContentsClosure* closure) { |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
130 |
oop_oop_iterate_ref_processing<oop>(obj, closure); |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
131 |
InstanceKlass::oop_oop_iterate_reverse<oop>(obj, closure); |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
132 |
} |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
133 |
|
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
134 |
template <> |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
135 |
inline void InstanceRefKlass::oop_oop_iterate_reverse<narrowOop, PSPushContentsClosure>(oop obj, PSPushContentsClosure* closure) { |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
136 |
oop_oop_iterate_ref_processing<narrowOop>(obj, closure); |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
137 |
InstanceKlass::oop_oop_iterate_reverse<narrowOop>(obj, closure); |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
138 |
} |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
139 |
|
29792
8c6fa07f0869
8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents:
29208
diff
changeset
|
140 |
inline void PSPromotionManager::push_contents(oop obj) { |
52117
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
141 |
if (!obj->klass()->is_typeArray_klass()) { |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
142 |
PSPushContentsClosure pcc(this); |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
143 |
obj->oop_iterate_backwards(&pcc); |
a2edf32cd813
8201436: Replace oop_ps_push_contents with oop_iterate and closure
lkorinth
parents:
51292
diff
changeset
|
144 |
} |
29792
8c6fa07f0869
8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents:
29208
diff
changeset
|
145 |
} |
11753 | 146 |
// |
147 |
// This method is pretty bulky. It would be nice to split it up |
|
148 |
// into smaller submethods, but we need to be careful not to hurt |
|
149 |
// performance. |
|
150 |
// |
|
151 |
template<bool promote_immediately> |
|
30566
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
152 |
inline oop PSPromotionManager::copy_to_survivor_space(oop o) { |
29208
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
153 |
assert(should_scavenge(&o), "Sanity"); |
11753 | 154 |
|
155 |
oop new_obj = NULL; |
|
156 |
||
157 |
// NOTE! We must be very careful with any methods that access the mark |
|
158 |
// in o. There may be multiple threads racing on it, and it may be forwarded |
|
159 |
// at any time. Do not use oop methods for accessing the mark! |
|
49722
a47d1e21b3f1
8199735: Mark word updates need to use Access API
rkennke
parents:
49592
diff
changeset
|
160 |
markOop test_mark = o->mark_raw(); |
11753 | 161 |
|
162 |
// The same test as "o->is_forwarded()" |
|
163 |
if (!test_mark->is_marked()) { |
|
164 |
bool new_obj_is_tenured = false; |
|
165 |
size_t new_obj_size = o->size(); |
|
166 |
||
28177
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
167 |
// Find the objects age, MT safe. |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
168 |
uint age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ? |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
169 |
test_mark->displaced_mark_helper()->age() : test_mark->age(); |
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
170 |
|
11753 | 171 |
if (!promote_immediately) { |
172 |
// Try allocating obj in to-space (unless too old) |
|
173 |
if (age < PSScavenge::tenuring_threshold()) { |
|
174 |
new_obj = (oop) _young_lab.allocate(new_obj_size); |
|
175 |
if (new_obj == NULL && !_young_gen_is_full) { |
|
176 |
// Do we allocate directly, or flush and refill? |
|
177 |
if (new_obj_size > (YoungPLABSize / 2)) { |
|
178 |
// Allocate this object directly |
|
179 |
new_obj = (oop)young_space()->cas_allocate(new_obj_size); |
|
28177
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
180 |
promotion_trace_event(new_obj, o, new_obj_size, age, false, NULL); |
11753 | 181 |
} else { |
182 |
// Flush and fill |
|
183 |
_young_lab.flush(); |
|
184 |
||
185 |
HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize); |
|
186 |
if (lab_base != NULL) { |
|
187 |
_young_lab.initialize(MemRegion(lab_base, YoungPLABSize)); |
|
188 |
// Try the young lab allocation again. |
|
189 |
new_obj = (oop) _young_lab.allocate(new_obj_size); |
|
28177
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
190 |
promotion_trace_event(new_obj, o, new_obj_size, age, false, &_young_lab); |
11753 | 191 |
} else { |
192 |
_young_gen_is_full = true; |
|
193 |
} |
|
194 |
} |
|
195 |
} |
|
196 |
} |
|
197 |
} |
|
198 |
||
199 |
// Otherwise try allocating obj tenured |
|
200 |
if (new_obj == NULL) { |
|
201 |
#ifndef PRODUCT |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
202 |
if (ParallelScavengeHeap::heap()->promotion_should_fail()) { |
11753 | 203 |
return oop_promotion_failed(o, test_mark); |
204 |
} |
|
205 |
#endif // #ifndef PRODUCT |
|
206 |
||
207 |
new_obj = (oop) _old_lab.allocate(new_obj_size); |
|
208 |
new_obj_is_tenured = true; |
|
209 |
||
210 |
if (new_obj == NULL) { |
|
211 |
if (!_old_gen_is_full) { |
|
212 |
// Do we allocate directly, or flush and refill? |
|
213 |
if (new_obj_size > (OldPLABSize / 2)) { |
|
214 |
// Allocate this object directly |
|
215 |
new_obj = (oop)old_gen()->cas_allocate(new_obj_size); |
|
28177
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
216 |
promotion_trace_event(new_obj, o, new_obj_size, age, true, NULL); |
11753 | 217 |
} else { |
218 |
// Flush and fill |
|
219 |
_old_lab.flush(); |
|
220 |
||
221 |
HeapWord* lab_base = old_gen()->cas_allocate(OldPLABSize); |
|
222 |
if(lab_base != NULL) { |
|
13924 | 223 |
#ifdef ASSERT |
224 |
// Delay the initialization of the promotion lab (plab). |
|
225 |
// This exposes uninitialized plabs to card table processing. |
|
226 |
if (GCWorkerDelayMillis > 0) { |
|
227 |
os::sleep(Thread::current(), GCWorkerDelayMillis, false); |
|
228 |
} |
|
229 |
#endif |
|
11753 | 230 |
_old_lab.initialize(MemRegion(lab_base, OldPLABSize)); |
231 |
// Try the old lab allocation again. |
|
232 |
new_obj = (oop) _old_lab.allocate(new_obj_size); |
|
28177
318600b0d7db
8066442: Add PS and ParOld support for promotion event
sfriberg
parents:
25905
diff
changeset
|
233 |
promotion_trace_event(new_obj, o, new_obj_size, age, true, &_old_lab); |
11753 | 234 |
} |
235 |
} |
|
236 |
} |
|
237 |
||
238 |
// This is the promotion failed test, and code handling. |
|
239 |
// The code belongs here for two reasons. It is slightly |
|
18025 | 240 |
// different than the code below, and cannot share the |
11753 | 241 |
// CAS testing code. Keeping the code here also minimizes |
242 |
// the impact on the common case fast path code. |
|
243 |
||
244 |
if (new_obj == NULL) { |
|
245 |
_old_gen_is_full = true; |
|
246 |
return oop_promotion_failed(o, test_mark); |
|
247 |
} |
|
248 |
} |
|
249 |
} |
|
250 |
||
251 |
assert(new_obj != NULL, "allocation should have succeeded"); |
|
252 |
||
253 |
// Copy obj |
|
254 |
Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size); |
|
255 |
||
256 |
// Now we have to CAS in the header. |
|
50398
4d6a5c267541
8154736: enhancement of cmpxchg and copy_to_survivor for ppc64
mhorie
parents:
49722
diff
changeset
|
257 |
// Make copy visible to threads reading the forwardee. |
4d6a5c267541
8154736: enhancement of cmpxchg and copy_to_survivor for ppc64
mhorie
parents:
49722
diff
changeset
|
258 |
if (o->cas_forward_to(new_obj, test_mark, memory_order_release)) { |
11753 | 259 |
// We won any races, we "own" this object. |
260 |
assert(new_obj == o->forwardee(), "Sanity"); |
|
261 |
||
262 |
// Increment age if obj still in new generation. Now that |
|
263 |
// we're dealing with a markOop that cannot change, it is |
|
264 |
// okay to use the non mt safe oop methods. |
|
265 |
if (!new_obj_is_tenured) { |
|
266 |
new_obj->incr_age(); |
|
267 |
assert(young_space()->contains(new_obj), "Attempt to push non-promoted obj"); |
|
268 |
} |
|
269 |
||
270 |
// Do the size comparison first with new_obj_size, which we |
|
271 |
// already have. Hopefully, only a few objects are larger than |
|
272 |
// _min_array_size_for_chunking, and most of them will be arrays. |
|
273 |
// So, the is->objArray() test would be very infrequent. |
|
274 |
if (new_obj_size > _min_array_size_for_chunking && |
|
275 |
new_obj->is_objArray() && |
|
276 |
PSChunkLargeArrays) { |
|
277 |
// we'll chunk it |
|
278 |
oop* const masked_o = mask_chunked_array_oop(o); |
|
279 |
push_depth(masked_o); |
|
280 |
TASKQUEUE_STATS_ONLY(++_arrays_chunked; ++_masked_pushes); |
|
281 |
} else { |
|
282 |
// we'll just push its contents |
|
29792
8c6fa07f0869
8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents:
29208
diff
changeset
|
283 |
push_contents(new_obj); |
11753 | 284 |
} |
285 |
} else { |
|
286 |
// We lost, someone else "owns" this object |
|
287 |
guarantee(o->is_forwarded(), "Object must be forwarded if the cas failed."); |
|
288 |
||
289 |
// Try to deallocate the space. If it was directly allocated we cannot |
|
290 |
// deallocate it, so we have to test. If the deallocation fails, |
|
291 |
// overwrite with a filler object. |
|
292 |
if (new_obj_is_tenured) { |
|
293 |
if (!_old_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) { |
|
294 |
CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size); |
|
295 |
} |
|
296 |
} else if (!_young_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) { |
|
297 |
CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size); |
|
298 |
} |
|
299 |
||
300 |
// don't update this before the unallocation! |
|
50398
4d6a5c267541
8154736: enhancement of cmpxchg and copy_to_survivor for ppc64
mhorie
parents:
49722
diff
changeset
|
301 |
// Using acquire though consume would be accurate for accessing new_obj. |
4d6a5c267541
8154736: enhancement of cmpxchg and copy_to_survivor for ppc64
mhorie
parents:
49722
diff
changeset
|
302 |
new_obj = o->forwardee_acquire(); |
11753 | 303 |
} |
304 |
} else { |
|
305 |
assert(o->is_forwarded(), "Sanity"); |
|
50398
4d6a5c267541
8154736: enhancement of cmpxchg and copy_to_survivor for ppc64
mhorie
parents:
49722
diff
changeset
|
306 |
new_obj = o->forwardee_acquire(); |
11753 | 307 |
} |
308 |
||
309 |
// This code must come after the CAS test, or it will print incorrect |
|
310 |
// information. |
|
35061 | 311 |
log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", |
312 |
should_scavenge(&new_obj) ? "copying" : "tenuring", |
|
313 |
new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); |
|
11753 | 314 |
|
315 |
return new_obj; |
|
316 |
} |
|
317 |
||
29208
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
318 |
// Attempt to "claim" oop at p via CAS, push the new obj if successful |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
319 |
// This version tests the oop* to make sure it is within the heap before |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
320 |
// attempting marking. |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
321 |
template <class T, bool promote_immediately> |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
322 |
inline void PSPromotionManager::copy_and_push_safe_barrier(T* p) { |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
323 |
assert(should_scavenge(p, true), "revisiting object?"); |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
324 |
|
50728 | 325 |
oop o = RawAccess<IS_NOT_NULL>::oop_load(p); |
29208
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
326 |
oop new_obj = o->is_forwarded() |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
327 |
? o->forwardee() |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
328 |
: copy_to_survivor_space<promote_immediately>(o); |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
329 |
|
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
330 |
// This code must come after the CAS test, or it will print incorrect |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
331 |
// information. |
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35061
diff
changeset
|
332 |
if (log_develop_is_enabled(Trace, gc, scavenge) && o->is_forwarded()) { |
35061 | 333 |
log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", |
334 |
"forwarding", |
|
335 |
new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); |
|
29208
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
336 |
} |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
337 |
|
50728 | 338 |
RawAccess<IS_NOT_NULL>::oop_store(p, new_obj); |
29208
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
339 |
|
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
340 |
// We cannot mark without test, as some code passes us pointers |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
341 |
// that are outside the heap. These pointers are either from roots |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
342 |
// or from metadata. |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
343 |
if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) && |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
344 |
ParallelScavengeHeap::heap()->is_in_reserved(p)) { |
29208
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
345 |
if (PSScavenge::is_obj_in_young(new_obj)) { |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
346 |
PSScavenge::card_table()->inline_write_ref_field_gc(p, new_obj); |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
347 |
} |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
348 |
} |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
349 |
} |
11753 | 350 |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
351 |
inline void PSPromotionManager::process_popped_location_depth(StarTask p) { |
1 | 352 |
if (is_oop_masked(p)) { |
353 |
assert(PSChunkLargeArrays, "invariant"); |
|
354 |
oop const old = unmask_chunked_array_oop(p); |
|
355 |
process_array_chunk(old); |
|
356 |
} else { |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
357 |
if (p.is_narrow()) { |
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
670
diff
changeset
|
358 |
assert(UseCompressedOops, "Error"); |
29208
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
359 |
copy_and_push_safe_barrier<narrowOop, /*promote_immediately=*/false>(p); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
360 |
} else { |
29208
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
28177
diff
changeset
|
361 |
copy_and_push_safe_barrier<oop, /*promote_immediately=*/false>(p); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
362 |
} |
1 | 363 |
} |
364 |
} |
|
6067 | 365 |
|
51292
0538a5cdb474
8205921: Optimizing best-of-2 work stealing queue selection
zgu
parents:
50728
diff
changeset
|
366 |
inline bool PSPromotionManager::steal_depth(int queue_num, StarTask& t) { |
0538a5cdb474
8205921: Optimizing best-of-2 work stealing queue selection
zgu
parents:
50728
diff
changeset
|
367 |
return stack_array_depth()->steal(queue_num, t); |
30566
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
368 |
} |
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
369 |
|
6067 | 370 |
#if TASKQUEUE_STATS |
371 |
void PSPromotionManager::record_steal(StarTask& p) { |
|
372 |
if (is_oop_masked(p)) { |
|
373 |
++_masked_steals; |
|
374 |
} |
|
375 |
} |
|
376 |
#endif // TASKQUEUE_STATS |
|
7397 | 377 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52117
diff
changeset
|
378 |
#endif // SHARE_GC_PARALLEL_PSPROMOTIONMANAGER_INLINE_HPP |