src/share/vm/opto/graphKit.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/graphKit.cpp

Print this page
rev 8008 : 8073866: Fix for 8064703 is not sufficient
Summary: side effects between allocation and arraycopy can be reexecuted, unreachable uninitialized array can be seen by GCs
Reviewed-by:


2778         replace_in_map(not_null_obj, exact_obj);
2779       }
2780       return exact_obj;
2781     }
2782     // assert(ssc == Compile::SSC_always_true)... except maybe the profile lied to us.
2783   }
2784 
2785   return NULL;
2786 }
2787 
2788 /**
2789  * Cast obj to type and emit guard unless we had too many traps here
2790  * already
2791  *
2792  * @param obj       node being casted
2793  * @param type      type to cast the node to
2794  * @param not_null  true if we know node cannot be null
2795  */
2796 Node* GraphKit::maybe_cast_profiled_obj(Node* obj,
2797                                         ciKlass* type,
2798                                         bool not_null,
2799                                         SafePointNode* sfpt) {
2800   // type == NULL if profiling tells us this object is always null
2801   if (type != NULL) {
2802     Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check;
2803     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 
2807     if (!too_many_traps(null_reason) && !too_many_recompiles(null_reason) &&
2808         !C->too_many_traps(trap_method, trap_bci, class_reason) &&
2809         !C->too_many_recompiles(trap_method, trap_bci, class_reason)) {
2810       Node* not_null_obj = NULL;
2811       // not_null is true if we know the object is not null and
2812       // there's no need for a null check
2813       if (!not_null) {
2814         Node* null_ctl = top();
2815         not_null_obj = null_check_oop(obj, &null_ctl, true, true, true);
2816         assert(null_ctl->is_top(), "no null control here");
2817       } else {
2818         not_null_obj = obj;
2819       }
2820 
2821       Node* exact_obj = not_null_obj;
2822       ciKlass* exact_kls = type;
2823       Node* slow_ctl  = type_check_receiver(exact_obj, exact_kls, 1.0,
2824                                             &exact_obj);
2825       if (sfpt != NULL) {
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);
2832         set_control(slow_ctl);
2833         uncommon_trap_exact(class_reason, Deoptimization::Action_maybe_recompile);
2834       }
2835       replace_in_map(not_null_obj, exact_obj);
2836       obj = exact_obj;
2837     }
2838   } else {
2839     if (!too_many_traps(Deoptimization::Reason_null_assert) &&
2840         !too_many_recompiles(Deoptimization::Reason_null_assert)) {
2841       Node* exact_obj = null_assert(obj);
2842       replace_in_map(obj, exact_obj);
2843       obj = exact_obj;
2844     }
2845   }
2846   return obj;
2847 }
2848 
2849 //-------------------------------gen_instanceof--------------------------------
2850 // Generate an instance-of idiom.  Used by both the instance-of bytecode




2778         replace_in_map(not_null_obj, exact_obj);
2779       }
2780       return exact_obj;
2781     }
2782     // assert(ssc == Compile::SSC_always_true)... except maybe the profile lied to us.
2783   }
2784 
2785   return NULL;
2786 }
2787 
2788 /**
2789  * Cast obj to type and emit guard unless we had too many traps here
2790  * already
2791  *
2792  * @param obj       node being casted
2793  * @param type      type to cast the node to
2794  * @param not_null  true if we know node cannot be null
2795  */
2796 Node* GraphKit::maybe_cast_profiled_obj(Node* obj,
2797                                         ciKlass* type,
2798                                         bool not_null) {

2799   // type == NULL if profiling tells us this object is always null
2800   if (type != NULL) {
2801     Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check;
2802     Deoptimization::DeoptReason null_reason = Deoptimization::Reason_speculate_null_check;


2803 
2804     if (!too_many_traps(null_reason) && !too_many_recompiles(null_reason) &&
2805         !too_many_traps(class_reason) &&
2806         !too_many_recompiles(class_reason)) {
2807       Node* not_null_obj = NULL;
2808       // not_null is true if we know the object is not null and
2809       // there's no need for a null check
2810       if (!not_null) {
2811         Node* null_ctl = top();
2812         not_null_obj = null_check_oop(obj, &null_ctl, true, true, true);
2813         assert(null_ctl->is_top(), "no null control here");
2814       } else {
2815         not_null_obj = obj;
2816       }
2817 
2818       Node* exact_obj = not_null_obj;
2819       ciKlass* exact_kls = type;
2820       Node* slow_ctl  = type_check_receiver(exact_obj, exact_kls, 1.0,
2821                                             &exact_obj);
2822       {





2823         PreserveJVMState pjvms(this);
2824         set_control(slow_ctl);
2825         uncommon_trap_exact(class_reason, Deoptimization::Action_maybe_recompile);
2826       }
2827       replace_in_map(not_null_obj, exact_obj);
2828       obj = exact_obj;
2829     }
2830   } else {
2831     if (!too_many_traps(Deoptimization::Reason_null_assert) &&
2832         !too_many_recompiles(Deoptimization::Reason_null_assert)) {
2833       Node* exact_obj = null_assert(obj);
2834       replace_in_map(obj, exact_obj);
2835       obj = exact_obj;
2836     }
2837   }
2838   return obj;
2839 }
2840 
2841 //-------------------------------gen_instanceof--------------------------------
2842 // Generate an instance-of idiom.  Used by both the instance-of bytecode


src/share/vm/opto/graphKit.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File