Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/jfr/writers/jfrMemoryWriterHost.inline.hpp
41149 views
1
/*
2
* Copyright (c) 2016, 2019, 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
#ifndef SHARE_JFR_WRITERS_JFRMEMORYWRITERHOST_INLINE_HPP
26
#define SHARE_JFR_WRITERS_JFRMEMORYWRITERHOST_INLINE_HPP
27
28
#include "jfr/writers/jfrMemoryWriterHost.hpp"
29
30
template <typename Adapter, typename AP, typename AccessAssert>
31
inline void MemoryWriterHost<Adapter, AP, AccessAssert>::write_bytes(void* dest, const void* buf, intptr_t len) {
32
assert(dest != NULL, "invariant");
33
assert(len >= 0, "invariant");
34
memcpy(dest, buf, (size_t)len); // no encoding
35
this->set_current_pos(len);
36
}
37
38
template <typename Adapter, typename AP, typename AccessAssert>
39
inline MemoryWriterHost<Adapter, AP, AccessAssert>::MemoryWriterHost(typename Adapter::StorageType* storage, Thread* thread) :
40
StorageHost<Adapter, AP>(storage, thread) {
41
}
42
43
template <typename Adapter, typename AP, typename AccessAssert>
44
inline MemoryWriterHost<Adapter, AP, AccessAssert>::MemoryWriterHost(typename Adapter::StorageType* storage, size_t size) :
45
StorageHost<Adapter, AP>(storage, size) {
46
}
47
48
template <typename Adapter, typename AP, typename AccessAssert>
49
inline MemoryWriterHost<Adapter, AP, AccessAssert>::MemoryWriterHost(Thread* thread) :
50
StorageHost<Adapter, AP>(thread) {
51
}
52
53
template <typename Adapter, typename AP, typename AccessAssert>
54
inline void MemoryWriterHost<Adapter, AP, AccessAssert>::acquire() {
55
debug_only(_access.acquire();)
56
if (!this->is_valid()) {
57
this->flush();
58
}
59
debug_only(is_acquired();)
60
}
61
62
template <typename Adapter, typename AP, typename AccessAssert>
63
inline void MemoryWriterHost<Adapter, AP, AccessAssert>::release() {
64
debug_only(is_acquired();)
65
StorageHost<Adapter, AP>::release();
66
debug_only(_access.release();)
67
}
68
69
#ifdef ASSERT
70
template <typename Adapter, typename AP, typename AccessAssert>
71
inline bool MemoryWriterHost<Adapter, AP, AccessAssert>::is_acquired() const {
72
return _access.is_acquired();
73
}
74
#endif
75
76
template <typename Adapter, typename AP>
77
inline AcquireReleaseMemoryWriterHost<Adapter, AP>::AcquireReleaseMemoryWriterHost(typename Adapter::StorageType* storage, Thread* thread) :
78
MemoryWriterHost<Adapter, AP>(storage, thread) {
79
this->acquire();
80
}
81
82
template <typename Adapter, typename AP>
83
inline AcquireReleaseMemoryWriterHost<Adapter, AP>::AcquireReleaseMemoryWriterHost(typename Adapter::StorageType* storage, size_t size) :
84
MemoryWriterHost<Adapter, AP>(storage, size) {
85
this->acquire();
86
}
87
88
template <typename Adapter, typename AP>
89
inline AcquireReleaseMemoryWriterHost<Adapter, AP>::AcquireReleaseMemoryWriterHost(Thread* thread) :
90
MemoryWriterHost<Adapter, AP>(thread) {
91
this->acquire();
92
}
93
94
template <typename Adapter, typename AP>
95
inline AcquireReleaseMemoryWriterHost<Adapter, AP>::~AcquireReleaseMemoryWriterHost() {
96
assert(this->is_acquired(), "invariant");
97
this->release();
98
}
99
100
#endif // SHARE_JFR_WRITERS_JFRMEMORYWRITERHOST_INLINE_HPP
101
102