Version 3.2.0-99.0.dev

Merge 84ff6dd74e8cda6a2b9224494d8e448602c5beed into dev
diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart
index 791ba8f..20c6f10 100644
--- a/pkg/compiler/lib/src/dart2js.dart
+++ b/pkg/compiler/lib/src/dart2js.dart
@@ -16,6 +16,7 @@
 import 'common/ram_usage.dart';
 import 'io/mapped_file.dart';
 import 'options.dart' show CompilerOptions, Dart2JSStage, FeatureOptions;
+import 'compiler.dart' as defaultCompiler show Compiler;
 import 'source_file_provider.dart';
 import 'util/command_line.dart';
 import 'util/util.dart' show stackTraceFilePrefix;
@@ -1226,7 +1227,7 @@
   // provided. It needs to be replaced by reading all the contents of the
   // file and expanding them into the resulting argument list.
   //
-  // TODO: Move this logic to a single place and share it among all tools.
+  // TODO: Remove when internal tooling targets bazelMain instead of this.
   if (arguments.length > 0 && arguments.last.startsWith('@')) {
     var extra = _readLines(arguments.last.substring(1));
     arguments = arguments.take(arguments.length - 1).followedBy(extra).toList();
@@ -1241,6 +1242,20 @@
   await internalMain(arguments);
 }
 
