Path: blob/master/src/hotspot/share/ci/ciCallProfile.hpp
40930 views
/*1* Copyright (c) 1999, 2019, 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#ifndef SHARE_CI_CICALLPROFILE_HPP25#define SHARE_CI_CICALLPROFILE_HPP2627#include "ci/ciClassList.hpp"28#include "memory/allocation.hpp"2930// ciCallProfile31//32// This class is used to determine the frequently called method33// at some call site34class ciCallProfile : StackObj {35private:36// Fields are initialized directly by ciMethod::call_profile_at_bci.37friend class ciMethod;38friend class ciMethodHandle;3940enum { MorphismLimit = 2 }; // Max call site's morphism we care about41int _limit; // number of receivers have been determined42int _morphism; // determined call site's morphism43int _count; // # times has this call been executed44int _receiver_count[MorphismLimit + 1]; // # times receivers have been seen45ciKlass* _receiver[MorphismLimit + 1]; // receivers (exact)4647ciCallProfile() {48_limit = 0;49_morphism = 0;50_count = -1;51_receiver_count[0] = -1;52_receiver[0] = NULL;53}5455void add_receiver(ciKlass* receiver, int receiver_count);5657public:58// Note: The following predicates return false for invalid profiles:59bool has_receiver(int i) const { return _limit > i; }60int morphism() const { return _morphism; }6162int count() const { return _count; }63int receiver_count(int i) {64assert(i < _limit, "out of Call Profile MorphismLimit");65return _receiver_count[i];66}67float receiver_prob(int i) {68assert(i < _limit, "out of Call Profile MorphismLimit");69return (float)_receiver_count[i]/(float)_count;70}71ciKlass* receiver(int i) {72assert(i < _limit, "out of Call Profile MorphismLimit");73return _receiver[i];74}75};7677#endif // SHARE_CI_CICALLPROFILE_HPP787980