ciCallProfile.hpp revision 0:a61af66fc99e
117680Spst/* 217680Spst * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. 317680Spst * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 417680Spst * 517680Spst * This code is free software; you can redistribute it and/or modify it 617680Spst * under the terms of the GNU General Public License version 2 only, as 717680Spst * published by the Free Software Foundation. 817680Spst * 917680Spst * This code is distributed in the hope that it will be useful, but WITHOUT 1017680Spst * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1117680Spst * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1217680Spst * version 2 for more details (a copy is included in the LICENSE file that 1317680Spst * accompanied this code). 1417680Spst * 1517680Spst * You should have received a copy of the GNU General Public License version 1617680Spst * 2 along with this work; if not, write to the Free Software Foundation, 1717680Spst * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1817680Spst * 1917680Spst * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2017680Spst * CA 95054 USA or visit www.sun.com if you need additional information or 2117680Spst * have any questions. 2217680Spst * 2317680Spst */ 2417680Spst 2517680Spst// ciCallProfile 2617680Spst// 2717680Spst// This class is used to determine the frequently called method 2817680Spst// at some call site 2917680Spstclass ciCallProfile : StackObj { 3017680Spstprivate: 3117680Spst // Fields are initialized directly by ciMethod::call_profile_at_bci. 3217680Spst friend class ciMethod; 3317680Spst 3417680Spst enum { MorphismLimit = 2 }; // Max call site's morphism we care about 3517680Spst int _limit; // number of receivers have been determined 3617680Spst int _morphism; // determined call site's morphism 3717680Spst int _count; // # times has this call been executed 3817680Spst int _receiver_count[MorphismLimit + 1]; // # times receivers have been seen 3917680Spst ciMethod* _method[MorphismLimit + 1]; // receivers methods 4017680Spst ciKlass* _receiver[MorphismLimit + 1]; // receivers (exact) 4117680Spst 4217680Spst ciCallProfile() { 4317680Spst _limit = 0; 4417680Spst _morphism = 0; 4517680Spst _count = -1; 4617680Spst _receiver_count[0] = -1; 4717680Spst _method[0] = NULL; 4817680Spst _receiver[0] = NULL; 4917680Spst } 5017680Spst 5117680Spst void add_receiver(ciKlass* receiver, int receiver_count); 5217680Spst 5317680Spstpublic: 5417680Spst // Note: The following predicates return false for invalid profiles: 5517680Spst bool has_receiver(int i) { return _limit > i; } 5617680Spst int morphism() { return _morphism; } 5717680Spst 5817680Spst int count() { return _count; } 5917680Spst int receiver_count(int i) { 6017680Spst assert(i < _limit, "out of Call Profile MorphismLimit"); 6117680Spst return _receiver_count[i]; 6217680Spst } 6317680Spst float receiver_prob(int i) { 6417680Spst assert(i < _limit, "out of Call Profile MorphismLimit"); 6517680Spst return (float)_receiver_count[i]/(float)_count; 6617680Spst } 6717680Spst ciMethod* method(int i) { 6817680Spst assert(i < _limit, "out of Call Profile MorphismLimit"); 6917680Spst return _method[i]; 7017680Spst } 7117680Spst ciKlass* receiver(int i) { 7217680Spst assert(i < _limit, "out of Call Profile MorphismLimit"); 7317680Spst return _receiver[i]; 7417680Spst } 7517680Spst}; 7617680Spst