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_CHAINS_OBJECTSAMPLEMARKER_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
26 |
#define SHARE_JFR_LEAKPROFILER_CHAINS_OBJECTSAMPLEMARKER_HPP |
50113 | 27 |
|
28 |
#include "memory/allocation.hpp" |
|
57811 | 29 |
#include "oops/markWord.hpp" |
50113 | 30 |
#include "utilities/growableArray.hpp" |
31 |
// |
|
32 |
// This class will save the original mark oop of a object sample object. |
|
33 |
// It will then install an "identifier" mark oop to be used for |
|
34 |
// identification purposes in the search for reference chains. |
|
35 |
// The destructor will restore each modified oop with its original mark oop. |
|
36 |
// |
|
37 |
class ObjectSampleMarker : public StackObj { |
|
38 |
private: |
|
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
39 |
class ObjectSampleMarkWord : public ResourceObj { |
50113 | 40 |
friend class ObjectSampleMarker; |
41 |
private: |
|
42 |
oop _obj; |
|
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
43 |
markWord _mark_word; |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
44 |
ObjectSampleMarkWord(const oop obj, |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
45 |
const markWord mark_word) : _obj(obj), |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
46 |
_mark_word(mark_word) {} |
50113 | 47 |
public: |
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
48 |
ObjectSampleMarkWord() : _obj(NULL), _mark_word(markWord::zero()) {} |
50113 | 49 |
}; |
50 |
||
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
51 |
GrowableArray<ObjectSampleMarkWord>* _store; |
50113 | 52 |
|
53 |
public: |
|
54 |
ObjectSampleMarker() : |
|
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
55 |
_store(new GrowableArray<ObjectSampleMarkWord>(16)) {} |
50113 | 56 |
~ObjectSampleMarker() { |
57 |
assert(_store != NULL, "invariant"); |
|
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
58 |
// restore the saved, original, markWord for sample objects |
50113 | 59 |
while (_store->is_nonempty()) { |
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
60 |
ObjectSampleMarkWord sample_oop = _store->pop(); |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
61 |
sample_oop._obj->set_mark(sample_oop._mark_word); |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
62 |
assert(sample_oop._obj->mark() == sample_oop._mark_word, "invariant"); |
50113 | 63 |
} |
64 |
} |
|
65 |
||
66 |
void mark(oop obj) { |
|
67 |
assert(obj != NULL, "invariant"); |
|
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
68 |
// save the original markWord |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
69 |
_store->push(ObjectSampleMarkWord(obj, obj->mark())); |
50113 | 70 |
// now we will "poison" the mark word of the sample object |
71 |
// to the intermediate monitor INFLATING state. |
|
72 |
// This is an "impossible" state during a safepoint, |
|
73 |
// hence we will use it to quickly identify sample objects |
|
74 |
// during the reachability search from gc roots. |
|
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
75 |
assert(NULL == markWord::INFLATING().to_pointer(), "invariant"); |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
76 |
obj->set_mark(markWord::INFLATING()); |
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
53244
diff
changeset
|
77 |
assert(NULL == obj->mark().to_pointer(), "invariant"); |
50113 | 78 |
} |
79 |
}; |
|
80 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
81 |
#endif // SHARE_JFR_LEAKPROFILER_CHAINS_OBJECTSAMPLEMARKER_HPP |