Version 2.17.0-69.2.beta
* Cherry-pick e4942db83e2ad147de8710c0c96629f676fc91e3 to beta
diff --git a/runtime/vm/compiler/frontend/kernel_to_il.cc b/runtime/vm/compiler/frontend/kernel_to_il.cc
index 08ff0cc..5147fdc 100644
--- a/runtime/vm/compiler/frontend/kernel_to_il.cc
+++ b/runtime/vm/compiler/frontend/kernel_to_il.cc
@@ -1582,7 +1582,8 @@
// Initialize the result's data pointer field.
body += LoadLocal(typed_data_object);
body += LoadLocal(arg_pointer);
- body += LoadNativeField(Slot::Pointer_data_field());
+ body += LoadUntagged(compiler::target::Pointer::data_field_offset());
+ body += ConvertUntaggedToUnboxed(kUnboxedIntPtr);
body += StoreNativeField(Slot::TypedDataBase_data_field(),
StoreInstanceFieldInstr::Kind::kInitializing,
kNoStoreBarrier);
diff --git a/tests/ffi/regress_flutter97301_test.dart b/tests/ffi/regress_flutter97301_test.dart
new file mode 100644
index 0000000..c330d70
--- /dev/null
+++ b/tests/ffi/regress_flutter97301_test.dart
@@ -0,0 +1,21 @@
+// Copyright (c) 2022, 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.
+//
+// Verifies that there are no deoptimizing IntConverter instructions
+// used when converting Pointer to TypedData.
+// Regression test for https://github.com/flutter/flutter/issues/97301.
+
+import "dart:ffi";
+import "package:ffi/ffi.dart";
+
+@pragma("vm:never-inline")
+Pointer<Uint32> foo() => calloc(4);
+
+main() {
+ final Pointer<Uint32> offsetsPtr = foo();
+
+ for (var i = 0; i < 2; i++) {
+ print(offsetsPtr.asTypedList(1));
+ }
+}
diff --git a/tests/ffi_2/regress_flutter97301_test.dart b/tests/ffi_2/regress_flutter97301_test.dart
new file mode 100644
index 0000000..1417a7a
--- /dev/null
+++ b/tests/ffi_2/regress_flutter97301_test.dart
@@ -0,0 +1,23 @@
+// Copyright (c) 2022, 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.
+//
+// Verifies that there are no deoptimizing IntConverter instructions
+// used when converting Pointer to TypedData.
+// Regression test for https://github.com/flutter/flutter/issues/97301.
+
+// @dart = 2.9
+
+import "dart:ffi";
+import "package:ffi/ffi.dart";
+
+@pragma("vm:never-inline")
+Pointer<Uint32> foo() => calloc(4);
+
+main() {
+ final Pointer<Uint32> offsetsPtr = foo();
+
+ for (var i = 0; i < 2; i++) {
+ print(offsetsPtr.asTypedList(1));
+ }
+}
diff --git a/tools/VERSION b/tools/VERSION
index 0ed4213..e220f6a 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -28,4 +28,4 @@
MINOR 17
PATCH 0
PRERELEASE 69
-PRERELEASE_PATCH 1
\ No newline at end of file
+PRERELEASE_PATCH 2
\ No newline at end of file