[vm/concurrency] As preparation step to sharing JITed code, disable various optimizations

This is a preparation CL to enable actually sharing JIT'ed code between
isolates within the same isolate group.

We start with conservative settings, disabling various compiler
optimisations. We will lift those restrictions step-by-step.

Since this is guarded by FLAG_enable_isolate_groups it will not affect
any production code. Only individual tests which opt-in via the flag.

TEST=Existing tests opt'ing into --enable-isolate-groups.

Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: I05c4151116a8516f92c76b4d57f2c7fb725168ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173970
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
diff --git a/runtime/tests/vm/vm.status b/runtime/tests/vm/vm.status
index e3e32f3..3e25e86 100644
--- a/runtime/tests/vm/vm.status
+++ b/runtime/tests/vm/vm.status
@@ -139,6 +139,10 @@
 [ $nnbd == legacy ]
 dart/*: SkipByDesign # Migrated tests are not supposed to run on non-NNBD bots.
 
+[ $runtime == vm ]
+dart/isolates/*: Pass, Slow # https://dartbug.com/36097: Slower while isolate groups are being gradually enabled in JIT mode.
+dart_2/isolates/*: Pass, Slow # https://dartbug.com/36097: Slower while isolate groups are being gradually enabled in JIT mode.
+
 [ $system == android ]
 dart/isolates/dart_api_create_lightweight_isolate_test: SkipByDesign # On android this test does not work due to not being able to identify library uri.
 dart/sdk_hash_test: SkipByDesign # The test doesn't know location of cross-platform gen_snapshot
diff --git a/runtime/vm/flag_list.h b/runtime/vm/flag_list.h
index 022032b..dd6c196 100644
--- a/runtime/vm/flag_list.h
+++ b/runtime/vm/flag_list.h
@@ -119,7 +119,7 @@
   P(enable_ffi, bool, true, "Disable to make importing dart:ffi an error.")    \
   P(fields_may_be_reset, bool, false,                                          \
     "Don't optimize away static field initialization")                         \
-  C(force_clone_compiler_objects, false, false, bool, false,                   \
+  P(force_clone_compiler_objects, bool, false,                                 \
     "Force cloning of objects needed in compiler (ICData and Field).")         \
   P(getter_setter_ratio, int, 13,                                              \
     "Ratio of getter/setter usage used for double field unboxing heuristics")  \
diff --git a/runtime/vm/flags.cc b/runtime/vm/flags.cc
index 901856c..f3fc0ef 100644
--- a/runtime/vm/flags.cc
+++ b/runtime/vm/flags.cc
@@ -466,6 +466,30 @@
     PrintFlags();
   }
 
+  // TODO(dartbug.com/36097): Support for isolate groups in JIT mode is
+  // in-development. We will start with very conservative settings. As we make
+  // more of our compiler, runtime as well as generated code re-entrant we'll
+  // graudally remove those restrictions.
+
+#if !defined(DART_PRCOMPILED_RUNTIME)
+  if (!FLAG_precompiled_mode && FLAG_enable_isolate_groups) {
+    // Our compiler should not make rely on a global field being initialized at
+    // compile-time, since that compiled code might be re-used in another
+    // isolate that has not yet initialized the global field.
+    FLAG_fields_may_be_reset = true;
+
+    // We will start by only allowing compilation to unoptimized code.
+    FLAG_optimization_counter_threshold = -1;
+    FLAG_background_compilation = false;
+    FLAG_force_clone_compiler_objects = true;
+
+    // To eliminate potential flakiness, we will start by disabling field guards
+    // and CHA-based compilations.
+    FLAG_use_field_guards = false;
+    FLAG_use_cha_deopt = false;
+  }
+#endif  // !defined(DART_PRCOMPILED_RUNTIME)
+
   initialized_ = true;
   return NULL;
 }
diff --git a/tests/lib/lib_vm.status b/tests/lib/lib_vm.status
index b28a2fa..c693924 100644
--- a/tests/lib/lib_vm.status
+++ b/tests/lib/lib_vm.status
@@ -2,6 +2,9 @@
 # for details. All rights reserved. Use of this source code is governed by a
 # BSD-style license that can be found in the LICENSE file.
 
+[ $runtime == vm ]
+isolate/*: Pass, Slow # https://dartbug.com/36097: Slower while isolate groups are being gradually enabled in JIT mode.
+
 [ $runtime != vm ]
 isolate/native_wrapper_message_test: Skip # A VM specific test.
 
diff --git a/tests/lib_2/lib_2_vm.status b/tests/lib_2/lib_2_vm.status
index 68e3420..4820450 100644
--- a/tests/lib_2/lib_2_vm.status
+++ b/tests/lib_2/lib_2_vm.status
@@ -2,6 +2,9 @@
 # for details. All rights reserved. Use of this source code is governed by a
 # BSD-style license that can be found in the LICENSE file.
 
+[ $runtime == vm ]
+isolate/*: Pass, Slow # https://dartbug.com/36097: Slower while isolate groups are being gradually enabled in JIT mode.
+
 [ $runtime != vm ]
 isolate/native_wrapper_message_test: Skip # A VM specific test.