mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
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
This commit is contained in:
parent
aac4647e6e
commit
a08e1ce906
41 changed files with 1423 additions and 268 deletions
|
@ -29,6 +29,9 @@
|
|||
#include "classfile/systemDictionary.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "interpreter/linkResolver.hpp"
|
||||
#ifndef SERIALGC
|
||||
#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
|
||||
#endif // SERIALGC
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/gcLocker.inline.hpp"
|
||||
#include "memory/oopFactory.hpp"
|
||||
|
@ -1724,6 +1727,26 @@ JNI_ENTRY(jobject, jni_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID
|
|||
o = JvmtiExport::jni_GetField_probe(thread, obj, o, k, fieldID, false);
|
||||
}
|
||||
jobject ret = JNIHandles::make_local(env, o->obj_field(offset));
|
||||
#ifndef SERIALGC
|
||||
// If G1 is enabled and we are accessing the value of the referent
|
||||
// field in a reference object then we need to register a non-null
|
||||
// referent with the SATB barrier.
|
||||
if (UseG1GC) {
|
||||
bool needs_barrier = false;
|
||||
|
||||
if (ret != NULL &&
|
||||
offset == java_lang_ref_Reference::referent_offset &&
|
||||
instanceKlass::cast(k)->reference_type() != REF_NONE) {
|
||||
assert(instanceKlass::cast(k)->is_subclass_of(SystemDictionary::Reference_klass()), "sanity");
|
||||
needs_barrier = true;
|
||||
}
|
||||
|
||||
if (needs_barrier) {
|
||||
oop referent = JNIHandles::resolve(ret);
|
||||
G1SATBCardTableModRefBS::enqueue(referent);
|
||||
}
|
||||
}
|
||||
#endif // SERIALGC
|
||||
DTRACE_PROBE1(hotspot_jni, GetObjectField__return, ret);
|
||||
return ret;
|
||||
JNI_END
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue