[flutter_runner] Disable asserts when flutter_profile=true

Change-Id: Ia48a33f3094b25a8f57d6b37ce6e6397dccc6b11
diff --git a/runtime/dart/dart_component.gni b/runtime/dart/dart_component.gni
index d0e934f..376fa85 100644
--- a/runtime/dart/dart_component.gni
+++ b/runtime/dart/dart_component.gni
@@ -892,7 +892,10 @@
             rebase_path(shared_snapshot_instructions_path),
         "--print-instructions-sizes-to=" + rebase_path(stats_json_path),
       ]
-      if (!product) {
+      # No asserts in debug or release product.
+      # No asserts in release with flutter_profile=true (non-product)
+      # Yes asserts in non-product debug.
+      if (!product && (!flutter_profile || is_debug)) {
         args += [ "--enable_asserts" ]
       }
       args += [ rebase_path(kernel_path) ]
diff --git a/runtime/flutter_runner/BUILD.gn b/runtime/flutter_runner/BUILD.gn
index 34ff1bb..7db8736 100644
--- a/runtime/flutter_runner/BUILD.gn
+++ b/runtime/flutter_runner/BUILD.gn
@@ -9,6 +9,7 @@
 import("//build/testing/environments.gni")
 import("//build/vulkan/config.gni")
 import("//garnet/bin/ui/scenic/config.gni")
+import("//topaz/runtime/dart/dart_component.gni")
 import("//topaz/runtime/flutter_runner/prebuilt_framework.gni")
 import("$flutter_root/shell/gpu/gpu.gni")
 
@@ -179,6 +180,9 @@
 flutter_runner("aot") {
   output_name = "flutter_aot_runner"
   product = false
+  if (flutter_profile) {
+    extra_defines = [ "FLUTTER_PROFILE" ]
+  }
   extra_deps = [
     "//third_party/dart/runtime:libdart_precompiled_runtime",
     "//third_party/dart/runtime/platform:libdart_platform_precompiled_runtime",
@@ -198,6 +202,9 @@
 flutter_runner("jit") {
   output_name = "flutter_jit_runner"
   product = false
+  if (flutter_profile) {
+    extra_defines = [ "FLUTTER_PROFILE" ]
+  }
   extra_deps = [
                  "//third_party/dart/runtime:libdart_jit",
                  "//third_party/dart/runtime/platform:libdart_platform_jit",
diff --git a/runtime/flutter_runner/component.cc b/runtime/flutter_runner/component.cc
index a90bd16..36e201c 100644
--- a/runtime/flutter_runner/component.cc
+++ b/runtime/flutter_runner/component.cc
@@ -266,7 +266,10 @@
 
   settings_.log_tag = debug_label_ + std::string{"(flutter)"};
 
-#if !defined(DART_PRODUCT)
+  // No asserts in debug or release product.
+  // No asserts in release with flutter_profile=true (non-product)
+  // Yes asserts in non-product debug.
+#if !defined(DART_PRODUCT) && (!defined(FLUTTER_PROFILE) || !defined(NDEBUG))
   // Debug mode
   settings_.disable_dart_asserts = false;
 #else
diff --git a/runtime/flutter_runner/kernel/BUILD.gn b/runtime/flutter_runner/kernel/BUILD.gn
index 8fc6ff1..8a00839 100644
--- a/runtime/flutter_runner/kernel/BUILD.gn
+++ b/runtime/flutter_runner/kernel/BUILD.gn
@@ -5,6 +5,7 @@
 import("//build/dart/dart_tool.gni")
 import("//build/host.gni")
 import("//third_party/dart/utils/compile_platform.gni")
+import("//topaz/runtime/dart/dart_component.gni")
 import("//topaz/runtime/dart/dart_kernel.gni")
 import("//topaz/runtime/flutter_runner/prebuilt_framework.gni")
 
@@ -110,7 +111,10 @@
       "--write_v8_snapshot_profile_to=" +
           rebase_path(snapshot_profile, root_build_dir),
     ]
-    if (!invoker.product) {
+    # No asserts in debug or release product.
+    # No asserts in release with flutter_profile=true (non-product)
+    # Yes asserts in non-product debug.
+    if (!invoker.product && (!flutter_profile || is_debug)) {
       args += [ "--enable_asserts" ]
     }
     args += [ rebase_path(platform_dill) ]