Actually set experiment flags to fix invalidation

Previously we were just getting the default experiment flags (regardless of the arg),
which never matched any experiments passed in, so we always threw away the world.

I also added invalidation based on experiment flags for DDC.

This gives overall ~20% initial build time reduction for flutter gallery, and ~30% for angular_components_example.

Change-Id: I578d9611b89d3776e45ae8d309cfe8f70c7b7edd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107188
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
diff --git a/pkg/front_end/lib/src/api_unstable/bazel_worker.dart b/pkg/front_end/lib/src/api_unstable/bazel_worker.dart
index c9969c5..2cd528c 100644
--- a/pkg/front_end/lib/src/api_unstable/bazel_worker.dart
+++ b/pkg/front_end/lib/src/api_unstable/bazel_worker.dart
@@ -105,7 +105,8 @@
       ..target = target
       ..fileSystem = fileSystem
       ..omitPlatform = true
-      ..environmentDefines = const {};
+      ..environmentDefines = const {}
+      ..experimentalFlags = experimentalFlags;
 
     processedOpts = new ProcessedOptions(options: options);
     cachedSdkInput = WorkerInputComponent(
diff --git a/pkg/front_end/lib/src/api_unstable/ddc.dart b/pkg/front_end/lib/src/api_unstable/ddc.dart
index a344601..d761b49 100644
--- a/pkg/front_end/lib/src/api_unstable/ddc.dart
+++ b/pkg/front_end/lib/src/api_unstable/ddc.dart
@@ -155,7 +155,8 @@
       oldState.incrementalCompiler == null ||
       oldState.options.compileSdk != compileSdk ||
       cachedSdkInput == null ||
-      !digestsEqual(cachedSdkInput.digest, sdkDigest)) {
+      !digestsEqual(cachedSdkInput.digest, sdkDigest) ||
+      !equalMaps(oldState.options.experimentalFlags, experiments)) {
     // No previous state.
     options = new CompilerOptions()
       ..compileSdk = compileSdk