8068915: uncommon trap w/ Reason_speculate_class_check causes performance regression due to continuous deoptimizations

Reviewed-by: kvn, roland, jrose
This commit is contained in:
Vladimir Ivanov 2015-01-29 10:26:02 -08:00
parent 7227e9ba53
commit efd80ec6af

View File

@ -1989,6 +1989,11 @@ void GraphKit::uncommon_trap(int trap_request,
Deoptimization::trap_request_index(trap_request) < 0 &&
too_many_recompiles(reason)) {
// This BCI is causing too many recompilations.
if (C->log() != NULL) {
C->log()->elem("observe that='trap_action_change' reason='%s' from='%s' to='none'",
Deoptimization::trap_reason_name(reason),
Deoptimization::trap_action_name(action));
}
action = Deoptimization::Action_none;
trap_request = Deoptimization::make_trap_request(reason, action);
} else {
@ -2763,7 +2768,7 @@ Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj,
Deoptimization::DeoptReason reason = Deoptimization::reason_class_check(spec_klass != NULL);
// Make sure we haven't already deoptimized from this tactic.
if (too_many_traps(reason))
if (too_many_traps(reason) || too_many_recompiles(reason))
return NULL;
// (No, this isn't a call, but it's enough like a virtual call
@ -2785,8 +2790,7 @@ Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj,
&exact_obj);
{ PreserveJVMState pjvms(this);
set_control(slow_ctl);
uncommon_trap(reason,
Deoptimization::Action_maybe_recompile);
uncommon_trap_exact(reason, Deoptimization::Action_maybe_recompile);
}
if (safe_for_replace) {
replace_in_map(not_null_obj, exact_obj);
@ -2815,8 +2819,8 @@ Node* GraphKit::maybe_cast_profiled_obj(Node* obj,
if (type != NULL) {
Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check;
Deoptimization::DeoptReason null_reason = Deoptimization::Reason_speculate_null_check;
if (!too_many_traps(null_reason) &&
!too_many_traps(class_reason)) {
if (!too_many_traps(null_reason) && !too_many_recompiles(null_reason) &&
!too_many_traps(class_reason) && !too_many_recompiles(class_reason)) {
Node* not_null_obj = NULL;
// not_null is true if we know the object is not null and
// there's no need for a null check
@ -2836,19 +2840,18 @@ Node* GraphKit::maybe_cast_profiled_obj(Node* obj,
GraphKit kit(sfpt->jvms());
PreserveJVMState pjvms(&kit);
kit.set_control(slow_ctl);
kit.uncommon_trap(class_reason,
Deoptimization::Action_maybe_recompile);
kit.uncommon_trap_exact(class_reason, Deoptimization::Action_maybe_recompile);
} else {
PreserveJVMState pjvms(this);
set_control(slow_ctl);
uncommon_trap(class_reason,
Deoptimization::Action_maybe_recompile);
uncommon_trap_exact(class_reason, Deoptimization::Action_maybe_recompile);
}
replace_in_map(not_null_obj, exact_obj);
obj = exact_obj;
}
} else {
if (!too_many_traps(Deoptimization::Reason_null_assert)) {
if (!too_many_traps(Deoptimization::Reason_null_assert) &&
!too_many_recompiles(Deoptimization::Reason_null_assert)) {
Node* exact_obj = null_assert(obj);
replace_in_map(obj, exact_obj);
obj = exact_obj;