author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 57811 | 947252a54b98 |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
2 |
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
50113 | 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 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
25 |
#ifndef SHARE_JFR_LEAKPROFILER_UTILITIES_SAVERESTORE_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
26 |
#define SHARE_JFR_LEAKPROFILER_UTILITIES_SAVERESTORE_HPP |
50113 | 27 |
|
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "memory/iterator.hpp" |
|
57811 | 30 |
#include "oops/markWord.hpp" |
50113 | 31 |
#include "utilities/growableArray.hpp" |
32 |
||
33 |
template <typename T, typename Impl> |
|
34 |
class SaveRestore { |
|
35 |
private: |
|
36 |
Impl _impl; |
|
37 |
public: |
|
38 |
SaveRestore() : _impl() { |
|
39 |
_impl.setup(); |
|
40 |
} |
|
41 |
||
42 |
void save(T const& value) { |
|
43 |
_impl.save(value); |
|
44 |
} |
|
45 |
||
46 |
~SaveRestore() { |
|
47 |
_impl.restore(); |
|
48 |
} |
|
49 |
}; |
|
50 |
||
51 |
template <typename T, typename Context> |
|
52 |
class ContextStore { |
|
53 |
private: |
|
54 |
GrowableArray<Context>* _storage; |
|
55 |
public: |
|
56 |
ContextStore() : _storage(NULL) {} |
|
57 |
||
58 |
void setup() { |
|
59 |
assert(_storage == NULL, "invariant"); |
|
60 |
_storage = new GrowableArray<Context>(16); |
|
61 |
} |
|
62 |
||
63 |
void save(T const& value) { |
|
64 |
_storage->push(Context(value)); |
|
65 |
} |
|
66 |
||
67 |
void restore() { |
|
68 |
for (int i = 0; i < _storage->length(); ++i) { |
|
69 |
_storage->at(i).~Context(); |
|
70 |
} |
|
71 |
} |
|
72 |
}; |
|
73 |
||
74 |
/* |
|
75 |
* This class will save the original mark oop of an object sample object. |
|
76 |
* It will then install an "identifier" mark oop to be used for |
|
77 |
* identification purposes in the search for reference chains. |
|
78 |
* The destructor will restore the original mark oop. |
|
79 |
*/ |
|
80 |
||
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
81 |
class MarkWordContext { |
50113 | 82 |
private: |
83 |
oop _obj; |
|
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
84 |
markWord _mark_word; |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
85 |
void swap(MarkWordContext& rhs); |
50113 | 86 |
public: |
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
87 |
MarkWordContext(); |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
88 |
MarkWordContext(const oop obj); |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
89 |
MarkWordContext(const MarkWordContext& rhs); |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
90 |
void operator=(MarkWordContext rhs); |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
91 |
~MarkWordContext(); |
50113 | 92 |
}; |
93 |
||
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
94 |
typedef SaveRestore<oop, ContextStore<oop, MarkWordContext> > SaveRestoreMarkWords; |
50113 | 95 |
|
96 |
class ClassLoaderData; |
|
97 |
||
98 |
class CLDClaimContext { |
|
99 |
private: |
|
100 |
ClassLoaderData* _cld; |
|
101 |
void swap(CLDClaimContext& rhs); |
|
102 |
public: |
|
103 |
CLDClaimContext(); |
|
104 |
CLDClaimContext(ClassLoaderData* cld); |
|
105 |
CLDClaimContext(const CLDClaimContext& rhs); |
|
106 |
void operator=(CLDClaimContext rhs); |
|
107 |
~CLDClaimContext(); |
|
108 |
}; |
|
109 |
||
110 |
typedef SaveRestore<ClassLoaderData*, ContextStore<ClassLoaderData*, CLDClaimContext> > SaveRestoreCLDClaimState; |
|
111 |
||
112 |
class CLDClaimStateClosure : public CLDClosure { |
|
113 |
private: |
|
114 |
SaveRestoreCLDClaimState _state; |
|
115 |
public: |
|
116 |
CLDClaimStateClosure(); |
|
117 |
void do_cld(ClassLoaderData* cld); |
|
118 |
}; |
|
119 |
||
120 |
class SaveRestoreCLDClaimBits : public StackObj { |
|
121 |
private: |
|
122 |
CLDClaimStateClosure _claim_state_closure; |
|
123 |
public: |
|
124 |
SaveRestoreCLDClaimBits(); |
|
125 |
~SaveRestoreCLDClaimBits(); |
|
126 |
}; |
|
127 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
128 |
#endif // SHARE_JFR_LEAKPROFILER_UTILITIES_SAVERESTORE_HPP |