Skip to content

Commit

Permalink
poly
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name authored and weixlu committed Aug 26, 2024
1 parent 26f863a commit 0c61358
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/ci/ciCallProfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ciCallProfile : StackObj {
friend class ciMethod;
friend class ciMethodHandle;

enum { MorphismLimit = 2 }; // Max call site's morphism we care about
enum { MorphismLimit = 8 }; // Max call site's morphism we care about
int _limit; // number of receivers have been determined
int _morphism; // determined call site's morphism
int _count; // # times has this call been executed
Expand Down
12 changes: 9 additions & 3 deletions src/hotspot/share/ci/ciMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ bool ciMethod::has_balanced_monitors() {
}


/*
char* ciMethod::get_name() {
name()->
}
*/

// ------------------------------------------------------------------
// ciMethod::get_flow_analysis
ciTypeFlow* ciMethod::get_flow_analysis() {
Expand Down Expand Up @@ -468,7 +474,7 @@ const BitMap& ciMethod::bci_block_start() {
ciCallProfile ciMethod::call_profile_at_bci(int bci) {
ResourceMark rm;
ciCallProfile result;
if (method_data() != NULL && method_data()->is_mature()) {
if (method_data() != NULL && (method_data()->is_mature() || PolymorphicInlining)) {
ciProfileData* data = method_data()->bci_to_data(bci);
if (data != NULL && data->is_CounterData()) {
// Every profiled call site has a counter.
Expand Down Expand Up @@ -515,8 +521,8 @@ ciCallProfile ciMethod::call_profile_at_bci(int bci) {
// The call site count is > 0 in the case of a polymorphic virtual call.
if (morphism > 0 && morphism == result._limit) {
// The morphism <= MorphismLimit.
if ((morphism < ciCallProfile::MorphismLimit) ||
(morphism == ciCallProfile::MorphismLimit && count == 0)) {
if ((morphism == 1) ||
(morphism <= ciCallProfile::MorphismLimit && count == 0)) {
#ifdef ASSERT
if (count > 0) {
this->print_short_name(tty);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/code/codeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1678,9 +1678,9 @@ void CodeCache::print_summary(outputStream* st, bool detailed) {
}

if (detailed) {
st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT " nonprofiled nmethods=" UINT32_FORMAT
" adapters=" UINT32_FORMAT,
blob_count(), nmethod_count(), adapter_count());
blob_count(), nmethod_count(), nmethod_count(CodeBlobType::MethodNonProfiled), adapter_count());
st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
"enabled" : Arguments::mode() == Arguments::_int ?
"disabled (interpreter mode)" :
Expand Down
15 changes: 10 additions & 5 deletions src/hotspot/share/opto/bytecodeInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static bool is_unboxing_method(ciMethod* callee_method, Compile* C) {
// positive filter: should callee be inlined?
bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
int caller_bci, ciCallProfile& profile,
WarmCallInfo* wci_result) {
WarmCallInfo* wci_result, int receiver_index) {
// Allows targeted inlining
if (C->directive()->should_inline(callee_method)) {
*wci_result = *(WarmCallInfo::always_hot());
Expand Down Expand Up @@ -166,6 +166,11 @@ bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
assert(invoke_count != 0, "require invocation count greater than zero");
double freq = (double)call_site_count / (double)invoke_count;

if (InlineFreqOnReceiver && receiver_index != -1) {
guarantee(profile.has_receiver(receiver_index), "sanity");
freq = freq * profile.receiver_prob(receiver_index);
}

// bump the max size if the call is frequent
if ((freq >= InlineFrequencyRatio) ||
is_unboxing_method(callee_method, C) ||
Expand Down Expand Up @@ -332,7 +337,7 @@ bool InlineTree::should_not_inline(ciMethod *callee_method,
// Relocated from "InliningClosure::try_to_inline"
bool InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method,
int caller_bci, JVMState* jvms, ciCallProfile& profile,
WarmCallInfo* wci_result, bool& should_delay) {
WarmCallInfo* wci_result, bool& should_delay, int receiver_index) {

if (ClipInlining && (int)count_inline_bcs() >= DesiredMethodLimit) {
if (!callee_method->force_inline() || !IncrementalInline) {
Expand All @@ -345,7 +350,7 @@ bool InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method,

_forced_inline = false; // Reset
if (!should_inline(callee_method, caller_method, caller_bci, profile,
wci_result)) {
wci_result, receiver_index)) {
return false;
}
if (should_not_inline(callee_method, caller_method, jvms, wci_result)) {
Expand Down Expand Up @@ -543,7 +548,7 @@ void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
}

//------------------------------ok_to_inline-----------------------------------
WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay, int receiver_index) {
assert(callee_method != NULL, "caller checks for optimized virtual!");
assert(!should_delay, "should be initialized to false");
#ifdef ASSERT
Expand Down Expand Up @@ -576,7 +581,7 @@ WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms,
// Check if inlining policy says no.
WarmCallInfo wci = *(initial_wci);
bool success = try_to_inline(callee_method, caller_method, caller_bci,
jvms, profile, &wci, should_delay);
jvms, profile, &wci, should_delay, receiver_index);

#ifndef PRODUCT
if (InlineWarmCalls && (PrintOpto || C->print_inlining())) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/c2_globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@
\
/* controls for heat-based inlining */ \
\
develop(intx, NodeCountInliningCutoff, 18000, \
product (intx, NodeCountInliningCutoff, 18000, \
"If parser node generation exceeds limit stop inlining") \
range(0, max_jint) \
\
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/compile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ class Compile : public Phase {
// The profile factor is a discount to apply to this site's interp. profile.
CallGenerator* call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch,
JVMState* jvms, bool allow_inline, float profile_factor, ciKlass* speculative_receiver_type = NULL,
bool allow_intrinsics = true, bool delayed_forbidden = false);
bool allow_intrinsics = true, bool delayed_forbidden = false, int receiver_index = -1);
bool should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
return should_delay_string_inlining(call_method, jvms) ||
should_delay_boxing_inlining(call_method, jvms) ||
Expand Down
Loading

0 comments on commit 0c61358

Please sign in to comment.