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 on_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 || !on_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 = on_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 }
|
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 }
|