Version 2.9.0-21.10.beta

* Cherry-pick c632a629ffa47182dc74a024a12928bb3fc23ac0 to beta
* Cherry-pick 3844e74adbcc55a933180aef9bb4408c3b851cfa to beta
* Cherry-pick 7e5ac71ff390bd140ebe77b19e698bd808d8b927 to beta
* Cherry-pick a38e265f04d8976d226c3d966de2d9070a5c0941 to beta
* Cherry-pick 90bba3ae277dacf561a188d8f1d0d6f0756d597f to beta
* Cherry-pick f6a82443e47a17be471ef104b5de2549fdf797e9 to beta
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3ebc479..725055b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -58,6 +58,18 @@
 
 [#41653]: https://github.com/dart-lang/sdk/issues/41653
 
+#### `dart:mirrors`
+
+*   **Breaking Change** [#42714][]: web compilers (dart2js and DDC) now produce
+    a compile-time error if `dart:mirrors` is imported.
+
+    Most projects should not be affected. Since 2.0.0 this library was
+    unsupported and produced runtime errors on all its APIs. Since then several
+    tools already reject code that use `dart:mirrors` including webdev and
+    flutter tools, we expect few projects to run into this problem.
+
+[#42714]: https://github.com/dart-lang/sdk/issues/42714
+
 ### Tools
 
 #### dartfmt
diff --git a/pkg/compiler/lib/src/js_backend/namer.dart b/pkg/compiler/lib/src/js_backend/namer.dart
index e44beff..5ebc469 100644
--- a/pkg/compiler/lib/src/js_backend/namer.dart
+++ b/pkg/compiler/lib/src/js_backend/namer.dart
@@ -681,7 +681,8 @@
       String invocationName = operatorNameToIdentifier(function.name);
       // TODO(sra): If the generator is for a closure's 'call' method, we don't
       // need to incorporate the enclosing class.
-      String className = method.enclosingClass.name.replaceAll('&', '_');
+      String className =
+          method.enclosingClass.name.replaceAll(_nonIdentifierRE, '_');
       return '${invocationName}\$body\$${className}';
     });
   }
diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc
index e3f195b..a250af8 100644
--- a/runtime/bin/main_options.cc
+++ b/runtime/bin/main_options.cc
@@ -42,6 +42,7 @@
 bool Options::enable_vm_service_ = false;
 MallocGrowableArray<const char*> Options::enabled_experiments_ =
     MallocGrowableArray<const char*>(4);
+bool Options::disable_dart_dev_ = true;
 
 #define OPTION_FIELD(variable) Options::variable##_
 
@@ -403,6 +404,28 @@
   return true;
 }
 
+bool Options::ProcessEnableDartDevOption(const char* arg,
+                                         CommandLineOptions* vm_options) {
+  const char* value = OptionProcessor::ProcessOption(arg, "--enable-dart-dev");
+  if (value == nullptr) {
+    value = OptionProcessor::ProcessOption(arg, "--enable_dart_dev");
+  }
+  if (value == nullptr) {
+    // Ensure --disable-dart-dev doesn't result in an unknown flag error.
+    value = OptionProcessor::ProcessOption(arg, "--disable-dart-dev");
+    if (value != nullptr) {
+      return true;
+    }
+    value = OptionProcessor::ProcessOption(arg, "--disable_dart_dev");
+    if (value != nullptr) {
+      return true;
+    }
+    return false;
+  }
+  disable_dart_dev_ = false;
+  return true;
+}
+
 static void ResolveDartDevSnapshotPath(const char* script,
                                        char** snapshot_path) {
   if (!DartDevUtils::TryResolveDartDevSnapshotPath(snapshot_path)) {
@@ -591,7 +614,8 @@
         }
       }
     }
