comparison src/share/vm/opto/compile.cpp @ 3249:e1162778c1c8

7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error Summary: A referent object that is only weakly reachable at the start of concurrent marking but is re-attached to the strongly reachable object graph during marking may not be marked as live. This can cause the reference object to be processed prematurely and leave dangling pointers to the referent object. Implement a read barrier for the java.lang.ref.Reference::referent field by intrinsifying the Reference.get() method, and intercepting accesses though JNI, reflection, and Unsafe, so that when a non-null referent object is read it is also logged in an SATB buffer. Reviewed-by: kvn, iveresov, never, tonyp, dholmes
author johnc
date Thu, 07 Apr 2011 09:53:20 -0700
parents e6beb62de02d
children 92add02409c9
comparison
equal deleted inserted replaced
3248:e6beb62de02d 3249:e1162778c1c8
627 627
628 // Put top into the hash table ASAP. 628 // Put top into the hash table ASAP.
629 initial_gvn()->transform_no_reclaim(top()); 629 initial_gvn()->transform_no_reclaim(top());
630 630
631 // Set up tf(), start(), and find a CallGenerator. 631 // Set up tf(), start(), and find a CallGenerator.
632 CallGenerator* cg; 632 CallGenerator* cg = NULL;
633 if (is_osr_compilation()) { 633 if (is_osr_compilation()) {
634 const TypeTuple *domain = StartOSRNode::osr_domain(); 634 const TypeTuple *domain = StartOSRNode::osr_domain();
635 const TypeTuple *range = TypeTuple::make_range(method()->signature()); 635 const TypeTuple *range = TypeTuple::make_range(method()->signature());
636 init_tf(TypeFunc::make(domain, range)); 636 init_tf(TypeFunc::make(domain, range));
637 StartNode* s = new (this, 2) StartOSRNode(root(), domain); 637 StartNode* s = new (this, 2) StartOSRNode(root(), domain);
642 // Normal case. 642 // Normal case.
643 init_tf(TypeFunc::make(method())); 643 init_tf(TypeFunc::make(method()));
644 StartNode* s = new (this, 2) StartNode(root(), tf()->domain()); 644 StartNode* s = new (this, 2) StartNode(root(), tf()->domain());
645 initial_gvn()->set_type_bottom(s); 645 initial_gvn()->set_type_bottom(s);
646 init_start(s); 646 init_start(s);
647 float past_uses = method()->interpreter_invocation_count(); 647 if (method()->intrinsic_id() == vmIntrinsics::_Reference_get && UseG1GC) {
648 float expected_uses = past_uses; 648 // With java.lang.ref.reference.get() we must go through the
649 cg = CallGenerator::for_inline(method(), expected_uses); 649 // intrinsic when G1 is enabled - even when get() is the root
650 // method of the compile - so that, if necessary, the value in
651 // the referent field of the reference object gets recorded by
652 // the pre-barrier code.
653 // Specifically, if G1 is enabled, the value in the referent
654 // field is recorded by the G1 SATB pre barrier. This will
655 // result in the referent being marked live and the reference
656 // object removed from the list of discovered references during
657 // reference processing.
658 cg = find_intrinsic(method(), false);
659 }
660 if (cg == NULL) {
661 float past_uses = method()->interpreter_invocation_count();
662 float expected_uses = past_uses;
663 cg = CallGenerator::for_inline(method(), expected_uses);
664 }
650 } 665 }
651 if (failing()) return; 666 if (failing()) return;
652 if (cg == NULL) { 667 if (cg == NULL) {
653 record_method_not_compilable_all_tiers("cannot parse method"); 668 record_method_not_compilable_all_tiers("cannot parse method");
654 return; 669 return;