ciCallProfile.hpp revision 0
0N/A/*
0N/A * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any questions.
0N/A *
0N/A */
0N/A
0N/A// ciCallProfile
0N/A//
0N/A// This class is used to determine the frequently called method
0N/A// at some call site
0N/Aclass ciCallProfile : StackObj {
0N/Aprivate:
0N/A // Fields are initialized directly by ciMethod::call_profile_at_bci.
0N/A friend class ciMethod;
0N/A
0N/A enum { MorphismLimit = 2 }; // Max call site's morphism we care about
0N/A int _limit; // number of receivers have been determined
0N/A int _morphism; // determined call site's morphism
0N/A int _count; // # times has this call been executed
0N/A int _receiver_count[MorphismLimit + 1]; // # times receivers have been seen
0N/A ciMethod* _method[MorphismLimit + 1]; // receivers methods
0N/A ciKlass* _receiver[MorphismLimit + 1]; // receivers (exact)
0N/A
0N/A ciCallProfile() {
0N/A _limit = 0;
0N/A _morphism = 0;
0N/A _count = -1;
0N/A _receiver_count[0] = -1;
0N/A _method[0] = NULL;
0N/A _receiver[0] = NULL;
0N/A }
0N/A
0N/A void add_receiver(ciKlass* receiver, int receiver_count);
0N/A
0N/Apublic:
0N/A // Note: The following predicates return false for invalid profiles:
0N/A bool has_receiver(int i) { return _limit > i; }
0N/A int morphism() { return _morphism; }
0N/A
0N/A int count() { return _count; }
0N/A int receiver_count(int i) {
0N/A assert(i < _limit, "out of Call Profile MorphismLimit");
0N/A return _receiver_count[i];
0N/A }
0N/A float receiver_prob(int i) {
0N/A assert(i < _limit, "out of Call Profile MorphismLimit");
0N/A return (float)_receiver_count[i]/(float)_count;
0N/A }
0N/A ciMethod* method(int i) {
0N/A assert(i < _limit, "out of Call Profile MorphismLimit");
0N/A return _method[i];
0N/A }
0N/A ciKlass* receiver(int i) {
0N/A assert(i < _limit, "out of Call Profile MorphismLimit");
0N/A return _receiver[i];
0N/A }
0N/A};