-    if (num_experiment_flags + 1 != script_or_cmd_index) {
+    // +2 since --enable-dart-dev needs to be passed to enable DartDev.
+    if (num_experiment_flags + 2 != script_or_cmd_index) {
       Syslog::PrintErr(
           "Warning: The following flags were passed as VM options and are "
           "being "
diff --git a/runtime/bin/main_options.h b/runtime/bin/main_options.h
index adfcb5c..54b44b6 100644
--- a/runtime/bin/main_options.h
+++ b/runtime/bin/main_options.h
@@ -46,8 +46,7 @@
   V(disable_exit, exit_disabled)                                               \
   V(preview_dart_2, nop_option)                                                \
   V(suppress_core_dump, suppress_core_dump)                                    \
-  V(enable_service_port_fallback, enable_service_port_fallback)                \
-  V(disable_dart_dev, disable_dart_dev)
+  V(enable_service_port_fallback, enable_service_port_fallback)
 
 // Boolean flags that have a short form.
 #define SHORT_BOOL_OPTIONS_LIST(V)                                             \
@@ -70,7 +69,8 @@
   V(ProcessEnableVmServiceOption)                                              \
   V(ProcessObserveOption)                                                      \
   V(ProcessAbiVersionOption)                                                   \
-  V(ProcessEnableExperimentOption)
+  V(ProcessEnableExperimentOption)                                             \
+  V(ProcessEnableDartDevOption)
 
 // This enum must match the strings in kSnapshotKindNames in main_options.cc.
 enum SnapshotKind {
@@ -129,6 +129,8 @@
   static constexpr int kAbiVersionUnset = -1;
   static int target_abi_version() { return target_abi_version_; }
 
+  static bool disable_dart_dev() { return disable_dart_dev_; }
+
 #if !defined(DART_PRECOMPILED_RUNTIME)
   static DFE* dfe() { return dfe_; }
   static void set_dfe(DFE* dfe) { dfe_ = dfe; }
@@ -179,6 +181,7 @@
 
   static int target_abi_version_;
   static MallocGrowableArray<const char*> enabled_experiments_;
+  static bool disable_dart_dev_;
 
 #define OPTION_FRIEND(flag, variable) friend class OptionProcessor_##flag;
   STRING_OPTIONS_LIST(OPTION_FRIEND)
diff --git a/runtime/tests/vm/dart/sdk_hash_test.dart b/runtime/tests/vm/dart/sdk_hash_test.dart
index 6b05e96..855e007 100644
--- a/runtime/tests/vm/dart/sdk_hash_test.dart
+++ b/runtime/tests/vm/dart/sdk_hash_test.dart
@@ -30,11 +30,8 @@
 
     {
       final result = await Process.run(dart, [
-        genKernel,
-        '--platform',
-        platformDill,
-        '-o',
-        dillPath,
+        '--snapshot-kind=kernel',
+        '--snapshot=$dillPath',
         sourcePath,
       ]);
       Expect.equals('', result.stderr);
@@ -57,8 +54,9 @@
       // tags (both UInt32).
       Expect.listEquals(tagComponentFile, bytes.sublist(0, 4));
       Expect.listEquals(tagBinaryFormatVersion, bytes.sublist(4, 8));
+      Expect.notEquals('0000000000', ascii.decode(bytes.sublist(8, 10)));
       // Flip the first byte in the hash:
-      bytes[8] ^= bytes[8];
+      bytes[8] = ~bytes[8];
       myFile.writeAsBytesSync(bytes);
     }
 
diff --git a/runtime/tests/vm/dart/splay_test.dart b/runtime/tests/vm/dart/splay_test.dart
index 30e4582..f0498a9 100644
--- a/runtime/tests/vm/dart/splay_test.dart
+++ b/runtime/tests/vm/dart/splay_test.dart
@@ -27,6 +27,7 @@
 // VMOptions=--verify_after_gc
 // VMOptions=--verify_before_gc --verify_after_gc
 // VMOptions=--verify_store_buffer
+// VMOptions=--stress_write_barrier_elimination
 
 import "dart:math";
 import 'package:benchmark_harness/benchmark_harness.dart';
diff --git a/runtime/tests/vm/dart_2/sdk_hash_test.dart b/runtime/tests/vm/dart_2/sdk_hash_test.dart
index 6b05e96..b6f166c 100644
--- a/runtime/tests/vm/dart_2/sdk_hash_test.dart
+++ b/runtime/tests/vm/dart_2/sdk_hash_test.dart
@@ -30,11 +30,8 @@
 
     {
       final result = await Process.run(dart, [
-        genKernel,
-        '--platform',
-        platformDill,
-        '-o',
-        dillPath,
+        '--snapshot-kind=kernel',
+        '--snapshot=$dillPath',
         sourcePath,
       ]);
       Expect.equals('', result.stderr);
@@ -57,8 +54,9 @@
       // tags (both UInt32).
       Expect.listEquals(tagComponentFile, bytes.sublist(0, 4));
       Expect.listEquals(tagBinaryFormatVersion, bytes.sublist(4, 8));
+      Expect.notEquals('0000000000', ascii.decode(bytes.sublist(8, 18)));
       // Flip the first byte in the hash:
-      bytes[8] ^= bytes[8];
+      bytes[8] = ~bytes[8];
       myFile.writeAsBytesSync(bytes);
     }
 
diff --git a/runtime/tests/vm/dart_2/splay_test.dart b/runtime/tests/vm/dart_2/splay_test.dart
index eae1cbb..1fec471 100644
--- a/runtime/tests/vm/dart_2/splay_test.dart
+++ b/runtime/tests/vm/dart_2/splay_test.dart
@@ -27,6 +27,7 @@
 // VMOptions=--verify_after_gc
 // VMOptions=--verify_before_gc --verify_after_gc
 // VMOptions=--verify_store_buffer
+// VMOptions=--stress_write_barrier_elimination
 
 import "dart:math";
 import 'package:benchmark_harness/benchmark_harness.dart';
diff --git a/runtime/vm/compiler/backend/il_arm.cc b/runtime/vm/compiler/backend/il_arm.cc
index 6c3f917..ea7c9e8 100644
--- a/runtime/vm/compiler/backend/il_arm.cc
+++ b/runtime/vm/compiler/backend/il_arm.cc
@@ -3194,32 +3194,24 @@
   ASSERT(locs()->in(kElementTypePos).reg() == kElemTypeReg);
   ASSERT(locs()->in(kLengthPos).reg() == kLengthReg);
 
+  compiler::Label slow_path, done;
   if (compiler->is_optimizing() && !FLAG_precompiled_mode &&
       num_elements()->BindsToConstant() &&
       compiler::target::IsSmi(num_elements()->BoundConstant())) {
     const intptr_t length =
         compiler::target::SmiValue(num_elements()->BoundConstant());
     if (Array::IsValidLength(length)) {
-      compiler::Label slow_path, done;
       InlineArrayAllocation(compiler, length, &slow_path, &done);
-      __ Bind(&slow_path);
-      __ PushObject(Object::null_object());  // Make room for the result.
-      __ Push(kLengthReg);                   // length.
-      __ Push(kElemTypeReg);
-      compiler->GenerateRuntimeCall(token_pos(), deopt_id(),
-                                    kAllocateArrayRuntimeEntry, 2, locs());
-      __ Drop(2);
-      __ Pop(kResultReg);
-      __ Bind(&done);
-      return;
     }
   }
 
+  __ Bind(&slow_path);
   auto object_store = compiler->isolate()->object_store();
   const auto& allocate_array_stub =
       Code::ZoneHandle(compiler->zone(), object_store->allocate_array_stub());
   compiler->GenerateStubCall(token_pos(), allocate_array_stub,
                              PcDescriptorsLayout::kOther, locs(), deopt_id());
+  __ Bind(&done);
   ASSERT(locs()->out(0).reg() == kResultReg);
 }
 
diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc
index 273bba0..54e2e07 100644
--- a/runtime/vm/compiler/backend/il_arm64.cc
+++ b/runtime/vm/compiler/backend/il_arm64.cc
@@ -2719,30 +2719,24 @@
   ASSERT(locs()->in(kElementTypePos).reg() == kElemTypeReg);
   ASSERT(locs()->in(kLengthPos).reg() == kLengthReg);
 
+  compiler::Label slow_path, done;
   if (compiler->is_optimizing() && !FLAG_precompiled_mode &&
       num_elements()->BindsToConstant() &&
       num_elements()->BoundConstant().IsSmi()) {
     const intptr_t length = Smi::Cast(num_elements()->BoundConstant()).Value();
     if (Array::IsValidLength(length)) {
-      compiler::Label slow_path, done;
       InlineArrayAllocation(compiler, length, &slow_path, &done);
-      __ Bind(&slow_path);
-      __ PushObject(Object::null_object());   // Make room for the result.
-      __ PushPair(kElemTypeReg, kLengthReg);  // length.
-      compiler->GenerateRuntimeCall(token_pos(), deopt_id(),
-                                    kAllocateArrayRuntimeEntry, 2, locs());
-      __ Drop(2);
-      __ Pop(kResultReg);
-      __ Bind(&done);
-      return;
     }
   }
+
+  __ Bind(&slow_path);
   auto object_store = compiler->isolate()->object_store();
   const auto& allocate_array_stub =
       Code::ZoneHandle(compiler->zone(), object_store->allocate_array_stub());
   compiler->GenerateStubCall(token_pos(), allocate_array_stub,
                              PcDescriptorsLayout::kOther, locs(), deopt_id());
   ASSERT(locs()->out(0).reg() == kResultReg);
+  __ Bind(&done);
 }
 
 LocationSummary* LoadFieldInstr::MakeLocationSummary(Zone* zone,
diff --git a/runtime/vm/compiler/backend/il_ia32.cc b/runtime/vm/compiler/backend/il_ia32.cc
index 219ec45..6173afa 100644
--- a/runtime/vm/compiler/backend/il_ia32.cc
+++ b/runtime/vm/compiler/backend/il_ia32.cc
@@ -2510,23 +2510,15 @@
       num_elements()->BoundConstant().IsSmi()) {
     const intptr_t length = Smi::Cast(num_elements()->BoundConstant()).Value();
     if (Array::IsValidLength(length)) {
-      compiler::Label slow_path, done;
       InlineArrayAllocation(compiler, length, &slow_path, &done);
-      __ Bind(&slow_path);
-      __ PushObject(Object::null_object());  // Make room for the result.
-      __ pushl(kLengthReg);
-      __ pushl(kElemTypeReg);
-      compiler->GenerateRuntimeCall(token_pos(), deopt_id(),
-                                    kAllocateArrayRuntimeEntry, 2, locs());
-      __ Drop(2);
-      __ popl(kResultReg);
-      __ Bind(&done);
-      return;
     }
   }
 
   __ Bind(&slow_path);
-  compiler->GenerateStubCall(token_pos(), StubCode::AllocateArray(),
+  auto object_store = compiler->isolate()->object_store();
+  const auto& allocate_array_stub =
+      Code::ZoneHandle(compiler->zone(), object_store->allocate_array_stub());
+  compiler->GenerateStubCall(token_pos(), allocate_array_stub,
                              PcDescriptorsLayout::kOther, locs(), deopt_id());
   __ Bind(&done);
   ASSERT(locs()->out(0).reg() == kResultReg);
diff --git a/runtime/vm/compiler/backend/il_x64.cc b/runtime/vm/compiler/backend/il_x64.cc
index d01f34f..a6905d3 100644
--- a/runtime/vm/compiler/backend/il_x64.cc
+++ b/runtime/vm/compiler/backend/il_x64.cc
@@ -2752,18 +2752,7 @@
       num_elements()->BoundConstant().IsSmi()) {
     const intptr_t length = Smi::Cast(num_elements()->BoundConstant()).Value();
     if (Array::IsValidLength(length)) {
-      compiler::Label slow_path, done;
       InlineArrayAllocation(compiler, length, &slow_path, &done);
-      __ Bind(&slow_path);
-      __ PushObject(Object::null_object());  // Make room for the result.
-      __ pushq(kLengthReg);
-      __ pushq(kElemTypeReg);
-      compiler->GenerateRuntimeCall(token_pos(), deopt_id(),
-                                    kAllocateArrayRuntimeEntry, 2, locs());
-      __ Drop(2);
-      __ popq(kResultReg);
-      __ Bind(&done);
-      return;
     }
   }
 
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index db3458a..66640b8 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -12135,6 +12135,7 @@
   StorePointer(&raw_ptr()->resolved_names_, Array::null());
   StorePointer(&raw_ptr()->exported_names_, Array::null());
   StorePointer(&raw_ptr()->loaded_scripts_, Array::null());
+  StorePointer(&raw_ptr()->dependencies_, Array::null());
 }
 
 void Library::AddImport(const Namespace& ns) const {
diff --git a/runtime/vm/runtime_entry.cc b/runtime/vm/runtime_entry.cc
index 98813d1..4bfefb8 100644
--- a/runtime/vm/runtime_entry.cc
+++ b/runtime/vm/runtime_entry.cc
@@ -51,6 +51,10 @@
             reoptimization_counter_threshold,
             4000,
             "Counter threshold before a function gets reoptimized.");
+DEFINE_FLAG(bool,
+            stress_write_barrier_elimination,
+            false,
+            "Stress test write barrier elimination.");
 DEFINE_FLAG(bool, trace_deoptimization, false, "Trace deoptimization");
 DEFINE_FLAG(bool,
             trace_deoptimization_verbose,
@@ -253,6 +257,10 @@
   Exceptions::ThrowByType(Exceptions::kIntegerDivisionByZeroException, args);
 }
 
+static Heap::Space SpaceForRuntimeAllocation() {
+  return FLAG_stress_write_barrier_elimination ? Heap::kOld : Heap::kNew;
+}
+
 // Allocation of a fixed length array of given element type.
 // This runtime entry is never called for allocating a List of a generic type,
 // because a prior run time call instantiates the element type if necessary.
@@ -281,8 +289,9 @@
     Exceptions::Throw(thread, exception);
   }
 
