Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/jfr/utilities/jfrRelation.hpp
41149 views
1
/*
2
* Copyright (c) 2020, 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_UTILITIES_JFRRELATION_HPP
26
#define SHARE_JFR_UTILITIES_JFRRELATION_HPP
27
28
#include "jfr/utilities/jfrNode.hpp"
29
#include "jfr/utilities/jfrTypes.hpp"
30
31
inline int compare_traceid(const traceid& lhs, const traceid& rhs) {
32
return lhs > rhs ? 1 : (lhs < rhs) ? -1 : 0;
33
}
34
35
inline int sort_traceid(traceid* lhs, traceid* rhs) {
36
return compare_traceid(*lhs, *rhs);
37
}
38
39
class Klass;
40
41
inline int compare_klasses(const Klass*const& lhs, const Klass*const& rhs) {
42
return lhs > rhs ? 1 : (lhs < rhs) ? -1 : 0;
43
}
44
45
inline int sort_klasses(const Klass* lhs, const Klass* rhs) {
46
return compare_klasses(lhs, rhs);
47
}
48
49
template <typename Node>
50
class LessThan {
51
private:
52
typename Node::Key _key;
53
public:
54
LessThan(typename Node::Key key) : _key(key) {}
55
bool operator()(const Node* node) { return node->key() < _key; }
56
};
57
58
template <typename Node>
59
class GreaterThan {
60
private:
61
typename Node::Key _key;
62
public:
63
GreaterThan(typename Node::Key key) : _key(key) {}
64
bool operator()(const Node* node) { return node->key() > _key; }
65
};
66
67
/*
68
* Using a contradiction as a search predicate amounts
69
* to using the physical order of the list (key is neglected).
70
* [LessThan relation -> Ascending order ] -> the minimal element.
71
* [GreaterThan relation -> Descending order] -> the maximal element.
72
*/
73
template <typename Node>
74
class HeadNode {
75
public:
76
HeadNode(const Node* node = NULL) {}
77
bool operator()(const Node* current, const Node* next) {
78
return is_marked_for_removal(next);
79
}
80
};
81
82
/*
83
* Using a tautology as a search predicate amounts
84
* to using the physical store order of the list (key is neglected).
85
* [LessThan relation -> Ascending order ] -> the maximal element.
86
* [GreaterThan relation -> Descending order] -> the minimal element.
87
*/
88
template <typename Node>
89
class LastNode {
90
public:
91
LastNode(const Node* node = NULL) {}
92
bool operator()(const Node* current, const Node* next ) {
93
return true;
94
}
95
};
96
97
template <typename Node>
98
class Identity {
99
private:
100
const Node* _target;
101
bool _found;
102
public:
103
Identity(const Node* node = NULL) : _target(node), _found(false) {}
104
bool operator()(const Node* current, const Node* next) {
105
assert(current != NULL, "invariant");
106
assert(next != NULL, "invariant");
107
if (!_found && current == _target) {
108
_found = true;
109
}
110
return is_marked_for_removal(next) || !_found;
111
}
112
};
113
114
#endif // SHARE_JFR_UTILITIES_JFRRELATION_HPP
115
116