comparison src/share/vm/opto/graphKit.cpp @ 22987:4eeec0cdeb6a

8068915: uncommon trap w/ Reason_speculate_class_check causes performance regression due to continuous deoptimizations Reviewed-by: kvn, roland, jrose
author vlivanov
date Thu, 29 Jan 2015 10:26:02 -0800
parents 6e8e0bf87bbe
children 55d07ec5bde4
comparison
equal deleted inserted replaced
22986:d9593687713d 22987:4eeec0cdeb6a
1978 // get the chance to go from mono->bi->mega 1978 // get the chance to go from mono->bi->mega
1979 if (!keep_exact_action && 1979 if (!keep_exact_action &&
1980 Deoptimization::trap_request_index(trap_request) < 0 && 1980 Deoptimization::trap_request_index(trap_request) < 0 &&
1981 too_many_recompiles(reason)) { 1981 too_many_recompiles(reason)) {
1982 // This BCI is causing too many recompilations. 1982 // This BCI is causing too many recompilations.
1983 if (C->log() != NULL) {
1984 C->log()->elem("observe that='trap_action_change' reason='%s' from='%s' to='none'",
1985 Deoptimization::trap_reason_name(reason),
1986 Deoptimization::trap_action_name(action));
1987 }
1983 action = Deoptimization::Action_none; 1988 action = Deoptimization::Action_none;
1984 trap_request = Deoptimization::make_trap_request(reason, action); 1989 trap_request = Deoptimization::make_trap_request(reason, action);
1985 } else { 1990 } else {
1986 C->set_trap_can_recompile(true); 1991 C->set_trap_can_recompile(true);
1987 } 1992 }
2740 if (!UseTypeProfile || !TypeProfileCasts) return NULL; 2745 if (!UseTypeProfile || !TypeProfileCasts) return NULL;
2741 2746
2742 Deoptimization::DeoptReason reason = spec_klass == NULL ? Deoptimization::Reason_class_check : Deoptimization::Reason_speculate_class_check; 2747 Deoptimization::DeoptReason reason = spec_klass == NULL ? Deoptimization::Reason_class_check : Deoptimization::Reason_speculate_class_check;
2743 2748
2744 // Make sure we haven't already deoptimized from this tactic. 2749 // Make sure we haven't already deoptimized from this tactic.
2745 if (too_many_traps(reason)) 2750 if (too_many_traps(reason) || too_many_recompiles(reason))
2746 return NULL; 2751 return NULL;
2747 2752
2748 // (No, this isn't a call, but it's enough like a virtual call 2753 // (No, this isn't a call, but it's enough like a virtual call
2749 // to use the same ciMethod accessor to get the profile info...) 2754 // to use the same ciMethod accessor to get the profile info...)
2750 // If we have a speculative type use it instead of profiling (which 2755 // If we have a speculative type use it instead of profiling (which
2762 Node* exact_obj = not_null_obj; // will get updated in place... 2767 Node* exact_obj = not_null_obj; // will get updated in place...
2763 Node* slow_ctl = type_check_receiver(exact_obj, exact_kls, 1.0, 2768 Node* slow_ctl = type_check_receiver(exact_obj, exact_kls, 1.0,
2764 &exact_obj); 2769 &exact_obj);
2765 { PreserveJVMState pjvms(this); 2770 { PreserveJVMState pjvms(this);
2766 set_control(slow_ctl); 2771 set_control(slow_ctl);
2767 uncommon_trap(reason, 2772 uncommon_trap_exact(reason, Deoptimization::Action_maybe_recompile);
2768 Deoptimization::Action_maybe_recompile);
2769 } 2773 }
2770 if (safe_for_replace) { 2774 if (safe_for_replace) {
2771 replace_in_map(not_null_obj, exact_obj); 2775 replace_in_map(not_null_obj, exact_obj);
2772 } 2776 }
2773 return exact_obj; 2777 return exact_obj;
2791 bool not_null) { 2795 bool not_null) {
2792 // type == NULL if profiling tells us this object is always null 2796 // type == NULL if profiling tells us this object is always null
2793 if (type != NULL) { 2797 if (type != NULL) {
2794 Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check; 2798 Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check;
2795 Deoptimization::DeoptReason null_reason = Deoptimization::Reason_null_check; 2799 Deoptimization::DeoptReason null_reason = Deoptimization::Reason_null_check;
2796 if (!too_many_traps(null_reason) && 2800 if (!too_many_traps(null_reason) && !too_many_recompiles(null_reason) &&
2797 !too_many_traps(class_reason)) { 2801 !too_many_traps(class_reason) && !too_many_recompiles(class_reason)) {
2798 Node* not_null_obj = NULL; 2802 Node* not_null_obj = NULL;
2799 // not_null is true if we know the object is not null and 2803 // not_null is true if we know the object is not null and
2800 // there's no need for a null check 2804 // there's no need for a null check
2801 if (!not_null) { 2805 if (!not_null) {
2802 Node* null_ctl = top(); 2806 Node* null_ctl = top();
2811 Node* slow_ctl = type_check_receiver(exact_obj, exact_kls, 1.0, 2815 Node* slow_ctl = type_check_receiver(exact_obj, exact_kls, 1.0,
2812 &exact_obj); 2816 &exact_obj);
2813 { 2817 {
2814 PreserveJVMState pjvms(this); 2818 PreserveJVMState pjvms(this);
2815 set_control(slow_ctl); 2819 set_control(slow_ctl);
2816 uncommon_trap(class_reason, 2820 uncommon_trap_exact(class_reason, Deoptimization::Action_maybe_recompile);
2817 Deoptimization::Action_maybe_recompile);
2818 } 2821 }
2819 replace_in_map(not_null_obj, exact_obj); 2822 replace_in_map(not_null_obj, exact_obj);
2820 obj = exact_obj; 2823 obj = exact_obj;
2821 } 2824 }
2822 } else { 2825 } else {
2823 if (!too_many_traps(Deoptimization::Reason_null_assert)) { 2826 if (!too_many_traps(Deoptimization::Reason_null_assert) &&
2827 !too_many_recompiles(Deoptimization::Reason_null_assert)) {
2824 Node* exact_obj = null_assert(obj); 2828 Node* exact_obj = null_assert(obj);
2825 replace_in_map(obj, exact_obj); 2829 replace_in_map(obj, exact_obj);
2826 obj = exact_obj; 2830 obj = exact_obj;
2827 } 2831 }
2828 } 2832 }