< prev index next >

src/hotspot/share/opto/graphKit.cpp

Print this page




2830   if (UncommonNullCast               // Cutout for this technique
2831       && obj != null()               // And not the -Xcomp stupid case?
2832       && !too_many_traps(reason)
2833       ) {
2834     if (speculating) {
2835       return true;
2836     }
2837     if (data == NULL)
2838       // Edge case:  no mature data.  Be optimistic here.
2839       return true;
2840     // If the profile has not seen a null, assume it won't happen.
2841     assert(java_bc() == Bytecodes::_checkcast ||
2842            java_bc() == Bytecodes::_instanceof ||
2843            java_bc() == Bytecodes::_aastore, "MDO must collect null_seen bit here");
2844     return !data->as_BitData()->null_seen();
2845   }
2846   speculating = false;
2847   return false;
2848 }
2849 






















































2850 //------------------------maybe_cast_profiled_receiver-------------------------
2851 // If the profile has seen exactly one type, narrow to exactly that type.
2852 // Subsequent type checks will always fold up.
2853 Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj,
2854                                              ciKlass* require_klass,
2855                                              ciKlass* spec_klass,
2856                                              bool safe_for_replace) {
2857   if (!UseTypeProfile || !TypeProfileCasts) return NULL;
2858 
2859   Deoptimization::DeoptReason reason = Deoptimization::reason_class_check(spec_klass != NULL);
2860 
2861   // Make sure we haven't already deoptimized from this tactic.
2862   if (too_many_traps_or_recompiles(reason))
2863     return NULL;
2864 
2865   // (No, this isn't a call, but it's enough like a virtual call
2866   // to use the same ciMethod accessor to get the profile info...)
2867   // If we have a speculative type use it instead of profiling (which
2868   // may not help us)
2869   ciKlass* exact_kls = spec_klass == NULL ? profile_has_unique_klass() : spec_klass;




2830   if (UncommonNullCast               // Cutout for this technique
2831       && obj != null()               // And not the -Xcomp stupid case?
2832       && !too_many_traps(reason)
2833       ) {
2834     if (speculating) {
2835       return true;
2836     }
2837     if (data == NULL)
2838       // Edge case:  no mature data.  Be optimistic here.
2839       return true;
2840     // If the profile has not seen a null, assume it won't happen.
2841     assert(java_bc() == Bytecodes::_checkcast ||
2842            java_bc() == Bytecodes::_instanceof ||
2843            java_bc() == Bytecodes::_aastore, "MDO must collect null_seen bit here");
2844     return !data->as_BitData()->null_seen();
2845   }
2846   speculating = false;
2847   return false;
2848 }
2849 
2850 void GraphKit::guard_klass_being_initialized(Node* klass) {
2851   int init_state_off = in_bytes(InstanceKlass::init_state_offset());
2852   Node* adr = basic_plus_adr(top(), klass, init_state_off);
2853   Node* init_state = LoadNode::make(_gvn, NULL, immutable_memory(), adr,
2854                                     adr->bottom_type()->is_ptr(), TypeInt::BYTE,
2855                                     T_BYTE, MemNode::unordered);
2856   init_state = _gvn.transform(init_state);
2857 
2858   Node* being_initialized_state = makecon(TypeInt::make(InstanceKlass::being_initialized));
2859 
2860   Node* chk = _gvn.transform(new CmpINode(being_initialized_state, init_state));
2861   Node* tst = _gvn.transform(new BoolNode(chk, BoolTest::eq));
2862 
2863   { BuildCutout unless(this, tst, PROB_MAX);
2864     uncommon_trap(Deoptimization::Reason_initialized, Deoptimization::Action_reinterpret);
2865   }
2866 }
2867 
2868 void GraphKit::guard_init_thread(Node* klass) {
2869   int init_thread_off = in_bytes(InstanceKlass::init_thread_offset());
2870   Node* adr = basic_plus_adr(top(), klass, init_thread_off);
2871 
2872   Node* init_thread = LoadNode::make(_gvn, NULL, immutable_memory(), adr,
2873                                      adr->bottom_type()->is_ptr(), TypePtr::NOTNULL,
2874                                      T_ADDRESS, MemNode::unordered);
2875   init_thread = _gvn.transform(init_thread);
2876 
2877   Node* cur_thread = _gvn.transform(new ThreadLocalNode());
2878 
2879   Node* chk = _gvn.transform(new CmpPNode(cur_thread, init_thread));
2880   Node* tst = _gvn.transform(new BoolNode(chk, BoolTest::eq));
2881 
2882   { BuildCutout unless(this, tst, PROB_MAX);
2883     uncommon_trap(Deoptimization::Reason_uninitialized, Deoptimization::Action_none);
2884   }
2885 }
2886 
2887 void GraphKit::clinit_barrier(ciInstanceKlass* ik, ciMethod* context) {
2888   if (ik->is_being_initialized()) {
2889     if (C->needs_clinit_barrier(ik, context)) {
2890       Node* klass = makecon(TypeKlassPtr::make(ik));
2891       guard_klass_being_initialized(klass);
2892       guard_init_thread(klass);
2893       insert_mem_bar(Op_MemBarCPUOrder);
2894     }
2895   } else if (ik->is_initialized()) {
2896     return; // no barrier needed
2897   } else {
2898     uncommon_trap(Deoptimization::Reason_uninitialized,
2899                   Deoptimization::Action_reinterpret,
2900                   NULL);
2901   }
2902 }
2903 
2904 //------------------------maybe_cast_profiled_receiver-------------------------
2905 // If the profile has seen exactly one type, narrow to exactly that type.
2906 // Subsequent type checks will always fold up.
2907 Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj,
2908                                              ciKlass* require_klass,
2909                                              ciKlass* spec_klass,
2910                                              bool safe_for_replace) {
2911   if (!UseTypeProfile || !TypeProfileCasts) return NULL;
2912 
2913   Deoptimization::DeoptReason reason = Deoptimization::reason_class_check(spec_klass != NULL);
2914 
2915   // Make sure we haven't already deoptimized from this tactic.
2916   if (too_many_traps_or_recompiles(reason))
2917     return NULL;
2918 
2919   // (No, this isn't a call, but it's enough like a virtual call
2920   // to use the same ciMethod accessor to get the profile info...)
2921   // If we have a speculative type use it instead of profiling (which
2922   // may not help us)
2923   ciKlass* exact_kls = spec_klass == NULL ? profile_has_unique_klass() : spec_klass;


< prev index next >