static jboolean Reference_refersTo0(JNIEnv* env, jobject javaThis, jobject o) { if (gUseReadBarrier && !kUseBakerReadBarrier) { // Fall back to naive implementation that may block and needlessly preserve javaThis. return env->IsSameObject(Reference_getReferent(env, javaThis), o);
}
ScopedFastNativeObjectAccess soa(env); const ObjPtr<mirror::Reference> ref = soa.Decode<mirror::Reference>(javaThis); const ObjPtr<mirror::Object> other = soa.Decode<mirror::Reference>(o); const ObjPtr<mirror::Object> referent = ref->template GetReferent<kWithoutReadBarrier>(); if (referent == other) { return JNI_TRUE;
} if (!gUseReadBarrier || referent.IsNull() || other.IsNull()) { return JNI_FALSE;
} // Explicitly handle the case in which referent is a from-space pointer. Don't use a // read-barrier, since that could easily mark an object we no longer need and, since it creates // new gray objects, may not be safe without blocking. // // Assume we're post flip in a GC. 'other' will always be a to-space reference. Thus the only // remaining case in which we should return true is when 'referent' still points to from-space. // ConcurrentCopying::Copy ensures that whenever a pointer to a to-space object is published, // the forwarding pointer is also visible. Thus if 'other' and 'javaThis' refer to the same // object, and we can ensure that the read of the forwarding pointer is ordered after the read // of other, which ensured the forwarding pointer was set, then we're guaranteed to see the // correct forwarding pointer, which should then match 'other'. This fence ensures that the // forwarding pointer read is ordered with respect to the access to 'other':
atomic_thread_fence(std::memory_order_acquire); // Note: On ARM and RISC-V, the above could be replaced by an asm fake-dependency hack to make // referent appear to depend on other. That would be faster and uglier. return gc::collector::ConcurrentCopying::GetFwdPtrUnchecked(referent.Ptr()) == other.Ptr() ?
JNI_TRUE : JNI_FALSE;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.