+Future<String?> bazelMain(List<String> arguments) async {
+  if (arguments.length > 0 && arguments.last.startsWith('@')) {
+    var extra = _readLines(arguments.last.substring(1));
+    arguments = arguments.take(arguments.length - 1).followedBy(extra).toList();
+  }
+  final compiler = (await internalMain(arguments)).compiler;
+  if (compiler is defaultCompiler.Compiler) {
+    final buffer = StringBuffer();
+    compiler.collectMetrics(buffer);
+    return buffer.toString();
+  }
+  return null;
+}
+
 /// Return all non-empty lines in a file found at [path].
 Iterable<String> _readLines(String path) {
   return File(path).readAsLinesSync().where((line) => line.isNotEmpty);
diff --git a/pkg/compiler/lib/src/source_file_provider.dart b/pkg/compiler/lib/src/source_file_provider.dart
index 03a5ff8..d17da56 100644
--- a/pkg/compiler/lib/src/source_file_provider.dart
+++ b/pkg/compiler/lib/src/source_file_provider.dart
@@ -633,12 +633,14 @@
   @override
   String get namespace => 'input';
   CountMetric inputBytes = CountMetric('inputBytes');
+  CountMetric sourceBytes = CountMetric('sourceBytes');
 
   void addDataRead(api.CompilerInput input) {
     if (input is SourceFileProvider) {
       inputBytes.add(input.bytesRead);
+      sourceBytes.add(input.sourceBytesFromDill);
       if (primary.isEmpty) {
-        primary = [inputBytes];
+        primary = [inputBytes, sourceBytes];
       }
     }
   }
diff --git a/runtime/vm/compiler/stub_code_compiler_arm64.cc b/runtime/vm/compiler/stub_code_compiler_arm64.cc
index 0249f04..2b871c7 100644
--- a/runtime/vm/compiler/stub_code_compiler_arm64.cc
+++ b/runtime/vm/compiler/stub_code_compiler_arm64.cc
@@ -510,7 +510,7 @@
   // We exit the safepoint inside DLRT_GetFfiCallbackMetadata in order to save
   // code size on this shared stub.
   {
-    __ mov(SP, CSP);
+    __ SetupDartSP();
 
     __ EnterFrame(0);
     __ PushRegisters(all_registers);
@@ -531,8 +531,6 @@
     __ EnterFrame(0);
     __ ReserveAlignedFrameSpace(0);
 
-    __ mov(CSP, SP);
-
 #if defined(DART_TARGET_OS_FUCHSIA)
     // TODO(https://dartbug.com/52579): Remove.
     if (FLAG_precompiled_mode) {
@@ -549,7 +547,9 @@
         FfiCallbackMetadata::kGetFfiCallbackMetadata, R4);
 #endif  // defined(DART_TARGET_OS_FUCHSIA)
 
+    __ mov(CSP, SP);
     __ blr(R4);
+    __ mov(SP, CSP);
     __ mov(THR, R0);
 
     __ LeaveFrame();
@@ -564,7 +564,7 @@
     __ PopRegisters(all_registers);
     __ LeaveFrame();
 
-    __ mov(CSP, SP);
+    __ RestoreCSP();
   }
 
   Label async_callback;
@@ -605,7 +605,7 @@
 
   // Exit the temporary isolate.
   {
-    __ mov(SP, CSP);
+    __ SetupDartSP();
     __ EnterFrame(0);
     __ ReserveAlignedFrameSpace(0);
 
@@ -631,7 +631,7 @@
     __ mov(THR, R0);
 
     __ LeaveFrame();
-    __ mov(CSP, SP);
+    __ RestoreCSP();
   }
 
   __ Bind(&done);
diff --git a/runtime/vm/ffi_callback_metadata.h b/runtime/vm/ffi_callback_metadata.h
index 9269321..1565a1d 100644
--- a/runtime/vm/ffi_callback_metadata.h
+++ b/runtime/vm/ffi_callback_metadata.h
@@ -242,7 +242,7 @@
   static constexpr intptr_t kNativeCallbackTrampolineStackDelta = 4;
 #elif defined(TARGET_ARCH_ARM64)
   static constexpr intptr_t kNativeCallbackTrampolineSize = 8;
-  static constexpr intptr_t kNativeCallbackSharedStubSize = 320;
+  static constexpr intptr_t kNativeCallbackSharedStubSize = 332;
   static constexpr intptr_t kNativeCallbackTrampolineStackDelta = 2;
 #elif defined(TARGET_ARCH_RISCV32)
   static constexpr intptr_t kNativeCallbackTrampolineSize = 8;
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 96e4fec..1e1e8a0 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -2852,7 +2852,7 @@
    * Draws an image from a CanvasImageSource to an area of this canvas.
    *
    * The image is a region of [source] that is [sourceWidth] wide and
-   * [destHeight] tall with top left corner at ([sourceX], [sourceY]).
+   * [sourceHeight] tall with top left corner at ([sourceX], [sourceY]).
    * The image will be drawn to this context with its top left corner at the
    * point ([destX], [destY]) and will be scaled to be [destWidth] wide and
    * [destHeight] tall.
diff --git a/tests/ffi/function_callbacks_test.dart b/tests/ffi/function_callbacks_test.dart
index a085e58..f71ccfe 100644
--- a/tests/ffi/function_callbacks_test.dart
+++ b/tests/ffi/function_callbacks_test.dart
@@ -13,6 +13,7 @@
 // VMOptions=--use-slow-path --write-protect-code --no-dual-map-code --stacktrace-every=100
 // VMOptions=--dwarf_stack_traces --no-retain_function_objects --no-retain_code_objects
 // VMOptions=--test_il_serialization
+// VMOptions=--profiler
 // SharedObjects=ffi_test_functions
 
 import 'dart:ffi';
diff --git a/tools/VERSION b/tools/VERSION
index c0b37d9..4e39168 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 3
 MINOR 2
 PATCH 0
-PRERELEASE 98
+PRERELEASE 99
 PRERELEASE_PATCH 0
diff --git a/tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate b/tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate
index ec1f2e4..2f3827d 100644
--- a/tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate
+++ b/tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate
@@ -187,7 +187,7 @@
    * Draws an image from a CanvasImageSource to an area of this canvas.
    *
    * The image is a region of [source] that is [sourceWidth] wide and
-   * [destHeight] tall with top left corner at ([sourceX], [sourceY]).
+   * [sourceHeight] tall with top left corner at ([sourceX], [sourceY]).
    * The image will be drawn to this context with its top left corner at the
    * point ([destX], [destY]) and will be scaled to be [destWidth] wide and
    * [destHeight] tall.