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/test/knownfailures.json b/test/knownfailures.json
index c5e4221..e78e002 100644
--- a/test/knownfailures.json
+++ b/test/knownfailures.json
@@ -375,7 +375,8 @@
         "tests": ["530-checker-lse",
                   "530-checker-lse2",
                   "030-bad-finalizer",
-                  "080-oom-throw"],
+                  "080-oom-throw",
+                  "1336-short-finalizer-timeout"],
         "bug": "http://b/36377828",
         "variant": "interp-ac"
     },
@@ -1064,6 +1065,7 @@
           "993-breakpoints",
           "1002-notify-startup",
           "1003-metadata-section-strings",
+          "1336-short-finalizer-timeout",
           "1900-track-alloc",
           "1906-suspend-list-me-first",
           "1914-get-local-instance",
@@ -1149,6 +1151,12 @@
         "description": ["Test timing out under gcstress possibly due to slower unwinding by libbacktrace"]
     },
     {
+        "tests": ["1336-short-finalizer-timeout"],
+        "variant": "gcstress",
+        "bug": "b/68792448",
+        "description": ["Timing margins are too tight for gcstress"]
+    },
+    {
         "tests": ["021-string2"],
         "variant": "jit & debuggable",
         "bug": "b/109791792",