forked from OSchip/llvm-project
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 llvm-svn: 289682
This commit is contained in:
parent
4b0790d488
commit
963f5490e2
|
@ -150,6 +150,23 @@ void __tsan_java_move(jptr src, jptr dst, jptr size) {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -57,6 +57,10 @@ void __tsan_java_move(jptr src, jptr dst, jptr size) INTERFACE_ATTRIBUTE;
|
|||
// 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.
|
||||
|
|
|
@ -7,6 +7,7 @@ void __tsan_java_init(jptr heap_begin, jptr heap_size);
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue