author | ehelin |
Wed, 25 Nov 2015 21:54:05 +0100 | |
changeset 34308 | 4496e81c890d |
parent 33213 | b937f634f56e |
child 34639 | cb73d3c05599 |
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" |
|
34308
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
26 |
#include "gc/g1/g1RootClosures.inline.hpp" |
33213 | 27 |
|
28 |
// Closures used during initial mark. |
|
29 |
// The treatment of "weak" roots is selectable through the template parameter, |
|
30 |
// this is usually used to control unloading of classes and interned strings. |
|
31 |
template <G1Mark MarkWeak> |
|
32 |
class G1InitalMarkClosures : public G1EvacuationRootClosures { |
|
33 |
G1SharedClosures<G1MarkFromRoot> _strong; |
|
34 |
G1SharedClosures<MarkWeak> _weak; |
|
35 |
||
36 |
// Filter method to help with returning the appropriate closures |
|
37 |
// depending on the class template parameter. |
|
38 |
template <G1Mark Mark, typename T> |
|
39 |
T* null_if(T* t) { |
|
40 |
if (Mark == MarkWeak) { |
|
41 |
return NULL; |
|
42 |
} |
|
43 |
return t; |
|
44 |
} |
|
45 |
||
46 |
public: |
|
47 |
G1InitalMarkClosures(G1CollectedHeap* g1h, |
|
48 |
G1ParScanThreadState* pss) : |
|
49 |
_strong(g1h, pss, /* process_only_dirty_klasses */ false, /* must_claim_cld */ true), |
|
50 |
_weak(g1h, pss, /* process_only_dirty_klasses */ false, /* must_claim_cld */ true) {} |
|
51 |
||
52 |
OopClosure* weak_oops() { return &_weak._buffered_oops; } |
|
53 |
OopClosure* strong_oops() { return &_strong._buffered_oops; } |
|
54 |
||
55 |
// If MarkWeak is G1MarkPromotedFromRoot then the weak CLDs must be processed in a second pass. |
|
56 |
CLDClosure* weak_clds() { return null_if<G1MarkPromotedFromRoot>(&_weak._clds); } |
|
57 |
CLDClosure* strong_clds() { return &_strong._clds; } |
|
58 |
||
59 |
// If MarkWeak is G1MarkFromRoot then all CLDs are processed by the weak and strong variants |
|
60 |
// return a NULL closure for the following specialized versions in that case. |
|
61 |
CLDClosure* thread_root_clds() { return null_if<G1MarkFromRoot>(&_strong._clds); } |
|
62 |
CLDClosure* second_pass_weak_clds() { return null_if<G1MarkFromRoot>(&_weak._clds); } |
|
63 |
||
64 |
CodeBlobClosure* strong_codeblobs() { return &_strong._codeblobs; } |
|
65 |
CodeBlobClosure* weak_codeblobs() { return &_weak._codeblobs; } |
|
66 |
||
67 |
void flush() { |
|
68 |
_strong._buffered_oops.done(); |
|
69 |
_weak._buffered_oops.done(); |
|
70 |
} |
|
71 |
||
72 |
double closure_app_seconds() { |
|
73 |
return _strong._buffered_oops.closure_app_seconds() + |
|
74 |
_weak._buffered_oops.closure_app_seconds(); |
|
75 |
} |
|
76 |
||
77 |
OopClosure* raw_strong_oops() { return &_strong._oops; } |
|
78 |
||
79 |
// If we are not marking all weak roots then we are tracing |
|
80 |
// which metadata is alive. |
|
81 |
bool trace_metadata() { return MarkWeak == G1MarkPromotedFromRoot; } |
|
82 |
}; |
|
83 |
||
84 |
G1EvacuationRootClosures* G1EvacuationRootClosures::create_root_closures(G1ParScanThreadState* pss, G1CollectedHeap* g1h) { |
|
34308
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
85 |
G1EvacuationRootClosures* res = create_root_closures_ext(pss, g1h); |
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
86 |
if (res != NULL) { |
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
87 |
return res; |
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
88 |
} |
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
89 |
|
33213 | 90 |
if (g1h->collector_state()->during_initial_mark_pause()) { |
91 |
if (ClassUnloadingWithConcurrentMark) { |
|
34308
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
92 |
res = new G1InitalMarkClosures<G1MarkPromotedFromRoot>(g1h, pss); |
33213 | 93 |
} else { |
34308
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
94 |
res = new G1InitalMarkClosures<G1MarkFromRoot>(g1h, pss); |
33213 | 95 |
} |
96 |
} else { |
|
34308
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
97 |
res = new G1EvacuationClosures(g1h, pss, g1h->collector_state()->gcs_are_young()); |
33213 | 98 |
} |
34308
4496e81c890d
8142494: Add extension point to G1EvacuationRootClosures
ehelin
parents:
33213
diff
changeset
|
99 |
return res; |
33213 | 100 |
} |