Option to disable startup layout

This makes it possible to test the impact of only disabling startup/non-startup boundary optimizations in isolation.

Change-Id: I5f59b3bc2fe449cbf0aa232bedd7079acf1a88ee
diff --git a/src/main/java/com/android/tools/r8/dex/MixedSectionLayoutStrategy.java b/src/main/java/com/android/tools/r8/dex/MixedSectionLayoutStrategy.java
index 7143d6b..2381e6f 100644
--- a/src/main/java/com/android/tools/r8/dex/MixedSectionLayoutStrategy.java
+++ b/src/main/java/com/android/tools/r8/dex/MixedSectionLayoutStrategy.java
@@ -23,7 +23,9 @@
   public static MixedSectionLayoutStrategy create(
       AppView<?> appView, MixedSectionOffsets mixedSectionOffsets, VirtualFile virtualFile) {
     StartupOrder startupOrderForWriting =
-        virtualFile.getId() == 0 && appView.hasClassHierarchy()
+        appView.options().getStartupOptions().isStartupLayoutOptimizationsEnabled()
+                && virtualFile.getId() == 0
+                && appView.hasClassHierarchy()
             ? appView
                 .appInfoWithClassHierarchy()
                 .getStartupOrder()
diff --git a/src/main/java/com/android/tools/r8/experimental/startup/StartupOptions.java b/src/main/java/com/android/tools/r8/experimental/startup/StartupOptions.java
index 0a97199..e737c9d 100644
--- a/src/main/java/com/android/tools/r8/experimental/startup/StartupOptions.java
+++ b/src/main/java/com/android/tools/r8/experimental/startup/StartupOptions.java
@@ -49,6 +49,13 @@
       parseSystemPropertyForDevelopmentOrDefault("com.android.tools.r8.startup.instrument", false);
 
   /**
+   * When enabled, the layout of the primary dex file will be generated using the startup list,
+   * using {@link com.android.tools.r8.dex.StartupMixedSectionLayoutStrategy}.
+   */
+  private boolean enableStartupLayoutOptimizations =
+      parseSystemPropertyForDevelopmentOrDefault("com.android.tools.r8.startup.layout", true);
+
+  /**
    * Specifies the synthetic context of the startup runtime library. When this is set, the startup
    * runtime library will only be injected into the app when the synthetic context is in the
    * program. This can be used to avoid that the startup runtime library is injected multiple times
@@ -124,6 +131,10 @@
     return this;
   }
 
+  public boolean isStartupLayoutOptimizationsEnabled() {
+    return enableStartupLayoutOptimizations;
+  }
+
   public boolean isStartupCompletenessCheckForTestingEnabled() {
     return enableStartupCompletenessCheckForTesting;
   }