ciCallProfile.hpp revision 1879
0N/A/*
0N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
0N/A * questions.
0N/A *
0N/A */
0N/A
0N/A#ifndef SHARE_VM_CI_CICALLPROFILE_HPP
0N/A#define SHARE_VM_CI_CICALLPROFILE_HPP
0N/A
0N/A#include "ci/ciClassList.hpp"
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:
// Note: The following predicates return false for invalid profiles:
bool has_receiver(int i) { return _limit > i; }
int morphism() { return _morphism; }
int count() { return _count; }
int receiver_count(int i) {
assert(i < _limit, "out of Call Profile MorphismLimit");
return _receiver_count[i];
}
float receiver_prob(int i) {
assert(i < _limit, "out of Call Profile MorphismLimit");
return (float)_receiver_count[i]/(float)_count;
}
ciMethod* method(int i) {
assert(i < _limit, "out of Call Profile MorphismLimit");
return _method[i];
}
ciKlass* receiver(int i) {
assert(i < _limit, "out of Call Profile MorphismLimit");
return _receiver[i];
}
};
#endif // SHARE_VM_CI_CICALLPROFILE_HPP