Merge "Disable inlining for some jctf tests."
diff --git a/src/test/java/com/android/tools/r8/JctfTestSpecifications.java b/src/test/java/com/android/tools/r8/JctfTestSpecifications.java
index eba8db6..055a880 100644
--- a/src/test/java/com/android/tools/r8/JctfTestSpecifications.java
+++ b/src/test/java/com/android/tools/r8/JctfTestSpecifications.java
@@ -18,6 +18,7 @@
 import com.google.common.collect.ImmutableListMultimap;
 import com.google.common.collect.Multimap;
 import java.util.Collection;
+import java.util.function.BiFunction;
 
 public class JctfTestSpecifications {
 
@@ -4808,6 +4809,20 @@
           .put("lang.RuntimePermission.Class.RuntimePermission_class_A13", any())
           .build(); // end of timeoutsWithArt
 
+  public static final Multimap<String, TestCondition> requiresInliningDisabled =
+      new ImmutableListMultimap.Builder<String, TestCondition>()
+          .put("lang.Throwable.printStackTrace.Throwable_printStackTrace_A01", match(R8_COMPILER))
+          .put("lang.Throwable.printStackTraceLjava_io_PrintWriter.Throwable_printStackTrace_A01",
+              match(R8_COMPILER))
+          .put("lang.Throwable.printStackTraceLjava_io_PrintStream.Throwable_printStackTrace_A01",
+              match(R8_COMPILER))
+          .put("lang.ref.SoftReference.isEnqueued.SoftReference_isEnqueued_A01", match(R8_COMPILER))
+          .put("lang.ref.WeakReference.isEnqueued.WeakReference_isEnqueued_A01", match(R8_COMPILER))
+          .put("lang.StackTraceElement.getMethodName.StackTraceElement_getMethodName_A01",
+              match(R8_COMPILER))
+          .put("lang.Thread.dumpStack.Thread_dumpStack_A01", match(R8_COMPILER))
+          .build();
+
   private static final boolean testMatch(
       Multimap<String, TestCondition> testConditions,
       String name,
@@ -4823,18 +4838,19 @@
     return false;
   }
 
-  public static final Outcome getExpectedOutcome(
+  public static final <T> T getExpectedOutcome(
       String name,
       CompilerUnderTest compilerUnderTest,
       DexVm dexVm,
-      CompilationMode compilationMode) {
+      CompilationMode compilationMode,
+      BiFunction<Outcome, Boolean, T> consumer) {
 
     Outcome outcome = null;
 
     if (testMatch(failuresToTriage, name, compilerUnderTest, dexVm, compilationMode)) {
       outcome = Outcome.FAILS_WITH_ART;
     }
-    if (testMatch(timeoutsWithArt, name, compilerUnderTest, dexVm, compilationMode)) {
+    if (testMatch(requiresInliningDisabled, name, compilerUnderTest, dexVm, compilationMode)) {
       assert outcome == null;
       outcome = Outcome.TIMEOUTS_WITH_ART;
     }
@@ -4842,6 +4858,11 @@
       assert outcome == null;
       outcome = Outcome.FLAKY_WITH_ART;
     }
-    return outcome == null ? Outcome.PASSES : outcome;
+    if (outcome == null) {
+      outcome = Outcome.PASSES;
+    }
+    boolean disableInlining = testMatch(requiresInliningDisabled, name, compilerUnderTest, dexVm,
+        compilationMode);
+    return consumer.apply(outcome, disableInlining);
   }
 }
diff --git a/src/test/java/com/android/tools/r8/R8RunArtTestsTest.java b/src/test/java/com/android/tools/r8/R8RunArtTestsTest.java
index 0b3395b..fabf8e7 100644
--- a/src/test/java/com/android/tools/r8/R8RunArtTestsTest.java
+++ b/src/test/java/com/android/tools/r8/R8RunArtTestsTest.java
@@ -7,6 +7,7 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
+import com.android.tools.r8.JctfTestSpecifications.Outcome;
 import com.android.tools.r8.ToolHelper.ArtCommandBuilder;
 import com.android.tools.r8.ToolHelper.DexVm;
 import com.android.tools.r8.ToolHelper.ProcessResult;
@@ -43,6 +44,7 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
+import java.util.function.BiFunction;
 import java.util.stream.Collectors;
 import org.junit.ComparisonFailure;
 import org.junit.Rule;
@@ -851,9 +853,9 @@
     }
 
     TestSpecification(String name, DexTool dexTool, File directory, boolean skipArt,
-        boolean failsWithArt) {
+        boolean failsWithArt, boolean disableInlining) {
       this(name, dexTool, directory, skipArt,
-          false, false, failsWithArt, false, false, null, false, false, false);
+          false, false, failsWithArt, false, false, null, false, false, disableInlining);
     }
 
     public File resolveFile(String name) {
@@ -1184,6 +1186,15 @@
     return auxClassFiles;
   }
 
+  private static BiFunction<Outcome, Boolean, TestSpecification> jctfOutcomeToSpecification(
+      String name, DexTool dexTool, File resultDir) {
+    return (outcome, noInlining) -> new TestSpecification(name, dexTool, resultDir,
+        outcome == JctfTestSpecifications.Outcome.TIMEOUTS_WITH_ART
+            || outcome == JctfTestSpecifications.Outcome.FLAKY_WITH_ART,
+        outcome == JctfTestSpecifications.Outcome.FAILS_WITH_ART,
+        noInlining);
+  }
+
   protected void runJctfTest(CompilerUnderTest compilerUnderTest, String classFilePath,
       String fullClassName)
       throws IOException, ProguardRuleParserException, ExecutionException, CompilationException {
@@ -1198,13 +1209,9 @@
 
     File resultDir = temp.newFolder(firstCompilerUnderTest.toString().toLowerCase() + "-output");
 
-    JctfTestSpecifications.Outcome expectedOutcome =
-        JctfTestSpecifications.getExpectedOutcome(
-            name, firstCompilerUnderTest, dexVm, compilationMode);
-    TestSpecification specification = new TestSpecification(name, DexTool.NONE, resultDir,
-        expectedOutcome == JctfTestSpecifications.Outcome.TIMEOUTS_WITH_ART
-            || expectedOutcome == JctfTestSpecifications.Outcome.FLAKY_WITH_ART,
-        expectedOutcome == JctfTestSpecifications.Outcome.FAILS_WITH_ART);
+    TestSpecification specification = JctfTestSpecifications.getExpectedOutcome(
+        name, firstCompilerUnderTest, dexVm, compilationMode,
+        jctfOutcomeToSpecification(name, DexTool.NONE, resultDir));
 
     if (specification.skipTest) {
       return;
@@ -1287,13 +1294,9 @@
               .collect(Collectors.toList());
       File r8ResultDir = temp.newFolder("r8-output");
       compilationMode = CompilationMode.DEBUG;
-      expectedOutcome =
-          JctfTestSpecifications.getExpectedOutcome(
-              name, CompilerUnderTest.R8_AFTER_D8, dexVm, compilationMode);
-      specification = new TestSpecification(name, DexTool.DX, r8ResultDir,
-          expectedOutcome == JctfTestSpecifications.Outcome.TIMEOUTS_WITH_ART
-              || expectedOutcome == JctfTestSpecifications.Outcome.FLAKY_WITH_ART,
-          expectedOutcome == JctfTestSpecifications.Outcome.FAILS_WITH_ART);
+      specification = JctfTestSpecifications.getExpectedOutcome(
+          name, CompilerUnderTest.R8_AFTER_D8, dexVm, compilationMode,
+          jctfOutcomeToSpecification(name, DexTool.DX, r8ResultDir));
       if (specification.skipTest) {
         return;
       }