/*
* 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/compileBroker.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 max_inline_level) :
C(c),
{
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 max_inline_level) :
C(c),
{
NOT_PRODUCT(_count_inlines = 0;)
}
// 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 callee be inlined?
// Allows targeted inlining
if(callee_method->should_inline()) {
if (PrintInlining && Verbose) {
}
set_msg("force inline by CompilerOracle");
return true;
}
// 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());
}
set_msg("many throws");
return true;
}
if (!UseOldInlining) {
set_msg("!UseOldInlining");
return true; // 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_inline_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() &&
set_msg("already compiled into a medium method");
return false;
}
}
if (size > max_inline_size) {
if (max_inline_size > default_max_inline_size) {
set_msg("hot method too big");
} else {
set_msg("too big");
}
return false;
}
return true;
}
// negative filter: should callee NOT be inlined?
// First check all inlining restrictions which are required for correctness
if ( callee_method->is_abstract()) {
fail_msg = "method holder not initialized";
} else if ( callee_method->is_native()) {
fail_msg = "native method";
} else if ( callee_method->dont_inline()) {
fail_msg = "don't inline by annotation";
}
if (!UseOldInlining) {
return true;
}
}
// don't inline exception code unless the top method belongs to an
// exception class
}
}
if (callee_method->has_compiled_code() &&
// %%% adjust wci_result->size()?
}
return false;
}
// one more inlining restriction
fail_msg = "unloaded signature classes";
}
return true;
}
// ignore heuristic controls on inlining
if (callee_method->should_inline()) {
set_msg("force inline by CompilerOracle");
return false;
}
// Now perform checks which are heuristic
if (!callee_method->force_inline()) {
if (callee_method->has_compiled_code() &&
set_msg("already compiled into a big method");
return true;
}
}
// don't inline exception code unless the top method belongs to an
// exception class
if (caller_tree() != NULL &&
set_msg("exception method");
return true;
}
}
if (callee_method->should_not_inline()) {
set_msg("disallowed by CompilerOracle");
return true;
}
if (UseStringCache) {
// Do not inline StringCache::profile() method used only at the beginning.
set_msg("profiling method");
return true;
}
}
// use frequency-based objections only for non-trivial methods
return false;
}
// don't use counts with -Xcomp or CTW
if (UseInterpreter && !CompileTheWorld) {
if (!callee_method->has_compiled_code() &&
!callee_method->was_executed_more_than(0)) {
set_msg("never executed");
return true;
}
// Escape Analysis: inline all executed constructors
CompileThreshold >> 1))) {
set_msg("executed < MinInliningThreshold times");
return true;
}
}
return false;
}
//-----------------------------try_to_inline-----------------------------------
// return true if ok
// Relocated from "InliningClosure::try_to_inline"
// Old algorithm had funny accumulating BC-size counters
if (UseOldInlining && ClipInlining
&& (int)count_inline_bcs() >= DesiredMethodLimit) {
set_msg("size > DesiredMethodLimit");
return false;
} else if (!C->inlining_incrementally()) {
should_delay = true;
}
}
wci_result)) {
return false;
}
return false;
}
// accessor methods are not subject to any of the following limits.
set_msg("accessor");
return true;
}
// suppress a few checks for accessors and trivial methods
// don't inline into giant methods
if (C->over_inlining_cutoff()) {
|| !IncrementalInline) {
set_msg("NodeCountInliningCutoff");
return false;
} else {
should_delay = true;
}
}
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
set_msg("call site not reached");
return false;
}
}
if (!C->do_inlining() && InlineAccessors) {
set_msg("not an accessor");
return false;
}
if (inline_level() > _max_inline_level) {
set_msg("inlining too deep");
return false;
} else if (!C->inlining_incrementally()) {
should_delay = true;
}
}
// detect direct and indirect recursive inlining
if (!callee_method->is_compiled_lambda_form()) {
// count the current method and the callee
if (inline_level > MaxRecursiveInlineLevel) {
set_msg("recursively inlining too deep");
return false;
}
// count callers of current method and callee
inline_level++;
if (inline_level > MaxRecursiveInlineLevel) {
set_msg("recursively inlining too deep");
return false;
}
}
}
}
if (UseOldInlining && ClipInlining
set_msg("size > DesiredMethodLimit");
return false;
} else if (!C->inlining_incrementally()) {
should_delay = true;
}
}
// ok, inline this method
return true;
}
//------------------------------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;
}
//------------------------------check_can_parse--------------------------------
// Certain methods cannot be parsed at all:
return NULL;
}
//------------------------------print_inlining---------------------------------
bool success) const {
if (success) {
} else {
}
}
if (PrintInlining) {
if (Verbose && callee_method) {
//tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
}
}
}
//------------------------------ok_to_inline-----------------------------------
WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
#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
// Do some initial checks.
set_msg("failed initial checks");
return NULL;
}
// Do some parse checks.
return NULL;
}
// Check if inlining policy says no.
#ifndef PRODUCT
if (UseOldInlining && InlineWarmCalls
set_msg("OK");
}
}
}
#endif
if (UseOldInlining) {
if (success) {
} else {
}
}
if (!InlineWarmCalls) {
// Do not inline the warm calls.
}
}
// Inline!
set_msg("inline (hot)");
}
if (UseOldInlining)
return WarmCallInfo::always_hot();
}
// Do not inline
set_msg("too cold to 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 max_inline_level_adjust = 0;
else if (callee_method->is_method_handle_intrinsic() ||
}
}
if (max_inline_level_adjust != 0 && C->log()) {
}
}
InlineTree* ilt = new InlineTree(C, this, callee_method, caller_jvms, caller_bci, recur_frequency, _max_inline_level + max_inline_level_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) {
// Select the corresponding subtree for this bci.
if (d == depth) {
}
return sub;
}
}
return iltp;
}
#ifndef PRODUCT
}
}
}
#endif