Use "product" mode VM snapshot when running dynamic "release" mode flutter with cached engine. (#22043)

Dynamic "release" mode requires "product" (not "release") mode VM, so we must point it to the correct cached snapshot.

Generation and caching of this snapshot happens the following corresponding change: https://chromium-review.googlesource.com/c/chromium/tools/build/+/1232134
diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart
index 06765c9..9d73831 100644
--- a/packages/flutter_tools/lib/src/artifacts.dart
+++ b/packages/flutter_tools/lib/src/artifacts.dart
@@ -32,7 +32,7 @@
   engineDartBinary,
 }
 
-String _artifactToFileName(Artifact artifact, [TargetPlatform platform]) {
+String _artifactToFileName(Artifact artifact, [TargetPlatform platform, BuildMode mode]) {
   switch (artifact) {
     case Artifact.dartIoEntriesTxt:
       return 'dart_io_entries.txt';
@@ -54,8 +54,20 @@
     case Artifact.flutterFramework:
       return 'Flutter.framework';
     case Artifact.vmSnapshotData:
+      // Flutter debug and dynamic profile modes for all target platforms use Dart
+      // RELEASE VM snapshot that comes from host debug build and has the metadata
+      // related to development tools.
+      if (mode == BuildMode.dynamicRelease) {
+        return 'product_vm_isolate_snapshot.bin';
+      }
+      // Flutter dynamic release mode for all target platforms uses Dart PRODUCT
+      // VM snapshot from host dynamic release build that strips out the metadata
+      // related to development tools.
       return 'vm_isolate_snapshot.bin';
     case Artifact.isolateSnapshotData:
+      if (mode == BuildMode.dynamicRelease) {
+        return 'product_isolate_snapshot.bin';
+      }
       return 'isolate_snapshot.bin';
     case Artifact.platformKernelDill:
       return 'platform_strong.dill';
@@ -119,7 +131,7 @@
       case TargetPlatform.windows_x64:
       case TargetPlatform.fuchsia:
       case TargetPlatform.tester:
-        return _getHostArtifactPath(artifact, platform);
+        return _getHostArtifactPath(artifact, platform, mode);
     }
     assert(false, 'Invalid platform $platform.');
     return null;
@@ -173,7 +185,7 @@
     return fs.path.join(engineArtifactsPath, 'common', 'flutter_patched_sdk');
   }
 
-  String _getHostArtifactPath(Artifact artifact, TargetPlatform platform) {
+  String _getHostArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) {
     switch (artifact) {
       case Artifact.genSnapshot:
         // For script snapshots any gen_snapshot binary will do. Returning gen_snapshot for
@@ -185,7 +197,7 @@
       case Artifact.frontendServerSnapshotForEngineDartSdk:
         final String engineArtifactsPath = cache.getArtifactDirectory('engine').path;
         final String platformDirName = getNameForTargetPlatform(platform);
-        return fs.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact, platform));
+        return fs.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact, platform, mode));
       case Artifact.engineDartSdkPath:
         return dartSdkPath;
       case Artifact.engineDartBinary: