Path: blob/master/src/hotspot/share/jfr/support/jfrMethodLookup.cpp
41152 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp"26#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp"27#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp"28#include "jfr/support/jfrMethodLookup.hpp"29#include "oops/instanceKlass.inline.hpp"30#include "oops/method.inline.hpp"3132// The InstanceKlass is assumed to be the method holder for the method to be looked up.33static const Method* lookup_method(InstanceKlass* ik, int orig_method_id_num) {34assert(ik != NULL, "invariant");35assert(orig_method_id_num >= 0, "invariant");36assert(orig_method_id_num < ik->methods()->length(), "invariant");37const Method* const m = ik->method_with_orig_idnum(orig_method_id_num);38assert(m != NULL, "invariant");39assert(m->orig_method_idnum() == orig_method_id_num, "invariant");40assert(!m->is_obsolete(), "invariant");41assert(ik == m->method_holder(), "invariant");42return m;43}4445const Method* JfrMethodLookup::lookup(const InstanceKlass* ik, traceid method_id) {46assert(ik != NULL, "invariant");47return lookup_method(const_cast<InstanceKlass*>(ik), method_id_num(method_id));48}4950int JfrMethodLookup::method_id_num(traceid method_id) {51return (int)(method_id & METHOD_ID_NUM_MASK);52}5354traceid JfrMethodLookup::method_id(const Method* method) {55assert(method != NULL, "invariant");56return METHOD_ID(method->method_holder(), method);57}5859traceid JfrMethodLookup::klass_id(traceid method_id) {60return method_id >> TRACE_ID_SHIFT;61}6263traceid JfrMethodLookup::klass_id(const Method* method) {64return klass_id(method_id(method));65}666768