Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/ci/ciCallProfile.hpp
32285 views
/*1* Copyright (c) 1999, 2010, 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_VM_CI_CICALLPROFILE_HPP25#define SHARE_VM_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 seen45ciMethod* _method[MorphismLimit + 1]; // receivers methods46ciKlass* _receiver[MorphismLimit + 1]; // receivers (exact)4748ciCallProfile() {49_limit = 0;50_morphism = 0;51_count = -1;52_receiver_count[0] = -1;53_method[0] = NULL;54_receiver[0] = NULL;55}5657void add_receiver(ciKlass* receiver, int receiver_count);5859public:60// Note: The following predicates return false for invalid profiles:61bool has_receiver(int i) const { return _limit > i; }62int morphism() const { return _morphism; }6364int count() const { return _count; }65int receiver_count(int i) {66assert(i < _limit, "out of Call Profile MorphismLimit");67return _receiver_count[i];68}69float receiver_prob(int i) {70assert(i < _limit, "out of Call Profile MorphismLimit");71return (float)_receiver_count[i]/(float)_count;72}73ciMethod* method(int i) {74assert(i < _limit, "out of Call Profile MorphismLimit");75return _method[i];76}77ciKlass* receiver(int i) {78assert(i < _limit, "out of Call Profile MorphismLimit");79return _receiver[i];80}8182// Rescale the current profile based on the incoming scale83ciCallProfile rescale(double scale) {84assert(scale >= 0 && scale <= 1.0, "out of range");85ciCallProfile call = *this;86call._count = (int)(call._count * scale);87for (int i = 0; i < _morphism; i++) {88call._receiver_count[i] = (int)(call._receiver_count[i] * scale);89}90return call;91}92};9394#endif // SHARE_VM_CI_CICALLPROFILE_HPP959697