Add FinalizerTimeoutMs argument, and respect it
Add -XX:FinalizerTimeoutMs commandline argument, and make it
available for libcore.
Add 1336-short-finalizer-timeout to test it. Blacklist it for
the cases in which 030-bad-finalizers was known not to work,
since it's largely a clone. Disable it for gcstress, since timeout
margins are tight.
Increase timeout in 030-bad-finalizers due to gcstress issues.
Use the result in 004-NativeAllocations and 030-bad-finalizers
to avoid timeouts. Make 004-NativeAllocations more proactive in
avoiding timeout.
This is intended as a replacement for aosp/836642 .
Bug: 129350738
Bug: 68792448
Test: Boot AOSP, TreeHugger
Change-Id: I9aef9c9bacb7e8d851bd2c879ed9fb5b596abc60
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 449a5a4..e811230 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -272,6 +272,10 @@
return default_stack_size_;
}
+ unsigned int GetFinalizerTimeoutMs() const {
+ return finalizer_timeout_ms_;
+ }
+
gc::Heap* GetHeap() const {
return heap_;
}
@@ -944,6 +948,9 @@
// The default stack size for managed threads created by the runtime.
size_t default_stack_size_;
+ // Finalizers running for longer than this many milliseconds abort the runtime.
+ unsigned int finalizer_timeout_ms_;
+
gc::Heap* heap_;
std::unique_ptr<ArenaPool> jit_arena_pool_;