Move Trace to use trampolines

Change method tracing to use instrumentation trampolines instead of
interpreter. This is generally faster but can slow down recursion as
the stack gets longer. Due to this we need to disable several tests
which will no longer finish in a reasonable time.

Test: ./test.py --host --trace --ntrace

Change-Id: Id4fb7c997a854859f2998f72018980973d8493f8
diff --git a/runtime/trace.cc b/runtime/trace.cc
index 292cac6..1986eec 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -433,7 +433,12 @@
                                                    instrumentation::Instrumentation::kMethodExited |
                                                    instrumentation::Instrumentation::kMethodUnwind);
         // TODO: In full-PIC mode, we don't need to fully deopt.
-        runtime->GetInstrumentation()->EnableMethodTracing(kTracerInstrumentationKey);
+        // TODO: We can only use trampoline entrypoints if we are java-debuggable since in that case
+        // we know that inlining and other problematic optimizations are disabled. We might just
+        // want to use the trampolines anyway since it is faster. It makes the story with disabling
+        // jit-gc more complex though.
+        runtime->GetInstrumentation()->EnableMethodTracing(
+            kTracerInstrumentationKey, /*needs_interpreter*/!runtime->IsJavaDebuggable());
       }
     }
   }
diff --git a/test/knownfailures.json b/test/knownfailures.json
index 9ba2b50..2b7a9b0 100644
--- a/test/knownfailures.json
+++ b/test/knownfailures.json
@@ -193,6 +193,22 @@
         "bug": "http://b/34369284"
     },
     {
+        "tests": ["018-stack-overflow",
+                  "107-int-math2",
+                  "667-jit-jni-stub"],
+        "description": ["We run for long enough for jit to compile some of the methods ",
+                        "which means it takes so long to finish the test that it will ",
+                        "timeout. The timeout is due to having to walk the stack ",
+                        "when entering and exiting methods due to the way the instrumentation ",
+                        "trampoline is implemented."],
+        "variant": "debuggable & jit & trace | debuggable & jit & stream"
+    },
+    {
+        "tests": "1935-get-set-current-frame-jit",
+        "description": ["Test expects that OSR works but tracing turns this feature off."],
+        "variant": "trace | stream"
+    },
+    {
         "tests": "1940-ddms-ext",
         "description": ["Test expects to be able to start tracing but we cannot",
                         "do that if tracing is already ongoing."],
@@ -201,7 +217,7 @@
     {
         "tests": "137-cfi",
         "description": ["This test unrolls and expects managed frames, but",
-                        "tracing means we run the interpreter."],
+                        "tracing means we run the interpreter or trampolines."],
         "variant": "trace | stream"
     },
     {