author | phh |
Sat, 30 Nov 2019 14:33:05 -0800 | |
changeset 59330 | 5b96c12f909d |
parent 57777 | 90ead0febf56 |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
2 |
* Copyright (c) 2017, 2018, 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" |
|
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
50986
diff
changeset
|
26 |
#include "classfile/classLoaderDataGraph.hpp" |
50113 | 27 |
#include "jfr/leakprofiler/utilities/saveRestore.hpp" |
28 |
#include "oops/oop.inline.hpp" |
|
29 |
||
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
30 |
MarkWordContext::MarkWordContext() : _obj(NULL), _mark_word(markWord::zero()) {} |
50113 | 31 |
|
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
32 |
MarkWordContext::MarkWordContext(const oop obj) : _obj(obj), _mark_word(obj->mark()) { |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
33 |
assert(_obj->mark() == _mark_word, "invariant"); |
50113 | 34 |
// now we will "poison" the mark word of the object |
35 |
// to the intermediate monitor INFLATING state. |
|
36 |
// This is an "impossible" state during a safepoint, |
|
37 |
// hence we will use it to quickly identify objects |
|
38 |
// during the reachability search from gc roots. |
|
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
39 |
assert(markWord::zero() == markWord::INFLATING(), "invariant"); |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
40 |
_obj->set_mark(markWord::INFLATING()); |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
41 |
assert(markWord::zero() == obj->mark(), "invariant"); |
50113 | 42 |
} |
43 |
||
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
44 |
MarkWordContext::~MarkWordContext() { |
50113 | 45 |
if (_obj != NULL) { |
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
46 |
_obj->set_mark(_mark_word); |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
47 |
assert(_obj->mark() == _mark_word, "invariant"); |
50113 | 48 |
} |
49 |
} |
|
50 |
||
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
51 |
MarkWordContext::MarkWordContext(const MarkWordContext& rhs) : _obj(NULL), _mark_word(markWord::zero()) { |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
52 |
swap(const_cast<MarkWordContext&>(rhs)); |
50113 | 53 |
} |
54 |
||
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
55 |
void MarkWordContext::operator=(MarkWordContext rhs) { |
50113 | 56 |
swap(rhs); |
57 |
} |
|
58 |
||
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
59 |
void MarkWordContext::swap(MarkWordContext& rhs) { |
50113 | 60 |
oop temp_obj = rhs._obj; |
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
61 |
markWord temp_mark_word = rhs._mark_word; |
50113 | 62 |
rhs._obj = _obj; |
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
63 |
rhs._mark_word = _mark_word; |
50113 | 64 |
_obj = temp_obj; |
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
52586
diff
changeset
|
65 |
_mark_word = temp_mark_word; |
50113 | 66 |
} |
67 |
||
68 |
CLDClaimContext::CLDClaimContext() : _cld(NULL) {} |
|
69 |
||
70 |
CLDClaimContext::CLDClaimContext(ClassLoaderData* cld) : _cld(cld) { |
|
71 |
assert(_cld->claimed(), "invariant"); |
|
52141
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51959
diff
changeset
|
72 |
_cld->clear_claim(); |
50113 | 73 |
} |
74 |
||
75 |
CLDClaimContext::~CLDClaimContext() { |
|
76 |
if (_cld != NULL) { |
|
52141
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51959
diff
changeset
|
77 |
_cld->try_claim(ClassLoaderData::_claim_strong); |
50113 | 78 |
assert(_cld->claimed(), "invariant"); |
79 |
} |
|
80 |
} |
|
81 |
||
82 |
CLDClaimContext::CLDClaimContext(const CLDClaimContext& rhs) : _cld(NULL) { |
|
83 |
swap(const_cast<CLDClaimContext&>(rhs)); |
|
84 |
} |
|
85 |
||
86 |
void CLDClaimContext::operator=(CLDClaimContext rhs) { |
|
87 |
swap(rhs); |
|
88 |
} |
|
89 |
||
90 |
void CLDClaimContext::swap(CLDClaimContext& rhs) { |
|
91 |
ClassLoaderData* temp_cld = rhs._cld; |
|
92 |
rhs._cld = _cld; |
|
93 |
_cld = temp_cld; |
|
94 |
} |
|
95 |
||
96 |
CLDClaimStateClosure::CLDClaimStateClosure() : CLDClosure(), _state() {} |
|
97 |
||
98 |
void CLDClaimStateClosure::do_cld(ClassLoaderData* cld) { |
|
99 |
assert(cld != NULL, "invariant"); |
|
100 |
if (cld->claimed()) { |
|
101 |
_state.save(cld); |
|
102 |
} |
|
103 |
} |
|
104 |
||
105 |
SaveRestoreCLDClaimBits::SaveRestoreCLDClaimBits() : _claim_state_closure() { |
|
52586
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52141
diff
changeset
|
106 |
// interferes with GC, so walk all oops that GC would. |
50113 | 107 |
ClassLoaderDataGraph::cld_do(&_claim_state_closure); |
108 |
} |
|
109 |
||
110 |
SaveRestoreCLDClaimBits::~SaveRestoreCLDClaimBits() { |
|
111 |
ClassLoaderDataGraph::clear_claimed_marks(); |
|
112 |
} |