[compiler-rt] r289682 - tsan: allow Java VM iterate over allocated objects
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 14 10:20:19 PST 2016
Author: dvyukov
Date: Wed Dec 14 12:20:18 2016
New Revision: 289682
URL: http://llvm.org/viewvc/llvm-project?rev=289682&view=rev
Log:
tsan: allow Java VM iterate over allocated objects
Objects may move during the garbage collection, and JVM needs
to notify ThreadAnalyzer about that. The new function
__tsan_java_find eliminates the need to maintain these
objects both in ThreadAnalyzer and JVM.
Author: Alexander Smundak (asmundak)
Reviewed in https://reviews.llvm.org/D27720
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_interface_java.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_interface_java.h
compiler-rt/trunk/test/tsan/java.h
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interface_java.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interface_java.cc?rev=289682&r1=289681&r2=289682&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interface_java.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interface_java.cc Wed Dec 14 12:20:18 2016
@@ -150,6 +150,23 @@ void __tsan_java_move(jptr src, jptr dst
}
}
+jptr __tsan_java_find(jptr *from_ptr, jptr to) {
+ SCOPED_JAVA_FUNC(__tsan_java_find);
+ DPrintf("#%d: java_find(&%p, %p)\n", *from_ptr, to);
+ CHECK_EQ((*from_ptr) % kHeapAlignment, 0);
+ CHECK_EQ(to % kHeapAlignment, 0);
+ CHECK_GE(*from_ptr, jctx->heap_begin);
+ CHECK_LE(to, jctx->heap_begin + jctx->heap_size);
+ for (uptr from = *from_ptr; from < to; from += kHeapAlignment) {
+ MBlock *b = ctx->metamap.GetBlock(from);
+ if (b) {
+ *from_ptr = from;
+ return b->siz;
+ }
+ }
+ return 0;
+}
+
void __tsan_java_finalize() {
SCOPED_JAVA_FUNC(__tsan_java_finalize);
DPrintf("#%d: java_mutex_finalize()\n", thr->tid);
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interface_java.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interface_java.h?rev=289682&r1=289681&r2=289682&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interface_java.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interface_java.h Wed Dec 14 12:20:18 2016
@@ -57,6 +57,10 @@ void __tsan_java_move(jptr src, jptr dst
// It ensures necessary synchronization between
// java object creation and finalization.
void __tsan_java_finalize() INTERFACE_ATTRIBUTE;
+// Finds the first allocated memory block in the [*from_ptr, to) range, saves
+// its address in *from_ptr and returns its size. Returns 0 if there are no
+// allocated memory blocks in the range.
+jptr __tsan_java_find(jptr *from_ptr, jptr to) INTERFACE_ATTRIBUTE;
// Mutex lock.
// Addr is any unique address associated with the mutex.
Modified: compiler-rt/trunk/test/tsan/java.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/java.h?rev=289682&r1=289681&r2=289682&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/java.h (original)
+++ compiler-rt/trunk/test/tsan/java.h Wed Dec 14 12:20:18 2016
@@ -7,6 +7,7 @@ void __tsan_java_init(jptr heap_begin, j
int __tsan_java_fini();
void __tsan_java_alloc(jptr ptr, jptr size);
void __tsan_java_free(jptr ptr, jptr size);
+jptr __tsan_java_find(jptr *from_ptr, jptr to);
void __tsan_java_move(jptr src, jptr dst, jptr size);
void __tsan_java_finalize();
void __tsan_java_mutex_lock(jptr addr);
More information about the llvm-commits
mailing list