< prev index next >

src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp

Print this page




 577                     T_OBJECT);
 578         if (need_mem_bar) {
 579           // Add memory barrier to prevent commoning reads from this field
 580           // across safepoint since GC can change its value.
 581           kit->insert_mem_bar(Op_MemBarCPUOrder);
 582         }
 583         // Update IdealKit from graphKit.
 584         __ sync_kit(kit);
 585 
 586       } __ end_if(); // _ref_type != ref_none
 587   } __ end_if(); // offset == referent_offset
 588 
 589   // Final sync IdealKit and GraphKit.
 590   kit->final_sync(ideal);
 591 }
 592 
 593 #undef __
 594 
 595 Node* G1BarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) const {
 596   DecoratorSet decorators = access.decorators();
 597   GraphKit* kit = access.kit();
 598 
 599   Node* adr = access.addr().node();
 600   Node* obj = access.base();
 601 
 602   bool mismatched = (decorators & C2_MISMATCHED) != 0;
 603   bool unknown = (decorators & ON_UNKNOWN_OOP_REF) != 0;
 604   bool in_heap = (decorators & IN_HEAP) != 0;
 605   bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0;
 606   bool is_unordered = (decorators & MO_UNORDERED) != 0;
 607   bool need_cpu_mem_bar = !is_unordered || mismatched || !in_heap;
 608 
 609   Node* offset = adr->is_AddP() ? adr->in(AddPNode::Offset) : kit->top();

 610   Node* load = CardTableBarrierSetC2::load_at_resolved(access, val_type);
 611 
 612   // If we are reading the value of the referent field of a Reference
 613   // object (either by using Unsafe directly or through reflection)
 614   // then, if G1 is enabled, we need to record the referent in an
 615   // SATB log buffer using the pre-barrier mechanism.
 616   // Also we need to add memory barrier to prevent commoning reads
 617   // from this field across safepoint since GC can change its value.
 618   bool need_read_barrier = in_heap && (on_weak ||
 619                                        (unknown && offset != kit->top() && obj != kit->top()));
 620 
 621   if (!access.is_oop() || !need_read_barrier) {
 622     return load;
 623   }




 624 
 625   if (on_weak) {
 626     // Use the pre-barrier to record the value in the referent field
 627     pre_barrier(kit, false /* do_load */,
 628                 kit->control(),
 629                 NULL /* obj */, NULL /* adr */, max_juint /* alias_idx */, NULL /* val */, NULL /* val_type */,
 630                 load /* pre_val */, T_OBJECT);
 631     // Add memory barrier to prevent commoning reads from this field
 632     // across safepoint since GC can change its value.
 633     kit->insert_mem_bar(Op_MemBarCPUOrder);
 634   } else if (unknown) {
 635     // We do not require a mem bar inside pre_barrier if need_mem_bar
 636     // is set: the barriers would be emitted by us.
 637     insert_pre_barrier(kit, obj, offset, load, !need_cpu_mem_bar);
 638   }
 639 
 640   return load;
 641 }
 642 
 643 bool G1BarrierSetC2::is_gc_barrier_node(Node* node) const {




 577                     T_OBJECT);
 578         if (need_mem_bar) {
 579           // Add memory barrier to prevent commoning reads from this field
 580           // across safepoint since GC can change its value.
 581           kit->insert_mem_bar(Op_MemBarCPUOrder);
 582         }
 583         // Update IdealKit from graphKit.
 584         __ sync_kit(kit);
 585 
 586       } __ end_if(); // _ref_type != ref_none
 587   } __ end_if(); // offset == referent_offset
 588 
 589   // Final sync IdealKit and GraphKit.
 590   kit->final_sync(ideal);
 591 }
 592 
 593 #undef __
 594 
 595 Node* G1BarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) const {
 596   DecoratorSet decorators = access.decorators();


 597   Node* adr = access.addr().node();
 598   Node* obj = access.base();
 599 
 600   bool mismatched = (decorators & C2_MISMATCHED) != 0;
 601   bool unknown = (decorators & ON_UNKNOWN_OOP_REF) != 0;
 602   bool in_heap = (decorators & IN_HEAP) != 0;
 603   bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0;
 604   bool is_unordered = (decorators & MO_UNORDERED) != 0;
 605   bool need_cpu_mem_bar = !is_unordered || mismatched || !in_heap;
 606 
 607   Node* top = Compile::current()->top();
 608   Node* offset = adr->is_AddP() ? adr->in(AddPNode::Offset) : top;
 609   Node* load = CardTableBarrierSetC2::load_at_resolved(access, val_type);
 610 
 611   // If we are reading the value of the referent field of a Reference
 612   // object (either by using Unsafe directly or through reflection)
 613   // then, if G1 is enabled, we need to record the referent in an
 614   // SATB log buffer using the pre-barrier mechanism.
 615   // Also we need to add memory barrier to prevent commoning reads
 616   // from this field across safepoint since GC can change its value.
 617   bool need_read_barrier = in_heap && (on_weak ||
 618                                        (unknown && offset != top && obj != top));
 619 
 620   if (!access.is_oop() || !need_read_barrier) {
 621     return load;
 622   }
 623 
 624   assert(access.is_parse_access(), "entry not supported at optimization time");
 625   C2ParseAccess& parse_access = static_cast<C2ParseAccess&>(access);
 626   GraphKit* kit = parse_access.kit();
 627 
 628   if (on_weak) {
 629     // Use the pre-barrier to record the value in the referent field
 630     pre_barrier(kit, false /* do_load */,
 631                 kit->control(),
 632                 NULL /* obj */, NULL /* adr */, max_juint /* alias_idx */, NULL /* val */, NULL /* val_type */,
 633                 load /* pre_val */, T_OBJECT);
 634     // Add memory barrier to prevent commoning reads from this field
 635     // across safepoint since GC can change its value.
 636     kit->insert_mem_bar(Op_MemBarCPUOrder);
 637   } else if (unknown) {
 638     // We do not require a mem bar inside pre_barrier if need_mem_bar
 639     // is set: the barriers would be emitted by us.
 640     insert_pre_barrier(kit, obj, offset, load, !need_cpu_mem_bar);
 641   }
 642 
 643   return load;
 644 }
 645 
 646 bool G1BarrierSetC2::is_gc_barrier_node(Node* node) const {


< prev index next >