comparison src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp @ 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 0ac769a57c64
children 92add02409c9
comparison
equal deleted inserted replaced
3248:e6beb62de02d 3249:e1162778c1c8
1 /* 1 /*
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
35 35
36 // This barrier is specialized to use a logging barrier to support 36 // This barrier is specialized to use a logging barrier to support
37 // snapshot-at-the-beginning marking. 37 // snapshot-at-the-beginning marking.
38 38
39 class G1SATBCardTableModRefBS: public CardTableModRefBSForCTRS { 39 class G1SATBCardTableModRefBS: public CardTableModRefBSForCTRS {
40 private: 40 public:
41 // Add "pre_val" to a set of objects that may have been disconnected from the 41 // Add "pre_val" to a set of objects that may have been disconnected from the
42 // pre-marking object graph. 42 // pre-marking object graph.
43 static void enqueue(oop pre_val); 43 static void enqueue(oop pre_val);
44 44
45 public:
46 G1SATBCardTableModRefBS(MemRegion whole_heap, 45 G1SATBCardTableModRefBS(MemRegion whole_heap,
47 int max_covered_regions); 46 int max_covered_regions);
48 47
49 bool is_a(BarrierSet::Name bsn) { 48 bool is_a(BarrierSet::Name bsn) {
50 return bsn == BarrierSet::G1SATBCT || CardTableModRefBS::is_a(bsn); 49 return bsn == BarrierSet::G1SATBCT || CardTableModRefBS::is_a(bsn);
58 T heap_oop = oopDesc::load_heap_oop(field); 57 T heap_oop = oopDesc::load_heap_oop(field);
59 if (!oopDesc::is_null(heap_oop)) { 58 if (!oopDesc::is_null(heap_oop)) {
60 enqueue(oopDesc::decode_heap_oop(heap_oop)); 59 enqueue(oopDesc::decode_heap_oop(heap_oop));
61 } 60 }
62 } 61 }
63
64 // When we know the current java thread:
65 template <class T> static void write_ref_field_pre_static(T* field, oop newVal,
66 JavaThread* jt);
67 62
68 // We export this to make it available in cases where the static 63 // We export this to make it available in cases where the static
69 // type of the barrier set is known. Note that it is non-virtual. 64 // type of the barrier set is known. Note that it is non-virtual.
70 template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal) { 65 template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal) {
71 write_ref_field_pre_static(field, newVal); 66 write_ref_field_pre_static(field, newVal);