-  const Array& array =
-      Array::Handle(zone, Array::New(static_cast<intptr_t>(len), Heap::kNew));
+  const Array& array = Array::Handle(
+      zone,
+      Array::New(static_cast<intptr_t>(len), SpaceForRuntimeAllocation()));
   arguments.SetReturn(array);
   TypeArguments& element_type =
       TypeArguments::CheckedHandle(zone, arguments.ArgAt(1));
@@ -310,7 +319,7 @@
 DEFINE_RUNTIME_ENTRY(AllocateObject, 2) {
   const Class& cls = Class::CheckedHandle(zone, arguments.ArgAt(0));
   const Instance& instance =
-      Instance::Handle(zone, Instance::New(cls, Heap::kNew));
+      Instance::Handle(zone, Instance::New(cls, SpaceForRuntimeAllocation()));
 
   arguments.SetReturn(instance);
   if (cls.NumTypeArguments() == 0) {
@@ -479,8 +488,8 @@
 // Return value: newly allocated context.
 DEFINE_RUNTIME_ENTRY(AllocateContext, 1) {
   const Smi& num_variables = Smi::CheckedHandle(zone, arguments.ArgAt(0));
-  const Context& context =
-      Context::Handle(zone, Context::New(num_variables.Value()));
+  const Context& context = Context::Handle(
+      zone, Context::New(num_variables.Value(), SpaceForRuntimeAllocation()));
   arguments.SetReturn(context);
 }
 
@@ -490,8 +499,8 @@
 // Return value: newly allocated context.
 DEFINE_RUNTIME_ENTRY(CloneContext, 1) {
   const Context& ctx = Context::CheckedHandle(zone, arguments.ArgAt(0));
-  Context& cloned_ctx =
-      Context::Handle(zone, Context::New(ctx.num_variables()));
+  Context& cloned_ctx = Context::Handle(
+      zone, Context::New(ctx.num_variables(), SpaceForRuntimeAllocation()));
   cloned_ctx.set_parent(Context::Handle(zone, ctx.parent()));
   Object& inst = Object::Handle(zone);
   for (int i = 0; i < ctx.num_variables(); i++) {
diff --git a/sdk/lib/_internal/js_runtime/lib/mirrors_patch_cfe.dart b/sdk/lib/_internal/js_runtime/lib/mirrors_patch_cfe.dart
deleted file mode 100644
index c429ecb..0000000
--- a/sdk/lib/_internal/js_runtime/lib/mirrors_patch_cfe.dart
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
-// 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.
-
-// Patch library for dart:mirrors.
-
-import 'dart:_js_helper' show patch;
-import 'dart:mirrors';
-
-const String _message = 'dart:mirrors is no longer supported for web apps';
-
-@patch
-MirrorSystem currentMirrorSystem() => throw new UnsupportedError(_message);
-
-@patch
-InstanceMirror reflect(dynamic reflectee) =>
-    throw new UnsupportedError(_message);
-
-@patch
-ClassMirror reflectClass(Type key) => throw new UnsupportedError(_message);
-
-@patch
-TypeMirror reflectType(Type key, [List<Type>? typeArguments]) =>
-    throw new UnsupportedError(_message);
-
-@patch
-abstract class MirrorSystem {
-  @patch
-  LibraryMirror findLibrary(Symbol libraryName) =>
-      throw new UnsupportedError(_message);
-
-  @patch
-  static String getName(Symbol symbol) => throw new UnsupportedError(_message);
-
-  @patch
-  static Symbol getSymbol(String name, [LibraryMirror? library]) =>
-      throw new UnsupportedError(_message);
-}
diff --git a/sdk/lib/libraries.json b/sdk/lib/libraries.json
index 0289238..15b4cd3 100644
--- a/sdk/lib/libraries.json
+++ b/sdk/lib/libraries.json
@@ -221,11 +221,6 @@
         "uri": "math/math.dart",
         "patches": "_internal/js_runtime/lib/math_patch.dart"
       },
-      "mirrors": {
-        "uri": "mirrors/mirrors.dart",
-        "patches": "_internal/js_runtime/lib/mirrors_patch_cfe.dart",
-        "supported": false
-      },
       "typed_data": {
         "uri": "typed_data/typed_data.dart",
         "patches": "_internal/js_runtime/lib/typed_data_patch.dart"
@@ -334,11 +329,6 @@
         "uri": "math/math.dart",
         "patches": "_internal/js_runtime/lib/math_patch.dart"
       },
-      "mirrors": {
-        "uri": "mirrors/mirrors.dart",
-        "patches": "_internal/js_runtime/lib/mirrors_patch_cfe.dart",
-        "supported": false
-      },
       "typed_data": {
         "uri": "typed_data/typed_data.dart",
         "patches": "_internal/js_runtime/lib/typed_data_patch.dart"
@@ -448,11 +438,6 @@
         "patches": "_internal/js_dev_runtime/patch/isolate_patch.dart",
         "supported": false
       },
-      "mirrors": {
-        "uri": "mirrors/mirrors.dart",
-        "patches": "_internal/js_runtime/lib/mirrors_patch_cfe.dart",
-        "supported": false
-      },
       "math": {
         "uri": "math/math.dart",
         "patches": "_internal/js_dev_runtime/patch/math_patch.dart"
diff --git a/sdk/lib/libraries.yaml b/sdk/lib/libraries.yaml
index a80284d..50e350e 100644
--- a/sdk/lib/libraries.yaml
+++ b/sdk/lib/libraries.yaml
@@ -218,11 +218,6 @@
       uri: "math/math.dart"
       patches: "_internal/js_runtime/lib/math_patch.dart"
 
-    mirrors:
-      uri: "mirrors/mirrors.dart"
-      patches: "_internal/js_runtime/lib/mirrors_patch_cfe.dart"
-      supported: false
-
     typed_data:
       uri: "typed_data/typed_data.dart"
       patches: "_internal/js_runtime/lib/typed_data_patch.dart"
@@ -329,11 +324,6 @@
       uri: "math/math.dart"
       patches: "_internal/js_runtime/lib/math_patch.dart"
 
-    mirrors:
-      uri: "mirrors/mirrors.dart"
-      patches: "_internal/js_runtime/lib/mirrors_patch_cfe.dart"
-      supported: false
-
     typed_data:
       uri: "typed_data/typed_data.dart"
       patches: "_internal/js_runtime/lib/typed_data_patch.dart"
@@ -441,11 +431,6 @@
         patches: "_internal/js_dev_runtime/patch/isolate_patch.dart"
         supported: false
 
-      mirrors:
-        uri: "mirrors/mirrors.dart"
-        patches: "_internal/js_runtime/lib/mirrors_patch_cfe.dart"
-        supported: false
-
       math:
         uri: "math/math.dart"
         patches: "_internal/js_dev_runtime/patch/math_patch.dart"
diff --git a/tests/dart2js/42531_test.dart b/tests/dart2js/42531_test.dart
new file mode 100644
index 0000000..7bc9b58
--- /dev/null
+++ b/tests/dart2js/42531_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2020, the Dart project authors.  Please see the AUTHORS file
+// 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.
+
+import 'package:expect/expect.dart';
+
+// Regression test for badly named generator body.
+
+Future<void> goo(Future Function() f) async {
+  Expect.equals(102, (await f()).keys.single);
+  Expect.equals(104, (await f()).keys.single);
+}
+
+Future<T> identity<T>(T x) async => x;
+
+extension Gloop<T> on Map<T, List<T>> {
+  // An async method using a 'complex' generator type `Map<T, List<T>>`.  This
+  // requires a separated entry and body, which requires a name, and the name
+  // must be legal JavaScript.
+  Future<Map<T, List<T>>> foo(int x) async {
+    var result = await identity({(x += this.length) as T: <T>[]});
+    return result;
+  }
+
+  Future<int> bar(int x) async {
+    // An async closure using a 'complex' generator type `Map<T, Set<T>>`.  This
+    // requires a separated entry and body, which requires a name, and the name
+    // must be legal JavaScript.
+    await goo(() async => {(x += this.length) as T: <T>{}});
+    return x;
+  }
+}
+
+main() async {
+  // Test method.
+  Map<int, List<int>> o1 = {1: [], 2: []};
+  var o2 = await o1.foo(100);
+  var o3 = await o2.foo(100);
+  Expect.equals('{102: []}', '$o2');
+  Expect.equals('{101: []}', '$o3');
+
+  // Test closure.
+  Map<int, List<int>> o = {1: [], 2: []};
+  int x = await o.bar(100);
+  Expect.equals(104, x);
+}
diff --git a/tests/dart2js_2/42531_test.dart b/tests/dart2js_2/42531_test.dart
new file mode 100644
index 0000000..7bc9b58
--- /dev/null
+++ b/tests/dart2js_2/42531_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2020, the Dart project authors.  Please see the AUTHORS file
+// 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.
+
+import 'package:expect/expect.dart';
+
+// Regression test for badly named generator body.
+
+Future<void> goo(Future Function() f) async {
+  Expect.equals(102, (await f()).keys.single);
+  Expect.equals(104, (await f()).keys.single);
+}
+
+Future<T> identity<T>(T x) async => x;
+
+extension Gloop<T> on Map<T, List<T>> {
+  // An async method using a 'complex' generator type `Map<T, List<T>>`.  This
+  // requires a separated entry and body, which requires a name, and the name
+  // must be legal JavaScript.
+  Future<Map<T, List<T>>> foo(int x) async {
+    var result = await identity({(x += this.length) as T: <T>[]});
+    return result;
+  }
+
+  Future<int> bar(int x) async {
+    // An async closure using a 'complex' generator type `Map<T, Set<T>>`.  This
+    // requires a separated entry and body, which requires a name, and the name
+    // must be legal JavaScript.
+    await goo(() async => {(x += this.length) as T: <T>{}});
+    return x;
+  }
+}
+
+main() async {
+  // Test method.
+  Map<int, List<int>> o1 = {1: [], 2: []};
+  var o2 = await o1.foo(100);
+  var o3 = await o2.foo(100);
+  Expect.equals('{102: []}', '$o2');
+  Expect.equals('{101: []}', '$o3');
+
+  // Test closure.
+  Map<int, List<int>> o = {1: [], 2: []};
+  int x = await o.bar(100);
+  Expect.equals(104, x);
+}
diff --git a/tests/lib/web/mirrors_support_test.dart b/tests/lib/web/mirrors_support_test.dart
index 03dc2d5..78f3648 100644
--- a/tests/lib/web/mirrors_support_test.dart
+++ b/tests/lib/web/mirrors_support_test.dart
@@ -2,16 +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.
 
-// 'dart:mirrors' provides no functionality in dart-web, but can be imported and
-// all APIs throw.
-import 'dart:mirrors';
-import 'package:expect/expect.dart';
+// 'dart:mirrors' can no longer be imported, doing so produces a static error.
+import 'dart:mirrors';   //# 01: compile-time error
 
 main() {
-  Expect.throws<UnsupportedError>(() => currentMirrorSystem());
-  Expect.throws<UnsupportedError>(() => reflect(main));
-  Expect.throws<UnsupportedError>(() => reflectClass(Object));
-  Expect.throws<UnsupportedError>(() => reflectType(Object));
-  Expect.throws<UnsupportedError>(() => MirrorSystem.getName(#core));
-  Expect.throws<UnsupportedError>(() => MirrorSystem.getSymbol("core"));
+  reflect(main);         //# 01: continued
 }
diff --git a/tests/lib_2/web/mirrors_support_test.dart b/tests/lib_2/web/mirrors_support_test.dart
index 03dc2d5..78f3648 100644
--- a/tests/lib_2/web/mirrors_support_test.dart
+++ b/tests/lib_2/web/mirrors_support_test.dart
@@ -2,16 +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.
 
-// 'dart:mirrors' provides no functionality in dart-web, but can be imported and
-// all APIs throw.
-import 'dart:mirrors';
-import 'package:expect/expect.dart';
+// 'dart:mirrors' can no longer be imported, doing so produces a static error.
+import 'dart:mirrors';   //# 01: compile-time error
 
 main() {
-  Expect.throws<UnsupportedError>(() => currentMirrorSystem());
-  Expect.throws<UnsupportedError>(() => reflect(main));
-  Expect.throws<UnsupportedError>(() => reflectClass(Object));
-  Expect.throws<UnsupportedError>(() => reflectType(Object));
-  Expect.throws<UnsupportedError>(() => MirrorSystem.getName(#core));
-  Expect.throws<UnsupportedError>(() => MirrorSystem.getSymbol("core"));
+  reflect(main);         //# 01: continued
 }
diff --git a/tools/VERSION b/tools/VERSION
index c041bdd..40e02d0 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -34,6 +34,6 @@
 MINOR 9
 PATCH 0
 PRERELEASE 21
-PRERELEASE_PATCH 4
+PRERELEASE_PATCH 10
 ABI_VERSION 38
 OLDEST_SUPPORTED_ABI_VERSION 38
diff --git a/tools/utils.py b/tools/utils.py
index 42a7db4..23c8812 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -503,7 +503,7 @@
 
 
 def GetShortGitHash(repo_path=DART_DIR):
-    p = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'],
+    p = subprocess.Popen(['git', 'rev-parse', '--short=10', 'HEAD'],
                          stdout=subprocess.PIPE,
                          stderr=subprocess.STDOUT,
                          shell=IsWindows(),
diff --git a/utils/application_snapshot.gni b/utils/application_snapshot.gni
index 8f3f882..7d981bd 100644
--- a/utils/application_snapshot.gni
+++ b/utils/application_snapshot.gni
@@ -102,6 +102,8 @@
     vm_args = [
       "--depfile=$abs_depfile",
       "--depfile_output_filename=$rebased_output",
+
+      # Ensure gen_kernel.dart will use this SDK hash when consuming/producing kernel.
       "-Dsdk_hash=$sdk_hash",
     ]
 
@@ -114,6 +116,13 @@
       "--no-embed-sources",
       "--no-link-platform",
       "--output=" + rebase_path(output),
+
+      # Ensure the compiled appliation (e.g. kernel-service, frontend-server,
+      # ...) will use this SDK hash when consuming/producing kernel.
+      #
+      # (Instead of ensuring every user of the "application_snapshot" /
+      # "kernel_snapshot" passes this if needed, we always pass it)
+      "-Dsdk_hash=$sdk_hash",
     ]
     if (dart_platform_bytecode) {
       args += [
diff --git a/utils/kernel-service/BUILD.gn b/utils/kernel-service/BUILD.gn
index a01bb1b..150d229 100644
--- a/utils/kernel-service/BUILD.gn
+++ b/utils/kernel-service/BUILD.gn
@@ -89,6 +89,9 @@
     vm_args = [
       "--depfile=$abs_depfile",
       "--depfile_output_filename=$rebased_output",
+
+      # Ensure gen_kernel.dart will use this SDK hash when consuming/producing
+      # kernel.
       "-Dsdk_hash=$sdk_hash",
     ]
 
@@ -97,6 +100,10 @@
 
     args =
         invoker.extra_args + [
+          # Ensure the compiled kernel-service will use this SDK hash when
+          # consuming/producing kernel.
+          "-Dsdk_hash=$sdk_hash",
+
           "--packages=" + scheme + ":///.packages",
           "--platform=" + rebase_path("$root_out_dir/vm_platform_strong.dill"),
           "--filesystem-root=" + rebase_path("../../"),