author | mgronlun |
Sat, 24 Aug 2019 14:30:27 +0200 | |
branch | JEP-349-branch |
changeset 57870 | 00860d9caf4d |
parent 57360 | src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetWriter.hpp@5d043a159d5c |
child 58157 | 9dca61a7df19 |
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 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
25 |
#ifndef SHARE_JFR_WRITERS_JFRTYPEWRITERHOST_HPP |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
26 |
#define SHARE_JFR_WRITERS_JFRTYPEWRITERHOST_HPP |
50113 | 27 |
|
28 |
#include "jfr/recorder/checkpoint/jfrCheckpointWriter.hpp" |
|
29 |
#include "jfr/utilities/jfrTypes.hpp" |
|
30 |
#include "memory/allocation.hpp" |
|
31 |
||
32 |
template <typename WriterImpl, u4 ID> |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
33 |
class JfrTypeWriterHost : public StackObj { |
50113 | 34 |
private: |
35 |
WriterImpl _impl; |
|
36 |
JfrCheckpointWriter* _writer; |
|
37 |
JfrCheckpointContext _ctx; |
|
53897
0abec72a3ac2
8217647: JFR: recordings on 32-bit systems unreadable
bulasevich
parents:
53244
diff
changeset
|
38 |
int64_t _count_offset; |
50113 | 39 |
int _count; |
40 |
bool _skip_header; |
|
41 |
public: |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
42 |
JfrTypeWriterHost(JfrCheckpointWriter* writer, |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
43 |
bool class_unload = false, |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
44 |
bool skip_header = false) : _impl(writer, class_unload), |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
45 |
_writer(writer), |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
46 |
_ctx(writer->context()), |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
47 |
_count(0), |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
48 |
_skip_header(skip_header) { |
50113 | 49 |
assert(_writer != NULL, "invariant"); |
50 |
if (!_skip_header) { |
|
51 |
_writer->write_type((JfrTypeId)ID); |
|
52 |
_count_offset = _writer->reserve(sizeof(u4)); // Don't know how many yet |
|
53 |
} |
|
54 |
} |
|
55 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
56 |
~JfrTypeWriterHost() { |
50113 | 57 |
if (_count == 0) { |
58 |
// nothing written, restore context for rewind |
|
59 |
_writer->set_context(_ctx); |
|
60 |
return; |
|
61 |
} |
|
62 |
assert(_count > 0, "invariant"); |
|
63 |
if (!_skip_header) { |
|
64 |
_writer->write_count(_count, _count_offset); |
|
65 |
} |
|
66 |
} |
|
67 |
||
68 |
bool operator()(typename WriterImpl::Type const & value) { |
|
69 |
this->_count += _impl(value); |
|
70 |
return true; |
|
71 |
} |
|
72 |
||
73 |
int count() const { return _count; } |
|
74 |
void add(int count) { _count += count; } |
|
75 |
}; |
|
76 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
77 |
typedef int(*type_write_operation)(JfrCheckpointWriter*, const void*); |
50113 | 78 |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
79 |
template <typename T, type_write_operation op> |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
80 |
class JfrTypeWriterImplHost { |
50113 | 81 |
private: |
82 |
JfrCheckpointWriter* _writer; |
|
83 |
public: |
|
84 |
typedef T Type; |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
85 |
JfrTypeWriterImplHost(JfrCheckpointWriter* writer, bool class_unload = false) : _writer(writer) {} |
50113 | 86 |
int operator()(T const& value) { |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
87 |
return op(this->_writer, value); |
50113 | 88 |
} |
89 |
}; |
|
90 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
91 |
template <typename T, typename Predicate, type_write_operation op> |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
92 |
class JfrPredicatedTypeWriterImplHost : public JfrTypeWriterImplHost<T, op> { |
50113 | 93 |
private: |
94 |
Predicate _predicate; |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
95 |
typedef JfrTypeWriterImplHost<T, op> Parent; |
50113 | 96 |
public: |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
97 |
JfrPredicatedTypeWriterImplHost(JfrCheckpointWriter* writer, bool class_unload = false) : |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
98 |
Parent(writer), _predicate(class_unload) {} |
50113 | 99 |
int operator()(T const& value) { |
100 |
return _predicate(value) ? Parent::operator()(value) : 0; |
|
101 |
} |
|
102 |
}; |
|
103 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
104 |
#endif // SHARE_JFR_WRITERS_JFRTYPEWRITERHOST_HPP |