< prev index next >

src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp

Print this page




 758 
 759 bool ShenandoahBarrierSetC2::optimize_loops(PhaseIdealLoop* phase, LoopOptsMode mode, VectorSet& visited, Node_Stack& nstack, Node_List& worklist) const {
 760   if (mode == LoopOptsShenandoahExpand) {
 761     assert(UseShenandoahGC, "only for shenandoah");
 762     ShenandoahBarrierC2Support::pin_and_expand(phase);
 763     return true;
 764   } else if (mode == LoopOptsShenandoahPostExpand) {
 765     assert(UseShenandoahGC, "only for shenandoah");
 766     visited.clear();
 767     ShenandoahBarrierC2Support::optimize_after_expansion(visited, nstack, worklist, phase);
 768     return true;
 769   }
 770   return false;
 771 }
 772 
 773 bool ShenandoahBarrierSetC2::array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type, bool is_clone, ArrayCopyPhase phase) const {
 774   bool is_oop = is_reference_type(type);
 775   if (!is_oop) {
 776     return false;
 777   }
 778   if (tightly_coupled_alloc) {
 779     if (phase == Optimization) {
 780       return false;
 781     }
 782     return !is_clone;
 783   }
 784   if (phase == Optimization) {
 785     return !ShenandoahStoreValEnqueueBarrier;
 786   }
 787   return true;
 788 }
 789 
 790 bool ShenandoahBarrierSetC2::clone_needs_barrier(Node* src, PhaseGVN& gvn) {
 791   const TypeOopPtr* src_type = gvn.type(src)->is_oopptr();
 792   if (src_type->isa_instptr() != NULL) {
 793     ciInstanceKlass* ik = src_type->klass()->as_instance_klass();
 794     if ((src_type->klass_is_exact() || (!ik->is_interface() && !ik->has_subklass())) && !ik->has_injected_fields()) {
 795       if (ik->has_object_fields()) {
 796         return true;
 797       } else {
 798         if (!src_type->klass_is_exact()) {


 825   Node* src = phase->basic_plus_adr(src_base, src_offset);
 826   Node* dest = phase->basic_plus_adr(dest_base, dest_offset);
 827 
 828   if (ShenandoahCloneBarrier && clone_needs_barrier(src, phase->igvn())) {
 829     // Check if heap is has forwarded objects. If it does, we need to call into the special
 830     // routine that would fix up source references before we can continue.
 831 
 832     enum { _heap_stable = 1, _heap_unstable, PATH_LIMIT };
 833     Node* region = new RegionNode(PATH_LIMIT);
 834     Node* mem_phi = new PhiNode(region, Type::MEMORY, TypeRawPtr::BOTTOM);
 835 
 836     Node* thread = phase->transform_later(new ThreadLocalNode());
 837     Node* offset = phase->igvn().MakeConX(in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
 838     Node* gc_state_addr = phase->transform_later(new AddPNode(phase->C->top(), thread, offset));
 839 
 840     uint gc_state_idx = Compile::AliasIdxRaw;
 841     const TypePtr* gc_state_adr_type = NULL; // debug-mode-only argument
 842     debug_only(gc_state_adr_type = phase->C->get_adr_type(gc_state_idx));
 843 
 844     Node* gc_state    = phase->transform_later(new LoadBNode(ctrl, mem, gc_state_addr, gc_state_adr_type, TypeInt::BYTE, MemNode::unordered));
 845     Node* stable_and  = phase->transform_later(new AndINode(gc_state, phase->igvn().intcon(ShenandoahHeap::HAS_FORWARDED)));




 846     Node* stable_cmp  = phase->transform_later(new CmpINode(stable_and, phase->igvn().zerocon(T_INT)));
 847     Node* stable_test = phase->transform_later(new BoolNode(stable_cmp, BoolTest::ne));
 848 
 849     IfNode* stable_iff  = phase->transform_later(new IfNode(ctrl, stable_test, PROB_UNLIKELY(0.999), COUNT_UNKNOWN))->as_If();
 850     Node* stable_ctrl   = phase->transform_later(new IfFalseNode(stable_iff));
 851     Node* unstable_ctrl = phase->transform_later(new IfTrueNode(stable_iff));
 852 
 853     // Heap is stable, no need to do anything additional
 854     region->init_req(_heap_stable, stable_ctrl);
 855     mem_phi->init_req(_heap_stable, mem);
 856 
 857     // Heap is unstable, call into clone barrier stub
 858     Node* call = phase->make_leaf_call(unstable_ctrl, mem,
 859                     ShenandoahBarrierSetC2::shenandoah_clone_barrier_Type(),
 860                     CAST_FROM_FN_PTR(address, ShenandoahRuntime::shenandoah_clone_barrier),
 861                     "shenandoah_clone",
 862                     TypeRawPtr::BOTTOM,
 863                     src_base);
 864     call = phase->transform_later(call);
 865 




 758 
 759 bool ShenandoahBarrierSetC2::optimize_loops(PhaseIdealLoop* phase, LoopOptsMode mode, VectorSet& visited, Node_Stack& nstack, Node_List& worklist) const {
 760   if (mode == LoopOptsShenandoahExpand) {
 761     assert(UseShenandoahGC, "only for shenandoah");
 762     ShenandoahBarrierC2Support::pin_and_expand(phase);
 763     return true;
 764   } else if (mode == LoopOptsShenandoahPostExpand) {
 765     assert(UseShenandoahGC, "only for shenandoah");
 766     visited.clear();
 767     ShenandoahBarrierC2Support::optimize_after_expansion(visited, nstack, worklist, phase);
 768     return true;
 769   }
 770   return false;
 771 }
 772 
 773 bool ShenandoahBarrierSetC2::array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type, bool is_clone, ArrayCopyPhase phase) const {
 774   bool is_oop = is_reference_type(type);
 775   if (!is_oop) {
 776     return false;
 777   }
 778   if (tightly_coupled_alloc && ShenandoahSATBBarrier) {
 779     if (phase == Optimization) {
 780       return false;
 781     }
 782     return !is_clone;
 783   }
 784   if (phase == Optimization) {
 785     return !ShenandoahStoreValEnqueueBarrier;
 786   }
 787   return true;
 788 }
 789 
 790 bool ShenandoahBarrierSetC2::clone_needs_barrier(Node* src, PhaseGVN& gvn) {
 791   const TypeOopPtr* src_type = gvn.type(src)->is_oopptr();
 792   if (src_type->isa_instptr() != NULL) {
 793     ciInstanceKlass* ik = src_type->klass()->as_instance_klass();
 794     if ((src_type->klass_is_exact() || (!ik->is_interface() && !ik->has_subklass())) && !ik->has_injected_fields()) {
 795       if (ik->has_object_fields()) {
 796         return true;
 797       } else {
 798         if (!src_type->klass_is_exact()) {


 825   Node* src = phase->basic_plus_adr(src_base, src_offset);
 826   Node* dest = phase->basic_plus_adr(dest_base, dest_offset);
 827 
 828   if (ShenandoahCloneBarrier && clone_needs_barrier(src, phase->igvn())) {
 829     // Check if heap is has forwarded objects. If it does, we need to call into the special
 830     // routine that would fix up source references before we can continue.
 831 
 832     enum { _heap_stable = 1, _heap_unstable, PATH_LIMIT };
 833     Node* region = new RegionNode(PATH_LIMIT);
 834     Node* mem_phi = new PhiNode(region, Type::MEMORY, TypeRawPtr::BOTTOM);
 835 
 836     Node* thread = phase->transform_later(new ThreadLocalNode());
 837     Node* offset = phase->igvn().MakeConX(in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
 838     Node* gc_state_addr = phase->transform_later(new AddPNode(phase->C->top(), thread, offset));
 839 
 840     uint gc_state_idx = Compile::AliasIdxRaw;
 841     const TypePtr* gc_state_adr_type = NULL; // debug-mode-only argument
 842     debug_only(gc_state_adr_type = phase->C->get_adr_type(gc_state_idx));
 843 
 844     Node* gc_state    = phase->transform_later(new LoadBNode(ctrl, mem, gc_state_addr, gc_state_adr_type, TypeInt::BYTE, MemNode::unordered));
 845     int flags = ShenandoahHeap::HAS_FORWARDED;
 846     if (ShenandoahStoreValEnqueueBarrier) {
 847       flags |= ShenandoahHeap::MARKING;
 848     }
 849     Node* stable_and  = phase->transform_later(new AndINode(gc_state, phase->igvn().intcon(flags)));
 850     Node* stable_cmp  = phase->transform_later(new CmpINode(stable_and, phase->igvn().zerocon(T_INT)));
 851     Node* stable_test = phase->transform_later(new BoolNode(stable_cmp, BoolTest::ne));
 852 
 853     IfNode* stable_iff  = phase->transform_later(new IfNode(ctrl, stable_test, PROB_UNLIKELY(0.999), COUNT_UNKNOWN))->as_If();
 854     Node* stable_ctrl   = phase->transform_later(new IfFalseNode(stable_iff));
 855     Node* unstable_ctrl = phase->transform_later(new IfTrueNode(stable_iff));
 856 
 857     // Heap is stable, no need to do anything additional
 858     region->init_req(_heap_stable, stable_ctrl);
 859     mem_phi->init_req(_heap_stable, mem);
 860 
 861     // Heap is unstable, call into clone barrier stub
 862     Node* call = phase->make_leaf_call(unstable_ctrl, mem,
 863                     ShenandoahBarrierSetC2::shenandoah_clone_barrier_Type(),
 864                     CAST_FROM_FN_PTR(address, ShenandoahRuntime::shenandoah_clone_barrier),
 865                     "shenandoah_clone",
 866                     TypeRawPtr::BOTTOM,
 867                     src_base);
 868     call = phase->transform_later(call);
 869 


< prev index next >