Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/jfr/support/jfrMethodLookup.cpp
41152 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
#include "precompiled.hpp"
26
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp"
27
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp"
28
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp"
29
#include "jfr/support/jfrMethodLookup.hpp"
30
#include "oops/instanceKlass.inline.hpp"
31
#include "oops/method.inline.hpp"
32
33
// The InstanceKlass is assumed to be the method holder for the method to be looked up.
34
static const Method* lookup_method(InstanceKlass* ik, int orig_method_id_num) {
35
assert(ik != NULL, "invariant");
36
assert(orig_method_id_num >= 0, "invariant");
37
assert(orig_method_id_num < ik->methods()->length(), "invariant");
38
const Method* const m = ik->method_with_orig_idnum(orig_method_id_num);
39
assert(m != NULL, "invariant");
40
assert(m->orig_method_idnum() == orig_method_id_num, "invariant");
41
assert(!m->is_obsolete(), "invariant");
42
assert(ik == m->method_holder(), "invariant");
43
return m;
44
}
45
46
const Method* JfrMethodLookup::lookup(const InstanceKlass* ik, traceid method_id) {
47
assert(ik != NULL, "invariant");
48
return lookup_method(const_cast<InstanceKlass*>(ik), method_id_num(method_id));
49
}
50
51
int JfrMethodLookup::method_id_num(traceid method_id) {
52
return (int)(method_id & METHOD_ID_NUM_MASK);
53
}
54
55
traceid JfrMethodLookup::method_id(const Method* method) {
56
assert(method != NULL, "invariant");
57
return METHOD_ID(method->method_holder(), method);
58
}
59
60
traceid JfrMethodLookup::klass_id(traceid method_id) {
61
return method_id >> TRACE_ID_SHIFT;
62
}
63
64
traceid JfrMethodLookup::klass_id(const Method* method) {
65
return klass_id(method_id(method));
66
}
67
68