Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/jfr/leakprofiler/chains/edgeQueue.cpp
41153 views
1
/*
2
* Copyright (c) 2014, 2018, 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/leakprofiler/chains/edgeQueue.hpp"
27
#include "jfr/leakprofiler/utilities/unifiedOopRef.inline.hpp"
28
#include "jfr/recorder/storage/jfrVirtualMemory.hpp"
29
30
EdgeQueue::EdgeQueue(size_t reservation_size_bytes, size_t commit_block_size_bytes) :
31
_vmm(NULL),
32
_reservation_size_bytes(reservation_size_bytes),
33
_commit_block_size_bytes(commit_block_size_bytes),
34
_top_index(0),
35
_bottom_index(0) {
36
}
37
38
bool EdgeQueue::initialize() {
39
assert(_reservation_size_bytes >= _commit_block_size_bytes, "invariant");
40
assert(_vmm == NULL, "invariant");
41
_vmm = new JfrVirtualMemory();
42
return _vmm != NULL && _vmm->initialize(_reservation_size_bytes, _commit_block_size_bytes, sizeof(Edge));
43
}
44
45
EdgeQueue::~EdgeQueue() {
46
delete _vmm;
47
}
48
49
void EdgeQueue::add(const Edge* parent, UnifiedOopRef ref) {
50
assert(!ref.is_null(), "Null objects not allowed in EdgeQueue");
51
assert(!is_full(), "EdgeQueue is full. Check is_full before adding another Edge");
52
assert(!_vmm->is_full(), "invariant");
53
void* const allocation = _vmm->new_datum();
54
assert(allocation != NULL, "invariant");
55
new (allocation)Edge(parent, ref);
56
_top_index++;
57
assert(_vmm->count() == _top_index, "invariant");
58
}
59
60
size_t EdgeQueue::top() const {
61
return _top_index;
62
}
63
64
size_t EdgeQueue::bottom() const {
65
return EdgeQueue::_bottom_index;
66
}
67
68
bool EdgeQueue::is_empty() const {
69
return _top_index == _bottom_index;
70
}
71
72
bool EdgeQueue::is_full() const {
73
return _vmm->is_full();
74
}
75
76
const Edge* EdgeQueue::remove() const {
77
assert(!is_empty(), "EdgeQueue is empty. Check if empty before removing Edge");
78
assert(!_vmm->is_empty(), "invariant");
79
return (const Edge*)_vmm->get(_bottom_index++);
80
}
81
82
const Edge* EdgeQueue::element_at(size_t index) const {
83
assert(index >= _bottom_index, "invariant");
84
assert(index <_top_index, "invariant");
85
return (Edge*)_vmm->get(index);
86
}
87
88
size_t EdgeQueue::reserved_size() const {
89
assert(_vmm != NULL, "invariant");
90
return _vmm->reserved_size();
91
}
92
93
size_t EdgeQueue::live_set() const {
94
assert(_vmm != NULL, "invariant");
95
return _vmm->live_set();
96
}
97
98
size_t EdgeQueue::sizeof_edge() const {
99
assert(_vmm != NULL, "invariant");
100
return _vmm->aligned_datum_size_bytes();
101
}
102
103