2793 * @param type type to cast the node to |
2793 * @param type type to cast the node to |
2794 * @param not_null true if we know node cannot be null |
2794 * @param not_null true if we know node cannot be null |
2795 */ |
2795 */ |
2796 Node* GraphKit::maybe_cast_profiled_obj(Node* obj, |
2796 Node* GraphKit::maybe_cast_profiled_obj(Node* obj, |
2797 ciKlass* type, |
2797 ciKlass* type, |
2798 bool not_null, |
2798 bool not_null) { |
2799 SafePointNode* sfpt) { |
|
2800 // type == NULL if profiling tells us this object is always null |
2799 // type == NULL if profiling tells us this object is always null |
2801 if (type != NULL) { |
2800 if (type != NULL) { |
2802 Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check; |
2801 Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check; |
2803 Deoptimization::DeoptReason null_reason = Deoptimization::Reason_speculate_null_check; |
2802 Deoptimization::DeoptReason null_reason = Deoptimization::Reason_speculate_null_check; |
2804 ciMethod* trap_method = (sfpt == NULL) ? method() : sfpt->jvms()->method(); |
|
2805 int trap_bci = (sfpt == NULL) ? bci() : sfpt->jvms()->bci(); |
|
2806 |
2803 |
2807 if (!too_many_traps(null_reason) && !too_many_recompiles(null_reason) && |
2804 if (!too_many_traps(null_reason) && !too_many_recompiles(null_reason) && |
2808 !C->too_many_traps(trap_method, trap_bci, class_reason) && |
2805 !too_many_traps(class_reason) && |
2809 !C->too_many_recompiles(trap_method, trap_bci, class_reason)) { |
2806 !too_many_recompiles(class_reason)) { |
2810 Node* not_null_obj = NULL; |
2807 Node* not_null_obj = NULL; |
2811 // not_null is true if we know the object is not null and |
2808 // not_null is true if we know the object is not null and |
2812 // there's no need for a null check |
2809 // there's no need for a null check |
2813 if (!not_null) { |
2810 if (!not_null) { |
2814 Node* null_ctl = top(); |
2811 Node* null_ctl = top(); |
2820 |
2817 |
2821 Node* exact_obj = not_null_obj; |
2818 Node* exact_obj = not_null_obj; |
2822 ciKlass* exact_kls = type; |
2819 ciKlass* exact_kls = type; |
2823 Node* slow_ctl = type_check_receiver(exact_obj, exact_kls, 1.0, |
2820 Node* slow_ctl = type_check_receiver(exact_obj, exact_kls, 1.0, |
2824 &exact_obj); |
2821 &exact_obj); |
2825 if (sfpt != NULL) { |
2822 { |
2826 GraphKit kit(sfpt->jvms()); |
|
2827 PreserveJVMState pjvms(&kit); |
|
2828 kit.set_control(slow_ctl); |
|
2829 kit.uncommon_trap_exact(class_reason, Deoptimization::Action_maybe_recompile); |
|
2830 } else { |
|
2831 PreserveJVMState pjvms(this); |
2823 PreserveJVMState pjvms(this); |
2832 set_control(slow_ctl); |
2824 set_control(slow_ctl); |
2833 uncommon_trap_exact(class_reason, Deoptimization::Action_maybe_recompile); |
2825 uncommon_trap_exact(class_reason, Deoptimization::Action_maybe_recompile); |
2834 } |
2826 } |
2835 replace_in_map(not_null_obj, exact_obj); |
2827 replace_in_map(not_null_obj, exact_obj); |