Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/jfr/utilities/jfrBlob.cpp
41149 views
1
/*
2
* Copyright (c) 2017, 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
#include "precompiled.hpp"
26
#include "jfr/utilities/jfrBlob.hpp"
27
28
JfrBlob::JfrBlob(const u1* checkpoint, size_t size) :
29
_data(JfrCHeapObj::new_array<u1>(size)),
30
_next(),
31
_size(size),
32
_written(false) {
33
assert(_data != NULL, "invariant");
34
memcpy(const_cast<u1*>(_data), checkpoint, size);
35
}
36
37
JfrBlob::~JfrBlob() {
38
JfrCHeapObj::free(const_cast<u1*>(_data), _size);
39
}
40
41
void JfrBlob::reset_write_state() const {
42
if (!_written) {
43
return;
44
}
45
_written = false;
46
if (_next.valid()) {
47
_next->reset_write_state();
48
}
49
}
50
51
void JfrBlob::set_next(const JfrBlobHandle& ref) {
52
if (_next == ref) {
53
return;
54
}
55
assert(_next != ref, "invariant");
56
if (_next.valid()) {
57
_next->set_next(ref);
58
return;
59
}
60
_next = ref;
61
}
62
63
JfrBlobHandle JfrBlob::make(const u1* data, size_t size) {
64
const JfrBlob* const blob = new JfrBlob(data, size);
65
assert(blob != NULL, "invariant");
66
return JfrBlobReference::make(blob);
67
}
68
69