void ciMethodData::load_data() { MethodData* mdo = get_MethodData(); if (mdo == NULL) { return; } // To do: don't copy the data if it is not "ripe" -- require a minimum # // of invocations. // Snapshot the data -- actually, take an approximate snapshot of // the data. Any concurrently executing threads may be changing the // data as we copy it. Copy::disjoint_words((HeapWord*) mdo, (HeapWord*) &_orig, sizeof(_orig) / HeapWordSize); Arena* arena = CURRENT_ENV->arena(); _data_size = mdo->data_size(); _extra_data_size = mdo->extra_data_size(); int total_size = _data_size + _extra_data_size; _data = (intptr_t *) arena->Amalloc(total_size); Copy::disjoint_words((HeapWord*) mdo->data_base(), (HeapWord*) _data, total_size / HeapWordSize); // Traverse the profile data, translating any oops into their // ci equivalents. ResourceMark rm; ciProfileData* ci_data = first_data(); ProfileData* data = mdo->first_data(); while (is_valid(ci_data)) { ci_data->translate_from(data); ci_data = next_data(ci_data); data = mdo->next_data(data); } if (mdo->parameters_type_data() != NULL) { _parameters = data_layout_at(mdo->parameters_type_data_di()); ciParametersTypeData* parameters = new ciParametersTypeData(_parameters); parameters->translate_from(mdo->parameters_type_data()); } load_extra_data(); // Note: Extra data are all BitData, and do not need translation. _current_mileage = MethodData::mileage_of(mdo->method()); _invocation_counter = mdo->invocation_count(); _backedge_counter = mdo->backedge_count(); _state = mdo->is_mature()? mature_state: immature_state; _eflags = mdo->eflags(); _arg_local = mdo->arg_local(); _arg_stack = mdo->arg_stack(); _arg_returned = mdo->arg_returned(); #ifndef PRODUCT if (ReplayCompiles) { ciReplay::initialize(this); } #endif }
// Determine is a method is mature. bool SimpleThresholdPolicy::is_mature(Method* method) { if (is_trivial(method)) return true; MethodData* mdo = method->method_data(); if (mdo != NULL) { int i = mdo->invocation_count(); int b = mdo->backedge_count(); double k = ProfileMaturityPercentage / 100.0; return call_predicate_helper<CompLevel_full_profile>(i, b, k, method) || loop_predicate_helper<CompLevel_full_profile>(i, b, k, method); } return false; }
// Determine if a method should be compiled with a normal entry point at a different level. CompLevel AdvancedThresholdPolicy::call_event(Method* method, CompLevel cur_level) { CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(), common(&AdvancedThresholdPolicy::loop_predicate, method, cur_level, true)); CompLevel next_level = common(&AdvancedThresholdPolicy::call_predicate, method, cur_level); // If OSR method level is greater than the regular method level, the levels should be // equalized by raising the regular method level in order to avoid OSRs during each // invocation of the method. if (osr_level == CompLevel_full_optimization && cur_level == CompLevel_full_profile) { MethodData* mdo = method->method_data(); guarantee(mdo != NULL, "MDO should not be NULL"); if (mdo->invocation_count() >= 1) { next_level = CompLevel_full_optimization; } } else { next_level = MAX2(osr_level, next_level); } return next_level; }
void SimpleThresholdPolicy::print_counters(const char* prefix, methodHandle mh) { int invocation_count = mh->invocation_count(); int backedge_count = mh->backedge_count(); MethodData* mdh = mh->method_data(); int mdo_invocations = 0, mdo_backedges = 0; int mdo_invocations_start = 0, mdo_backedges_start = 0; if (mdh != NULL) { mdo_invocations = mdh->invocation_count(); mdo_backedges = mdh->backedge_count(); mdo_invocations_start = mdh->invocation_count_start(); mdo_backedges_start = mdh->backedge_count_start(); } tty->print(" %stotal=%d,%d %smdo=%d(%d),%d(%d)", prefix, invocation_count, backedge_count, prefix, mdo_invocations, mdo_invocations_start, mdo_backedges, mdo_backedges_start); tty->print(" %smax levels=%d,%d", prefix, mh->highest_comp_level(), mh->highest_osr_comp_level()); }
// Determine if a method should be compiled with a normal entry point at a different level. CompLevel SimpleThresholdPolicy::call_event(Method* method, CompLevel cur_level, JavaThread* thread) { CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(), common(&SimpleThresholdPolicy::loop_predicate, method, cur_level)); CompLevel next_level = common(&SimpleThresholdPolicy::call_predicate, method, cur_level); // If OSR method level is greater than the regular method level, the levels should be // equalized by raising the regular method level in order to avoid OSRs during each // invocation of the method. if (osr_level == CompLevel_full_optimization && cur_level == CompLevel_full_profile) { MethodData* mdo = method->method_data(); guarantee(mdo != NULL, "MDO should not be NULL"); if (mdo->invocation_count() >= 1) { next_level = CompLevel_full_optimization; } } else { next_level = MAX2(osr_level, next_level); } #if INCLUDE_JVMCI if (UseJVMCICompiler) { next_level = JVMCIRuntime::adjust_comp_level(method, false, next_level, thread); } #endif return next_level; }