author | jprovino |
Sat, 27 Feb 2016 00:07:03 +0000 | |
changeset 36372 | b33937c0acdc |
parent 34639 | cb73d3c05599 |
child 38074 | 8475fdc6dcc3 |
permissions | -rw-r--r-- |
33213 | 1 |
/* |
2 |
* Copyright (c) 2015, 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 |
#include "precompiled.hpp" |
|
34639 | 26 |
#include "gc/g1/g1OopClosures.inline.hpp" |
27 |
#include "gc/g1/g1RootClosures.hpp" |
|
28 |
#include "gc/g1/g1SharedClosures.hpp" |
|
29 |
||
30 |
// Closures used for standard G1 evacuation. |
|
31 |
class G1EvacuationClosures : public G1EvacuationRootClosures { |
|
32 |
G1SharedClosures<G1MarkNone> _closures; |
|
33 |
||
34 |
public: |
|
35 |
G1EvacuationClosures(G1CollectedHeap* g1h, |
|
36 |
G1ParScanThreadState* pss, |
|
37 |
bool gcs_are_young) : |
|
38 |
_closures(g1h, pss, gcs_are_young, /* must_claim_cld */ false) {} |
|
39 |
||
40 |
OopClosure* weak_oops() { return &_closures._buffered_oops; } |
|
41 |
OopClosure* strong_oops() { return &_closures._buffered_oops; } |
|
42 |
||
43 |
CLDClosure* weak_clds() { return &_closures._clds; } |
|
44 |
CLDClosure* strong_clds() { return &_closures._clds; } |
|
45 |
CLDClosure* thread_root_clds() { return NULL; } |
|
46 |
CLDClosure* second_pass_weak_clds() { return NULL; } |
|
47 |
||
48 |
CodeBlobClosure* strong_codeblobs() { return &_closures._codeblobs; } |
|
49 |
CodeBlobClosure* weak_codeblobs() { return &_closures._codeblobs; } |
|
50 |
||
51 |
void flush() { _closures._buffered_oops.done(); } |
|
52 |
double closure_app_seconds() { return _closures._buffered_oops.closure_app_seconds(); } |
|
53 |
||
54 |
OopClosure* raw_strong_oops() { return &_closures._oops; } |
|
55 |
||
56 |
bool trace_metadata() { return false; } |
|
57 |
}; |
|
33213 | 58 |
|
59 |
// Closures used during initial mark. |
|
60 |
// The treatment of "weak" roots is selectable through the template parameter, |
|
61 |
// this is usually used to control unloading of classes and interned strings. |
|
62 |
template <G1Mark MarkWeak> |
|
63 |
class G1InitalMarkClosures : public G1EvacuationRootClosures { |
|
64 |
G1SharedClosures<G1MarkFromRoot> _strong; |
|
65 |
G1SharedClosures<MarkWeak> _weak; |
|
66 |
||
67 |
// Filter method to help with returning the appropriate closures |
|
68 |
// depending on the class template parameter. |
|
69 |
template <G1Mark Mark, typename T> |
|
70 |
T* null_if(T* t) { |
|
71 |
if (Mark == MarkWeak) { |
|
72 |
return NULL; |
|
73 |
} |
|
74 |
return t; |
|
75 |
} |
|
76 |
||
77 |
public: |
|
78 |
G1InitalMarkClosures(G1CollectedHeap* g1h, |
|
79 |
G1ParScanThreadState* pss) : |
|
80 |
_strong(g1h, pss, /* process_only_dirty_klasses */ false, /* must_claim_cld */ true), |
|
81 |
_weak(g1h, pss, /* process_only_dirty_klasses */ false, /* must_claim_cld */ true) {} |
|
82 |
||
83 |
OopClosure* weak_oops() { return &_weak._buffered_oops; } |
|
84 |
OopClosure* strong_oops() { return &_strong._buffered_oops; } |
|
85 |
||
86 |
// If MarkWeak is G1MarkPromotedFromRoot then the weak CLDs must be processed in a second pass. |
|
87 |
CLDClosure* weak_clds() { return null_if<G1MarkPromotedFromRoot>(&_weak._clds); } |
|
88 |
CLDClosure* strong_clds() { return &_strong._clds; } |
|
89 |
||
90 |
// If MarkWeak is G1MarkFromRoot then all CLDs are processed by the weak and strong variants |
|
91 |
// return a NULL closure for the following specialized versions in that case. |
|
92 |
CLDClosure* thread_root_clds() { return null_if<G1MarkFromRoot>(&_strong._clds); } |
|
93 |
CLDClosure* second_pass_weak_clds() { return null_if<G1MarkFromRoot>(&_weak._clds); } |
|
94 |
||
95 |
CodeBlobClosure* strong_codeblobs() { return &_strong._codeblobs; } |
|
96 |
CodeBlobClosure* weak_codeblobs() { return &_weak._codeblobs; } |
|
97 |
||
98 |
void flush() { |
|
99 |
_strong._buffered_oops.done(); |
|
100 |
_weak._buffered_oops.done(); |
|
101 |
} |
|
102 |
||
103 |
double closure_app_seconds() { |
|
104 |
return _strong._buffered_oops.closure_app_seconds() + |
|
105 |
_weak._buffered_oops.closure_app_seconds(); |
|
106 |
} |
|
107 |
||
108 |
OopClosure* raw_strong_oops() { return &_strong._oops; } |
|
109 |
||
110 |
// If we are not marking all weak roots then we are tracing |
|
111 |
// which metadata is alive. |
|
112 |
bool trace_metadata() { return MarkWeak == G1MarkPromotedFromRoot; } |
|
113 |
}; |
|
114 |
||
115 |
G1EvacuationRootClosures* G1EvacuationRootClosures::create_root_closures(G1ParScanThreadState* pss, G1CollectedHeap* g1h) { |
|
34308
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
116 |
G1EvacuationRootClosures* res = create_root_closures_ext(pss, g1h); |
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
117 |
if (res != NULL) { |
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
118 |
return res; |
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
119 |
} |
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
120 |
|
33213 | 121 |
if (g1h->collector_state()->during_initial_mark_pause()) { |
122 |
if (ClassUnloadingWithConcurrentMark) { |
|
34308
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
123 |
res = new G1InitalMarkClosures<G1MarkPromotedFromRoot>(g1h, pss); |
33213 | 124 |
} else { |
34308
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
125 |
res = new G1InitalMarkClosures<G1MarkFromRoot>(g1h, pss); |
33213 | 126 |
} |
127 |
} else { |
|
34308
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
128 |
res = new G1EvacuationClosures(g1h, pss, g1h->collector_state()->gcs_are_young()); |
33213 | 129 |
} |
34308
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
130 |
return res; |
33213 | 131 |
} |