2982 // Null check; get casted pointer; set region slot 3 2983 Node* null_ctl = top(); 2984 Node* not_null_obj = null_check_oop(obj, &null_ctl, never_see_null, safe_for_replace); 2985 2986 // If not_null_obj is dead, only null-path is taken 2987 if (stopped()) { // Doing instance-of on a NULL? 2988 set_control(null_ctl); 2989 return null(); 2990 } 2991 region->init_req(_null_path, null_ctl); 2992 phi ->init_req(_null_path, null()); // Set null path value 2993 if (null_ctl == top()) { 2994 // Do this eagerly, so that pattern matches like is_diamond_phi 2995 // will work even during parsing. 2996 assert(_null_path == PATH_LIMIT-1, "delete last"); 2997 region->del_req(_null_path); 2998 phi ->del_req(_null_path); 2999 } 3000 3001 Node* cast_obj = NULL; 3002 const TypeOopPtr* obj_type = _gvn.type(obj)->is_oopptr(); 3003 // We may not have profiling here or it may not help us. If we have 3004 // a speculative type use it to perform an exact cast. 3005 ciKlass* spec_obj_type = obj_type->speculative_type(); 3006 if (spec_obj_type != NULL || 3007 (data != NULL && 3008 // Counter has never been decremented (due to cast failure). 3009 // ...This is a reasonable thing to expect. It is true of 3010 // all casts inserted by javac to implement generic types. 3011 data->as_CounterData()->count() >= 0)) { 3012 cast_obj = maybe_cast_profiled_receiver(not_null_obj, tk->klass(), spec_obj_type, safe_for_replace); 3013 if (cast_obj != NULL) { 3014 if (failure_control != NULL) // failure is now impossible 3015 (*failure_control) = top(); 3016 // adjust the type of the phi to the exact klass: 3017 phi->raise_bottom_type(_gvn.type(cast_obj)->meet_speculative(TypePtr::NULL_PTR)); 3018 } 3019 } 3020 3021 if (cast_obj == NULL) { 3022 // Load the object's klass 3023 Node* obj_klass = load_object_klass(not_null_obj); 3024 3025 // Generate the subtype check 3026 Node* not_subtype_ctrl = gen_subtype_check( obj_klass, superklass ); 3027 3028 // Plug in success path into the merge 3029 cast_obj = _gvn.transform(new (C) CheckCastPPNode(control(), 3030 not_null_obj, toop)); 3031 // Failure path ends in uncommon trap (or may be dead - failure impossible) 3032 if (failure_control == NULL) { 3033 if (not_subtype_ctrl != top()) { // If failure is possible 3034 PreserveJVMState pjvms(this); 3035 set_control(not_subtype_ctrl); 3036 builtin_throw(Deoptimization::Reason_class_check, obj_klass); 3037 } 3038 } else { 3039 (*failure_control) = not_subtype_ctrl; | 2982 // Null check; get casted pointer; set region slot 3 2983 Node* null_ctl = top(); 2984 Node* not_null_obj = null_check_oop(obj, &null_ctl, never_see_null, safe_for_replace); 2985 2986 // If not_null_obj is dead, only null-path is taken 2987 if (stopped()) { // Doing instance-of on a NULL? 2988 set_control(null_ctl); 2989 return null(); 2990 } 2991 region->init_req(_null_path, null_ctl); 2992 phi ->init_req(_null_path, null()); // Set null path value 2993 if (null_ctl == top()) { 2994 // Do this eagerly, so that pattern matches like is_diamond_phi 2995 // will work even during parsing. 2996 assert(_null_path == PATH_LIMIT-1, "delete last"); 2997 region->del_req(_null_path); 2998 phi ->del_req(_null_path); 2999 } 3000 3001 Node* cast_obj = NULL; 3002 if (tk->klass_is_exact()) { 3003 // The following optimization tries to statically cast the speculative type of the object 3004 // (for example obtained during profiling) to the type of the superklass and then do a 3005 // dynamic check that the type of the object is what we expect. To work correctly 3006 // for checkcast and aastore the type of superklass should be exact. 3007 const TypeOopPtr* obj_type = _gvn.type(obj)->is_oopptr(); 3008 // We may not have profiling here or it may not help us. If we have 3009 // a speculative type use it to perform an exact cast. 3010 ciKlass* spec_obj_type = obj_type->speculative_type(); 3011 if (spec_obj_type != NULL || 3012 (data != NULL && 3013 // Counter has never been decremented (due to cast failure). 3014 // ...This is a reasonable thing to expect. It is true of 3015 // all casts inserted by javac to implement generic types. 3016 data->as_CounterData()->count() >= 0)) { 3017 cast_obj = maybe_cast_profiled_receiver(not_null_obj, tk->klass(), spec_obj_type, safe_for_replace); 3018 if (cast_obj != NULL) { 3019 if (failure_control != NULL) // failure is now impossible 3020 (*failure_control) = top(); 3021 // adjust the type of the phi to the exact klass: 3022 phi->raise_bottom_type(_gvn.type(cast_obj)->meet_speculative(TypePtr::NULL_PTR)); 3023 } 3024 } 3025 } 3026 3027 if (cast_obj == NULL) { 3028 // Load the object's klass 3029 Node* obj_klass = load_object_klass(not_null_obj); 3030 3031 // Generate the subtype check 3032 Node* not_subtype_ctrl = gen_subtype_check( obj_klass, superklass ); 3033 3034 // Plug in success path into the merge 3035 cast_obj = _gvn.transform(new (C) CheckCastPPNode(control(), 3036 not_null_obj, toop)); 3037 // Failure path ends in uncommon trap (or may be dead - failure impossible) 3038 if (failure_control == NULL) { 3039 if (not_subtype_ctrl != top()) { // If failure is possible 3040 PreserveJVMState pjvms(this); 3041 set_control(not_subtype_ctrl); 3042 builtin_throw(Deoptimization::Reason_class_check, obj_klass); 3043 } 3044 } else { 3045 (*failure_control) = not_subtype_ctrl; |