Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.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 | f95d63e2154a |
children | f08d439fab8c |
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. |
45 _kind = G1SATBCT; | 45 _kind = G1SATBCT; |
46 } | 46 } |
47 | 47 |
48 | 48 |
49 void G1SATBCardTableModRefBS::enqueue(oop pre_val) { | 49 void G1SATBCardTableModRefBS::enqueue(oop pre_val) { |
50 assert(pre_val->is_oop_or_null(true), "Error"); | 50 // Nulls should have been already filtered. |
51 assert(pre_val->is_oop(true), "Error"); | |
52 | |
51 if (!JavaThread::satb_mark_queue_set().is_active()) return; | 53 if (!JavaThread::satb_mark_queue_set().is_active()) return; |
52 Thread* thr = Thread::current(); | 54 Thread* thr = Thread::current(); |
53 if (thr->is_Java_thread()) { | 55 if (thr->is_Java_thread()) { |
54 JavaThread* jt = (JavaThread*)thr; | 56 JavaThread* jt = (JavaThread*)thr; |
55 jt->satb_mark_queue().enqueue(pre_val); | 57 jt->satb_mark_queue().enqueue(pre_val); |
56 } else { | 58 } else { |
57 MutexLocker x(Shared_SATB_Q_lock); | 59 MutexLocker x(Shared_SATB_Q_lock); |
58 JavaThread::satb_mark_queue_set().shared_satb_queue()->enqueue(pre_val); | 60 JavaThread::satb_mark_queue_set().shared_satb_queue()->enqueue(pre_val); |
59 } | |
60 } | |
61 | |
62 // When we know the current java thread: | |
63 template <class T> void | |
64 G1SATBCardTableModRefBS::write_ref_field_pre_static(T* field, | |
65 oop new_val, | |
66 JavaThread* jt) { | |
67 if (!JavaThread::satb_mark_queue_set().is_active()) return; | |
68 T heap_oop = oopDesc::load_heap_oop(field); | |
69 if (!oopDesc::is_null(heap_oop)) { | |
70 oop pre_val = oopDesc::decode_heap_oop_not_null(heap_oop); | |
71 assert(pre_val->is_oop(true /* ignore mark word */), "Error"); | |
72 jt->satb_mark_queue().enqueue(pre_val); | |
73 } | 61 } |
74 } | 62 } |
75 | 63 |
76 template <class T> void | 64 template <class T> void |
77 G1SATBCardTableModRefBS::write_ref_array_pre_work(T* dst, int count) { | 65 G1SATBCardTableModRefBS::write_ref_array_pre_work(T* dst, int count) { |