2120 |
2120 |
2121 //------------------------------null_check_oop--------------------------------- |
2121 //------------------------------null_check_oop--------------------------------- |
2122 // Null check oop. Set null-path control into Region in slot 3. |
2122 // Null check oop. Set null-path control into Region in slot 3. |
2123 // Make a cast-not-nullness use the other not-null control. Return cast. |
2123 // Make a cast-not-nullness use the other not-null control. Return cast. |
2124 Node* GraphKit::null_check_oop(Node* value, Node* *null_control, |
2124 Node* GraphKit::null_check_oop(Node* value, Node* *null_control, |
2125 bool never_see_null) { |
2125 bool never_see_null, bool safe_for_replace) { |
2126 // Initial NULL check taken path |
2126 // Initial NULL check taken path |
2127 (*null_control) = top(); |
2127 (*null_control) = top(); |
2128 Node* cast = null_check_common(value, T_OBJECT, false, null_control); |
2128 Node* cast = null_check_common(value, T_OBJECT, false, null_control); |
2129 |
2129 |
2130 // Generate uncommon_trap: |
2130 // Generate uncommon_trap: |
2137 set_control(*null_control); |
2137 set_control(*null_control); |
2138 replace_in_map(value, null()); |
2138 replace_in_map(value, null()); |
2139 uncommon_trap(Deoptimization::Reason_null_check, |
2139 uncommon_trap(Deoptimization::Reason_null_check, |
2140 Deoptimization::Action_make_not_entrant); |
2140 Deoptimization::Action_make_not_entrant); |
2141 (*null_control) = top(); // NULL path is dead |
2141 (*null_control) = top(); // NULL path is dead |
|
2142 } |
|
2143 if ((*null_control) == top() && safe_for_replace) { |
|
2144 replace_in_map(value, cast); |
2142 } |
2145 } |
2143 |
2146 |
2144 // Cast away null-ness on the result |
2147 // Cast away null-ness on the result |
2145 return cast; |
2148 return cast; |
2146 } |
2149 } |
2632 RegionNode* region = new(C) RegionNode(PATH_LIMIT); |
2635 RegionNode* region = new(C) RegionNode(PATH_LIMIT); |
2633 Node* phi = new(C) PhiNode(region, TypeInt::BOOL); |
2636 Node* phi = new(C) PhiNode(region, TypeInt::BOOL); |
2634 C->set_has_split_ifs(true); // Has chance for split-if optimization |
2637 C->set_has_split_ifs(true); // Has chance for split-if optimization |
2635 |
2638 |
2636 ciProfileData* data = NULL; |
2639 ciProfileData* data = NULL; |
|
2640 bool safe_for_replace = false; |
2637 if (java_bc() == Bytecodes::_instanceof) { // Only for the bytecode |
2641 if (java_bc() == Bytecodes::_instanceof) { // Only for the bytecode |
2638 data = method()->method_data()->bci_to_data(bci()); |
2642 data = method()->method_data()->bci_to_data(bci()); |
|
2643 safe_for_replace = true; |
2639 } |
2644 } |
2640 bool never_see_null = (ProfileDynamicTypes // aggressive use of profile |
2645 bool never_see_null = (ProfileDynamicTypes // aggressive use of profile |
2641 && seems_never_null(obj, data)); |
2646 && seems_never_null(obj, data)); |
2642 |
2647 |
2643 // Null check; get casted pointer; set region slot 3 |
2648 // Null check; get casted pointer; set region slot 3 |
2644 Node* null_ctl = top(); |
2649 Node* null_ctl = top(); |
2645 Node* not_null_obj = null_check_oop(obj, &null_ctl, never_see_null); |
2650 Node* not_null_obj = null_check_oop(obj, &null_ctl, never_see_null, safe_for_replace); |
2646 |
2651 |
2647 // If not_null_obj is dead, only null-path is taken |
2652 // If not_null_obj is dead, only null-path is taken |
2648 if (stopped()) { // Doing instance-of on a NULL? |
2653 if (stopped()) { // Doing instance-of on a NULL? |
2649 set_control(null_ctl); |
2654 set_control(null_ctl); |
2650 return intcon(0); |
2655 return intcon(0); |
2721 } |
2726 } |
2722 } |
2727 } |
2723 } |
2728 } |
2724 |
2729 |
2725 ciProfileData* data = NULL; |
2730 ciProfileData* data = NULL; |
|
2731 bool safe_for_replace = false; |
2726 if (failure_control == NULL) { // use MDO in regular case only |
2732 if (failure_control == NULL) { // use MDO in regular case only |
2727 assert(java_bc() == Bytecodes::_aastore || |
2733 assert(java_bc() == Bytecodes::_aastore || |
2728 java_bc() == Bytecodes::_checkcast, |
2734 java_bc() == Bytecodes::_checkcast, |
2729 "interpreter profiles type checks only for these BCs"); |
2735 "interpreter profiles type checks only for these BCs"); |
2730 data = method()->method_data()->bci_to_data(bci()); |
2736 data = method()->method_data()->bci_to_data(bci()); |
|
2737 safe_for_replace = true; |
2731 } |
2738 } |
2732 |
2739 |
2733 // Make the merge point |
2740 // Make the merge point |
2734 enum { _obj_path = 1, _null_path, PATH_LIMIT }; |
2741 enum { _obj_path = 1, _null_path, PATH_LIMIT }; |
2735 RegionNode* region = new (C) RegionNode(PATH_LIMIT); |
2742 RegionNode* region = new (C) RegionNode(PATH_LIMIT); |
2740 bool never_see_null = ((failure_control == NULL) // regular case only |
2747 bool never_see_null = ((failure_control == NULL) // regular case only |
2741 && seems_never_null(obj, data)); |
2748 && seems_never_null(obj, data)); |
2742 |
2749 |
2743 // Null check; get casted pointer; set region slot 3 |
2750 // Null check; get casted pointer; set region slot 3 |
2744 Node* null_ctl = top(); |
2751 Node* null_ctl = top(); |
2745 Node* not_null_obj = null_check_oop(obj, &null_ctl, never_see_null); |
2752 Node* not_null_obj = null_check_oop(obj, &null_ctl, never_see_null, safe_for_replace); |
2746 |
2753 |
2747 // If not_null_obj is dead, only null-path is taken |
2754 // If not_null_obj is dead, only null-path is taken |
2748 if (stopped()) { // Doing instance-of on a NULL? |
2755 if (stopped()) { // Doing instance-of on a NULL? |
2749 set_control(null_ctl); |
2756 set_control(null_ctl); |
2750 return null(); |
2757 return null(); |