author | stefank |
Thu, 15 Mar 2018 21:24:10 +0100 | |
changeset 49592 | 77fb0be7d19f |
parent 47622 | 817f2a7019e4 |
child 49722 | a47d1e21b3f1 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
47580 | 2 |
* Copyright (c) 2007, 2017, 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:
360
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
360
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:
360
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_CMS_PAROOPCLOSURES_INLINE_HPP |
26 |
#define SHARE_VM_GC_CMS_PAROOPCLOSURES_INLINE_HPP |
|
7397 | 27 |
|
47622
817f2a7019e4
8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
47580
diff
changeset
|
28 |
#include "gc/cms/cmsHeap.hpp" |
30764 | 29 |
#include "gc/cms/parNewGeneration.hpp" |
30 |
#include "gc/cms/parOopClosures.hpp" |
|
31 |
#include "gc/shared/cardTableRS.hpp" |
|
32 |
#include "gc/shared/genOopClosures.inline.hpp" |
|
35061 | 33 |
#include "logging/log.hpp" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
37242
diff
changeset
|
34 |
#include "logging/logStream.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47622
diff
changeset
|
35 |
#include "oops/access.inline.hpp" |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47622
diff
changeset
|
36 |
#include "oops/compressedOops.inline.hpp" |
7397 | 37 |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
38 |
template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47622
diff
changeset
|
39 |
oop obj = RawAccess<OOP_NOT_NULL>::oop_load(p); |
1 | 40 |
// weak references are sometimes scanned twice; must check |
41 |
// that to-space doesn't already contain this object |
|
42 |
if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) { |
|
43 |
// we need to ensure that it is copied (see comment in |
|
44 |
// ParScanClosure::do_oop_work). |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9624
diff
changeset
|
45 |
Klass* objK = obj->klass(); |
1 | 46 |
markOop m = obj->mark(); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
47 |
oop new_obj; |
1 | 48 |
if (m->is_marked()) { // Contains forwarding pointer. |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
49 |
new_obj = ParNewGeneration::real_forwardee(obj); |
1 | 50 |
} else { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9624
diff
changeset
|
51 |
size_t obj_sz = obj->size_given_klass(objK); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
52 |
new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state, |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
53 |
obj, obj_sz, m); |
1 | 54 |
} |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47622
diff
changeset
|
55 |
RawAccess<OOP_NOT_NULL>::oop_store(p, new_obj); |
1 | 56 |
} |
57 |
} |
|
58 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
59 |
inline void ParScanWeakRefClosure::do_oop_nv(oop* p) { ParScanWeakRefClosure::do_oop_work(p); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
60 |
inline void ParScanWeakRefClosure::do_oop_nv(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); } |
1 | 61 |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
62 |
template <class T> inline void ParScanClosure::par_do_barrier(T* p) { |
1 | 63 |
assert(generation()->is_in_reserved(p), "expected ref in generation"); |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47622
diff
changeset
|
64 |
oop obj = RawAccess<OOP_NOT_NULL>::oop_load(p); |
1 | 65 |
// If p points to a younger generation, mark the card. |
66 |
if ((HeapWord*)obj < gen_boundary()) { |
|
67 |
rs()->write_ref_field_gc_par(p, obj); |
|
68 |
} |
|
69 |
} |
|
70 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
71 |
template <class T> |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
72 |
inline void ParScanClosure::do_oop_work(T* p, |
1 | 73 |
bool gc_barrier, |
74 |
bool root_scan) { |
|
47622
817f2a7019e4
8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
47580
diff
changeset
|
75 |
assert((!CMSHeap::heap()->is_in_reserved(p) || |
1 | 76 |
generation()->is_in_reserved(p)) |
47622
817f2a7019e4
8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
47580
diff
changeset
|
77 |
&& (CMSHeap::heap()->is_young_gen(generation()) || gc_barrier), |
1 | 78 |
"The gen must be right, and we must be doing the barrier " |
79 |
"in older generations."); |
|
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47622
diff
changeset
|
80 |
T heap_oop = RawAccess<>::oop_load(p); |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47622
diff
changeset
|
81 |
if (!CompressedOops::is_null(heap_oop)) { |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47622
diff
changeset
|
82 |
oop obj = CompressedOops::decode_not_null(heap_oop); |
1 | 83 |
if ((HeapWord*)obj < _boundary) { |
9624
c3657c3324ee
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
7397
diff
changeset
|
84 |
#ifndef PRODUCT |
c3657c3324ee
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
7397
diff
changeset
|
85 |
if (_g->to()->is_in_reserved(obj)) { |
37242 | 86 |
Log(gc) log; |
37071
d7750d171889
8151603: Use error stream instead of tty for logging before ShouldNotReachHere()
brutisso
parents:
35061
diff
changeset
|
87 |
log.error("Scanning field (" PTR_FORMAT ") twice?", p2i(p)); |
47622
817f2a7019e4
8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
47580
diff
changeset
|
88 |
CMSHeap* heap = CMSHeap::heap(); |
817f2a7019e4
8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
47580
diff
changeset
|
89 |
Space* sp = heap->space_containing(p); |
9624
c3657c3324ee
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
7397
diff
changeset
|
90 |
oop obj = oop(sp->block_start(p)); |
c3657c3324ee
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
7397
diff
changeset
|
91 |
assert((HeapWord*)obj < (HeapWord*)p, "Error"); |
37071
d7750d171889
8151603: Use error stream instead of tty for logging before ShouldNotReachHere()
brutisso
parents:
35061
diff
changeset
|
92 |
log.error("Object: " PTR_FORMAT, p2i((void *)obj)); |
d7750d171889
8151603: Use error stream instead of tty for logging before ShouldNotReachHere()
brutisso
parents:
35061
diff
changeset
|
93 |
log.error("-------"); |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
37242
diff
changeset
|
94 |
LogStream ls(log.error()); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
37242
diff
changeset
|
95 |
obj->print_on(&ls); |
37071
d7750d171889
8151603: Use error stream instead of tty for logging before ShouldNotReachHere()
brutisso
parents:
35061
diff
changeset
|
96 |
log.error("-----"); |
d7750d171889
8151603: Use error stream instead of tty for logging before ShouldNotReachHere()
brutisso
parents:
35061
diff
changeset
|
97 |
log.error("Heap:"); |
d7750d171889
8151603: Use error stream instead of tty for logging before ShouldNotReachHere()
brutisso
parents:
35061
diff
changeset
|
98 |
log.error("-----"); |
47622
817f2a7019e4
8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
47580
diff
changeset
|
99 |
heap->print_on(&ls); |
9624
c3657c3324ee
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
7397
diff
changeset
|
100 |
ShouldNotReachHere(); |
c3657c3324ee
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
7397
diff
changeset
|
101 |
} |
c3657c3324ee
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
7397
diff
changeset
|
102 |
#endif |
1 | 103 |
// OK, we need to ensure that it is copied. |
104 |
// We read the klass and mark in this order, so that we can reliably |
|
105 |
// get the size of the object: if the mark we read is not a |
|
106 |
// forwarding pointer, then the klass is valid: the klass is only |
|
107 |
// overwritten with an overflow next pointer after the object is |
|
108 |
// forwarded. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9624
diff
changeset
|
109 |
Klass* objK = obj->klass(); |
1 | 110 |
markOop m = obj->mark(); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
111 |
oop new_obj; |
1 | 112 |
if (m->is_marked()) { // Contains forwarding pointer. |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
113 |
new_obj = ParNewGeneration::real_forwardee(obj); |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47622
diff
changeset
|
114 |
RawAccess<OOP_NOT_NULL>::oop_store(p, new_obj); |
35061 | 115 |
log_develop_trace(gc, scavenge)("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", |
116 |
"forwarded ", |
|
117 |
new_obj->klass()->internal_name(), p2i(p), p2i((void *)obj), p2i((void *)new_obj), new_obj->size()); |
|
1 | 118 |
} else { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9624
diff
changeset
|
119 |
size_t obj_sz = obj->size_given_klass(objK); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
120 |
new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m); |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47622
diff
changeset
|
121 |
RawAccess<OOP_NOT_NULL>::oop_store(p, new_obj); |
1 | 122 |
if (root_scan) { |
123 |
// This may have pushed an object. If we have a root |
|
124 |
// category with a lot of roots, can't let the queue get too |
|
125 |
// full: |
|
126 |
(void)_par_scan_state->trim_queues(10 * ParallelGCThreads); |
|
127 |
} |
|
128 |
} |
|
47580 | 129 |
if (is_scanning_a_cld()) { |
130 |
do_cld_barrier(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9624
diff
changeset
|
131 |
} else if (gc_barrier) { |
1 | 132 |
// Now call parent closure |
133 |
par_do_barrier(p); |
|
134 |
} |
|
135 |
} |
|
136 |
} |
|
137 |
} |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
138 |
|
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
139 |
inline void ParScanWithBarrierClosure::do_oop_nv(oop* p) { ParScanClosure::do_oop_work(p, true, false); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
140 |
inline void ParScanWithBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, true, false); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
141 |
|
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
142 |
inline void ParScanWithoutBarrierClosure::do_oop_nv(oop* p) { ParScanClosure::do_oop_work(p, false, false); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
143 |
inline void ParScanWithoutBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, false, false); } |
7397 | 144 |
|
30764 | 145 |
#endif // SHARE_VM_GC_CMS_PAROOPCLOSURES_INLINE_HPP |