bytecodeInfo.cpp revision 1879
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "compiler/compileLog.hpp"
#include "interpreter/linkResolver.hpp"
#include "oops/objArrayKlass.hpp"
#include "opto/callGenerator.hpp"
#include "runtime/handles.inline.hpp"
//=============================================================================
//------------------------------InlineTree-------------------------------------
float site_invoke_ratio, int site_depth_adjust)
: C(c), _caller_jvms(caller_jvms),
{
NOT_PRODUCT(_count_inlines = 0;)
if (_caller_jvms != NULL) {
// Keep a private copy of the caller_jvms:
}
assert((caller_tree == NULL ? 0 : caller_tree->stack_depth() + 1) == stack_depth(), "correct (redundant) depth parameter");
if (UseOldInlining) {
// Update hierarchical counts, count_inline_bcs() and count_inlines()
}
}
}
float site_invoke_ratio, int site_depth_adjust)
{
NOT_PRODUCT(_count_inlines = 0;)
}
static void print_indent(int depth) {
}
// True when EA is ON and a java constructor is called or
// a super constructor is called from an inlined java constructor.
return C->do_escape_analysis() && EliminateAllocations &&
( callee_method->is_initializer() ||
(caller_method->is_initializer() &&
caller_method != C->method() &&
);
}
// positive filter: should send be inlined? returns NULL, if yes, or rejection msg
const char* InlineTree::shouldInline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) const {
// Allows targeted inlining
if(callee_method->should_inline()) {
if (PrintInlining && Verbose) {
}
return NULL;
}
// positive filter: should send be inlined? returns NULL (--> yes)
// or rejection msg
int max_size = C->max_inline_size();
// Check for too many throws (and not too huge)
size < InlineThrowMaxSize ) {
if (PrintInlining && Verbose) {
tty->print_cr("Inlined method with many throws (throws=%d):", callee_method->interpreter_throwout_count());
}
return NULL;
}
if (!UseOldInlining) {
return NULL; // size and frequency are represented in a new way
}
// bump the max size if the call is frequent
if ((freq >= InlineFrequencyRatio) ||
(call_site_count >= InlineFrequencyCount) ||
max_size = C->freq_inline_size();
callee_method->print();
}
} else {
// Not hot. Check for medium-sized pre-existing nmethod at cold sites.
if (callee_method->has_compiled_code() &&
return "already compiled into a medium method";
}
if (max_size > C->max_inline_size())
return "hot method too big";
return "too big";
}
return NULL;
}
// negative filter: should send NOT be inlined? returns NULL, ok to inline, or rejection msg
const char* InlineTree::shouldNotInline(ciMethod *callee_method, ciMethod* caller_method, WarmCallInfo* wci_result) const {
// negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg
if (!UseOldInlining) {
// note: we allow ik->is_abstract()
if (fail) {
return fail;
}
}
// don't inline exception code unless the top method belongs to an
// exception class
}
}
if (callee_method->has_compiled_code() && callee_method->instructions_size(CompLevel_full_optimization) > InlineSmallCode) {
// %%% adjust wci_result->size()?
}
return NULL;
}
// Always inline MethodHandle methods and generated MethodHandle adapters.
return NULL;
// First check all inlining restrictions which are required for correctness
// note: we allow ik->is_abstract()
if (callee_method->should_inline()) {
// ignore heuristic controls on inlining
return NULL;
}
// Now perform checks which are heuristic
if( callee_method->has_compiled_code() && callee_method->instructions_size(CompLevel_full_optimization) > InlineSmallCode )
return "already compiled into a big method";
// don't inline exception code unless the top method belongs to an
// exception class
if (caller_tree() != NULL &&
const InlineTree *top = this;
return "exception method";
}
// use frequency-based objections only for non-trivial methods
// don't use counts with -Xcomp or CTW
if (UseInterpreter && !CompileTheWorld) {
if (!callee_method->has_compiled_code() &&
!callee_method->was_executed_more_than(0)) {
return "never executed";
}
// Escape Analysis: inline all executed constructors
CompileThreshold >> 1))) {
return "executed < MinInliningThreshold times";
}
}
if (callee_method->should_not_inline()) {
return "disallowed by CompilerOracle";
}
if (UseStringCache) {
// Do not inline StringCache::profile() method used only at the beginning.
return "profiling method";
}
}
return NULL;
}
//-----------------------------try_to_inline-----------------------------------
// return NULL if ok, reason for not inlining otherwise
// Relocated from "InliningClosure::try_to_inline"
const char* InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) {
// Old algorithm had funny accumulating BC-size counters
if (UseOldInlining && ClipInlining
&& (int)count_inline_bcs() >= DesiredMethodLimit) {
return "size > DesiredMethodLimit";
}
return msg;
}
wci_result)) != NULL) {
return msg;
}
// accessor methods are not subject to any of the following limits.
return NULL;
}
// suppress a few checks for accessors and trivial methods
// don't inline into giant methods
return "NodeCountInliningCutoff";
}
if ((!UseInterpreter || CompileTheWorld) &&
// Escape Analysis stress testing when running Xcomp or CTW:
// inline constructors even if they are not reached.
// don't inline unreached call sites
return "call site not reached";
}
}
if (!C->do_inlining() && InlineAccessors) {
return "not an accessor";
}
if( inline_depth() > MaxInlineLevel ) {
return "inlining too deep";
}
if( method() == callee_method &&
inline_depth() > MaxRecursiveInlineLevel ) {
return "recursively inlining too deep";
}
if (UseOldInlining && ClipInlining
return "size > DesiredMethodLimit";
}
// ok, inline this method
return NULL;
}
//------------------------------pass_initial_checks----------------------------
// Check if a callee_method was suggested
if( callee_method == NULL ) return false;
// Check if klass of callee_method is loaded
if( !callee_holder->is_loaded() ) return false;
if( !callee_holder->is_initialized() ) return false;
// Checks that constant pool's call site has been visited
// stricter than callee_holder->is_initialized()
// An invokedynamic instruction does not have a klass.
return false;
}
// Try to do constant pool resolution if running Xcomp
return false;
}
}
}
// did not, it may attempt to throw an exception during our probing. Catch
// and ignore such exceptions and do not attempt to compile the method.
if( callee_method->should_exclude() ) return false;
return true;
}
#ifndef PRODUCT
//------------------------------print_inlining---------------------------------
// Really, the failure_msg can be a success message also.
void InlineTree::print_inlining(ciMethod *callee_method, int caller_bci, const char *failure_msg) const {
if( Verbose && callee_method ) {
const InlineTree *top = this;
tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
}
}
#endif
//------------------------------ok_to_inline-----------------------------------
WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci) {
#ifdef ASSERT
// Make sure the incoming jvms has the same information content as me.
// This means that we can eventually make this whole class AllStatic.
} else {
}
#endif
const char *failure_msg = NULL;
if( PrintInlining ) {
failure_msg = "failed_initial_checks";
}
return NULL;
}
// Check if inlining policy says no.
}
#ifndef PRODUCT
if (UseOldInlining && InlineWarmCalls
}
}
#endif
if (UseOldInlining) {
if (failure_msg == NULL)
else
}
if (!InlineWarmCalls) {
// Do not inline the warm calls.
}
}
// In -UseOldInlining, the failure_msg may also be a success message.
// Inline!
if (UseOldInlining)
return WarmCallInfo::always_hot();
}
// Do not inline
return NULL;
}
//------------------------------compute_callee_frequency-----------------------
// Call-site count / interpreter invocation count, scaled recursively.
// Always between 0.0 and 1.0. Represents the percentage of the method's
// total execution time used at this call site.
return freq;
}
//------------------------------build_inline_tree_for_callee-------------------
InlineTree *InlineTree::build_inline_tree_for_callee( ciMethod* callee_method, JVMState* caller_jvms, int caller_bci) {
// Attempt inlining.
return old_ilt;
}
int new_depth_adjust = 0;
else if (callee_method->is_method_handle_invoke()) {
}
if (new_depth_adjust != 0 && PrintInlining) {
}
if (new_depth_adjust != 0 && C->log()) {
}
}
InlineTree *ilt = new InlineTree(C, this, callee_method, caller_jvms, caller_bci, recur_frequency, _site_depth_adjust + new_depth_adjust);
return ilt;
}
//---------------------------------------callee_at-----------------------------
return sub;
}
}
return NULL;
}
//------------------------------build_inline_tree_root-------------------------
// Root of inline tree
return ilt;
}
//-------------------------find_subtree_from_root-----------------------------
// Given a jvms, which determines a call chain from the root method,
// find the corresponding inline tree.
// Note: This method will be removed or replaced as InlineTree goes away.
InlineTree* InlineTree::find_subtree_from_root(InlineTree* root, JVMState* jvms, ciMethod* callee, bool create_if_not_found) {
// Select the corresponding subtree for this bci.
if (!sub) {
if (create_if_not_found && d == depth) {
}
return NULL;
}
}
return iltp;
}