3005 region->del_req(_null_path); |
3005 region->del_req(_null_path); |
3006 phi ->del_req(_null_path); |
3006 phi ->del_req(_null_path); |
3007 } |
3007 } |
3008 |
3008 |
3009 Node* cast_obj = NULL; |
3009 Node* cast_obj = NULL; |
3010 const TypeOopPtr* obj_type = _gvn.type(obj)->is_oopptr(); |
3010 if (tk->klass_is_exact()) { |
3011 // We may not have profiling here or it may not help us. If we have |
3011 // The following optimization tries to statically cast the speculative type of the object |
3012 // a speculative type use it to perform an exact cast. |
3012 // (for example obtained during profiling) to the type of the superklass and then do a |
3013 ciKlass* spec_obj_type = obj_type->speculative_type(); |
3013 // dynamic check that the type of the object is what we expect. To work correctly |
3014 if (spec_obj_type != NULL || |
3014 // for checkcast and aastore the type of superklass should be exact. |
3015 (data != NULL && |
3015 const TypeOopPtr* obj_type = _gvn.type(obj)->is_oopptr(); |
3016 // Counter has never been decremented (due to cast failure). |
3016 // We may not have profiling here or it may not help us. If we have |
3017 // ...This is a reasonable thing to expect. It is true of |
3017 // a speculative type use it to perform an exact cast. |
3018 // all casts inserted by javac to implement generic types. |
3018 ciKlass* spec_obj_type = obj_type->speculative_type(); |
3019 data->as_CounterData()->count() >= 0)) { |
3019 if (spec_obj_type != NULL || |
3020 cast_obj = maybe_cast_profiled_receiver(not_null_obj, tk->klass(), spec_obj_type, safe_for_replace); |
3020 (data != NULL && |
3021 if (cast_obj != NULL) { |
3021 // Counter has never been decremented (due to cast failure). |
3022 if (failure_control != NULL) // failure is now impossible |
3022 // ...This is a reasonable thing to expect. It is true of |
3023 (*failure_control) = top(); |
3023 // all casts inserted by javac to implement generic types. |
3024 // adjust the type of the phi to the exact klass: |
3024 data->as_CounterData()->count() >= 0)) { |
3025 phi->raise_bottom_type(_gvn.type(cast_obj)->meet_speculative(TypePtr::NULL_PTR)); |
3025 cast_obj = maybe_cast_profiled_receiver(not_null_obj, tk->klass(), spec_obj_type, safe_for_replace); |
|
3026 if (cast_obj != NULL) { |
|
3027 if (failure_control != NULL) // failure is now impossible |
|
3028 (*failure_control) = top(); |
|
3029 // adjust the type of the phi to the exact klass: |
|
3030 phi->raise_bottom_type(_gvn.type(cast_obj)->meet_speculative(TypePtr::NULL_PTR)); |
|
3031 } |
3026 } |
3032 } |
3027 } |
3033 } |
3028 |
3034 |
3029 if (cast_obj == NULL) { |
3035 if (cast_obj == NULL) { |
3030 // Load the object's klass |
3036 // Load the object's klass |