[vm/ffi] Add Fuchsia ABI unit tests

Adds the Fuchsia ABI to the ABI unit tests.

Adds an ABI test for the FFI callback on who's return the stack is/gets
corrupted from bug:
https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=105336

TEST=tools/test.py ffi_unit

Change-Id: I3c9bb9941e4883384dfba787bb6dacb4c8cdc141
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255122
Reviewed-by: Jonas Termansen <sortie@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
diff --git a/pkg/test_runner/lib/src/test_suite.dart b/pkg/test_runner/lib/src/test_suite.dart
index a5e7239..3688b5c 100644
--- a/pkg/test_runner/lib/src/test_suite.dart
+++ b/pkg/test_runner/lib/src/test_suite.dart
@@ -389,6 +389,7 @@
 
   static const targetAbis = [
     "arm64_android",
+    "arm64_fuchsia",
     "arm64_ios",
     "arm64_linux",
     "arm64_macos",
@@ -398,6 +399,7 @@
     "ia32_android",
     "ia32_linux",
     "ia32_win",
+    "x64_fuchsia",
     "x64_ios",
     "x64_linux",
     "x64_macos",
diff --git a/runtime/bin/ffi_unit_test/BUILD.gn b/runtime/bin/ffi_unit_test/BUILD.gn
index bad85d0..c06d9e5 100644
--- a/runtime/bin/ffi_unit_test/BUILD.gn
+++ b/runtime/bin/ffi_unit_test/BUILD.gn
@@ -61,6 +61,10 @@
   defines = [ "DART_TARGET_OS_ANDROID" ]
 }
 
+config("define_target_os_fuchsia") {
+  defines = [ "DART_TARGET_OS_FUCHSIA" ]
+}
+
 config("define_target_os_ios") {
   defines = [ "DART_TARGET_OS_MACOS_IOS" ]
 }
@@ -105,6 +109,13 @@
   ]
 }
 
+build_run_ffi_unit_tests("run_ffi_unit_tests_arm64_fuchsia") {
+  extra_configs = [
+    ":define_target_arch_arm64",
+    ":define_target_os_fuchsia",
+  ]
+}
+
 build_run_ffi_unit_tests("run_ffi_unit_tests_arm64_ios") {
   extra_configs = [
     ":define_target_arch_arm64",
@@ -147,6 +158,13 @@
   ]
 }
 
+build_run_ffi_unit_tests("run_ffi_unit_tests_x64_fuchsia") {
+  extra_configs = [
+    ":define_target_arch_x64",
+    ":define_target_os_fuchsia",
+  ]
+}
+
 build_run_ffi_unit_tests("run_ffi_unit_tests_x64_ios") {
   extra_configs = [
     ":define_target_arch_x64",
@@ -192,6 +210,7 @@
 group("run_ffi_unit_tests") {
   deps = [
     ":run_ffi_unit_tests_arm64_android",
+    ":run_ffi_unit_tests_arm64_fuchsia",
     ":run_ffi_unit_tests_arm64_ios",  # No other test coverage.
     ":run_ffi_unit_tests_arm64_linux",
     ":run_ffi_unit_tests_arm64_macos",
@@ -203,6 +222,7 @@
     ":run_ffi_unit_tests_ia32_win",
     ":run_ffi_unit_tests_riscv32_linux",
     ":run_ffi_unit_tests_riscv64_linux",
+    ":run_ffi_unit_tests_x64_fuchsia",
     ":run_ffi_unit_tests_x64_ios",  # Simulator, no other test coverage.
     ":run_ffi_unit_tests_x64_linux",
     ":run_ffi_unit_tests_x64_macos",
diff --git a/runtime/vm/compiler/ffi/native_calling_convention_test.cc b/runtime/vm/compiler/ffi/native_calling_convention_test.cc
index d040fb1..707d9e8 100644
--- a/runtime/vm/compiler/ffi/native_calling_convention_test.cc
+++ b/runtime/vm/compiler/ffi/native_calling_convention_test.cc
@@ -697,6 +697,38 @@
   RunSignatureTest(Z, "struct12bytesFloatx6", arguments, int64_type);
 }
 
+// typedef void (*YogaDartMeasureFunc)(intptr_t node_id,
+//                                     double available_width,
+//                                     int32_t width_mode,
+//                                     double available_height,
+//                                     int32_t height_mode,
+//                                     double *measured_width,
+//                                     double *measured_height);
+// https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=105336
+//
+// See the *.expect in ./unit_tests for this behavior.
+UNIT_TEST_CASE_WITH_ZONE(NativeCallingConvention_regress_fuchsia105336) {
+#if defined(TARGET_ARCH_IS_32_BIT)
+  const auto& intptr_type = *new (Z) NativePrimitiveType(kInt32);
+#elif defined(TARGET_ARCH_IS_64_BIT)
+  const auto& intptr_type = *new (Z) NativePrimitiveType(kInt64);
+#endif
+  const auto& double_type = *new (Z) NativePrimitiveType(kDouble);
+  const auto& int32_type = *new (Z) NativePrimitiveType(kInt32);
+  const auto& void_type = *new (Z) NativePrimitiveType(kVoid);
+
+  auto& arguments = *new (Z) NativeTypes(Z, 6);
+  arguments.Add(&intptr_type);
+  arguments.Add(&double_type);
+  arguments.Add(&int32_type);
+  arguments.Add(&double_type);
+  arguments.Add(&int32_type);
+  arguments.Add(&intptr_type);  // pointer
+  arguments.Add(&intptr_type);  // pointer
+
+  RunSignatureTest(Z, "regress_fuchsia105336", arguments, void_type);
+}
+
 }  // namespace ffi
 }  // namespace compiler
 }  // namespace dart
diff --git a/runtime/vm/compiler/ffi/unit_tests/doublex20/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/doublex20/arm64_fuchsia.expect
new file mode 100644
index 0000000..3b73df0
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/doublex20/arm64_fuchsia.expect
@@ -0,0 +1,22 @@
+v0 double
+v1 double
+v2 double
+v3 double
+v4 double
+v5 double
+v6 double
+v7 double
+S+0 double
+S+8 double
+S+16 double
+S+24 double
+S+32 double
+S+40 double
+S+48 double
+S+56 double
+S+64 double
+S+72 double
+S+80 double
+S+88 double
+=>
+v0 double
diff --git a/runtime/vm/compiler/ffi/unit_tests/doublex20/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/doublex20/x64_fuchsia.expect
new file mode 100644
index 0000000..e2792c6
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/doublex20/x64_fuchsia.expect
@@ -0,0 +1,22 @@
+xmm0 double
+xmm1 double
+xmm2 double
+xmm3 double
+xmm4 double
+xmm5 double
+xmm6 double
+xmm7 double
+S+0 double
+S+8 double
+S+16 double
+S+24 double
+S+32 double
+S+40 double
+S+48 double
+S+56 double
+S+64 double
+S+72 double
+S+80 double
+S+88 double
+=>
+xmm0 double
diff --git a/runtime/vm/compiler/ffi/unit_tests/floatx20/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/floatx20/arm64_fuchsia.expect
new file mode 100644
index 0000000..7964f7b
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/floatx20/arm64_fuchsia.expect
@@ -0,0 +1,22 @@
+v0 float
+v1 float
+v2 float
+v3 float
+v4 float
+v5 float
+v6 float
+v7 float
+S+0 float
+S+8 float
+S+16 float
+S+24 float
+S+32 float
+S+40 float
+S+48 float
+S+56 float
+S+64 float
+S+72 float
+S+80 float
+S+88 float
+=>
+v0 float
diff --git a/runtime/vm/compiler/ffi/unit_tests/floatx20/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/floatx20/x64_fuchsia.expect
new file mode 100644
index 0000000..463908b
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/floatx20/x64_fuchsia.expect
@@ -0,0 +1,22 @@
+xmm0 float
+xmm1 float
+xmm2 float
+xmm3 float
+xmm4 float
+xmm5 float
+xmm6 float
+xmm7 float
+S+0 float
+S+8 float
+S+16 float
+S+24 float
+S+32 float
+S+40 float
+S+48 float
+S+56 float
+S+64 float
+S+72 float
+S+80 float
+S+88 float
+=>
+xmm0 float
diff --git a/runtime/vm/compiler/ffi/unit_tests/int8x10/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/int8x10/arm64_fuchsia.expect
new file mode 100644
index 0000000..04f72e5f
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/int8x10/arm64_fuchsia.expect
@@ -0,0 +1,12 @@
+r0 int8
+r1 int8
+r2 int8
+r3 int8
+r4 int8
+r5 int8
+r6 int8
+r7 int8
+S+0 int8
+S+8 int8
+=>
+r0 int8
diff --git a/runtime/vm/compiler/ffi/unit_tests/int8x10/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/int8x10/x64_fuchsia.expect
new file mode 100644
index 0000000..0bcad4b
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/int8x10/x64_fuchsia.expect
@@ -0,0 +1,12 @@
+rdi int32[int8]
+rsi int32[int8]
+rdx int32[int8]
+rcx int32[int8]
+r8 int32[int8]
+r9 int32[int8]
+S+0 int32[int8]
+S+8 int32[int8]
+S+16 int32[int8]
+S+24 int32[int8]
+=>
+rax int8
diff --git a/runtime/vm/compiler/ffi/unit_tests/mixedx20/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/mixedx20/arm64_fuchsia.expect
new file mode 100644
index 0000000..32318c2
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/mixedx20/arm64_fuchsia.expect
@@ -0,0 +1,22 @@
+r0 int64
+v0 float
+r1 int64
+v1 double
+r2 int64
+v2 float
+r3 int64
+v3 double
+r4 int64
+v4 float
+r5 int64
+v5 double
+r6 int64
+v6 float
+r7 int64
+v7 double
+S+0 int64
+S+8 float
+S+16 int64
+S+24 double
+=>
+v0 double
diff --git a/runtime/vm/compiler/ffi/unit_tests/mixedx20/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/mixedx20/x64_fuchsia.expect
new file mode 100644
index 0000000..7c174cd
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/mixedx20/x64_fuchsia.expect
@@ -0,0 +1,22 @@
+rdi int64
+xmm0 float
+rsi int64
+xmm1 double
+rdx int64
+xmm2 float
+rcx int64
+xmm3 double
+r8 int64
+xmm4 float
+r9 int64
+xmm5 double
+S+0 int64
+xmm6 float
+S+8 int64
+xmm7 double
+S+16 int64
+S+24 float
+S+32 int64
+S+40 double
+=>
+xmm0 double
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress46127/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/regress46127/arm64_fuchsia.expect
new file mode 100644
index 0000000..9245d0d
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress46127/arm64_fuchsia.expect
@@ -0,0 +1,3 @@
+
+=>
+M(r0 int64) Struct(size: 8)
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress46127/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/regress46127/x64_fuchsia.expect
new file mode 100644
index 0000000..49ae1fd
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress46127/x64_fuchsia.expect
@@ -0,0 +1,3 @@
+
+=>
+M(rax int64) Struct(size: 8)
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_android.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_android.expect
new file mode 100644
index 0000000..ea3fdac
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_android.expect
@@ -0,0 +1,9 @@
+r0 int64
+v0 double
+r1 int32
+v1 double
+r2 int32
+r3 int64
+r4 int64
+=>
+r0 void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_fuchsia.expect
new file mode 100644
index 0000000..ea3fdac
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_fuchsia.expect
@@ -0,0 +1,9 @@
+r0 int64
+v0 double
+r1 int32
+v1 double
+r2 int32
+r3 int64
+r4 int64
+=>
+r0 void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_ios.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_ios.expect
new file mode 100644
index 0000000..ea3fdac
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_ios.expect
@@ -0,0 +1,9 @@
+r0 int64
+v0 double
+r1 int32
+v1 double
+r2 int32
+r3 int64
+r4 int64
+=>
+r0 void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_linux.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_linux.expect
new file mode 100644
index 0000000..ea3fdac
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_linux.expect
@@ -0,0 +1,9 @@
+r0 int64
+v0 double
+r1 int32
+v1 double
+r2 int32
+r3 int64
+r4 int64
+=>
+r0 void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_macos.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_macos.expect
new file mode 100644
index 0000000..ea3fdac
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm64_macos.expect
@@ -0,0 +1,9 @@
+r0 int64
+v0 double
+r1 int32
+v1 double
+r2 int32
+r3 int64
+r4 int64
+=>
+r0 void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm_android.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm_android.expect
new file mode 100644
index 0000000..e62a22a
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm_android.expect
@@ -0,0 +1,9 @@
+r0 int32
+(r2, r3) int64[double]
+S+0 int32
+S+8 double
+S+16 int32
+S+20 int32
+S+24 int32
+=>
+r0 void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm_ios.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm_ios.expect
new file mode 100644
index 0000000..0fba7ec
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm_ios.expect
@@ -0,0 +1,9 @@
+r0 int32
+d0 double
+r1 int32
+d1 double
+r2 int32
+r3 int32
+S+0 int32
+=>
+r0 void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm_linux.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm_linux.expect
new file mode 100644
index 0000000..0fba7ec
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/arm_linux.expect
@@ -0,0 +1,9 @@
+r0 int32
+d0 double
+r1 int32
+d1 double
+r2 int32
+r3 int32
+S+0 int32
+=>
+r0 void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/ia32_android.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/ia32_android.expect
new file mode 100644
index 0000000..c427c0c
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/ia32_android.expect
@@ -0,0 +1,9 @@
+S+0 int32
+S+4 double
+S+12 int32
+S+16 double
+S+24 int32
+S+28 int32
+S+32 int32
+=>
+eax void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/ia32_linux.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/ia32_linux.expect
new file mode 100644
index 0000000..c427c0c
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/ia32_linux.expect
@@ -0,0 +1,9 @@
+S+0 int32
+S+4 double
+S+12 int32
+S+16 double
+S+24 int32
+S+28 int32
+S+32 int32
+=>
+eax void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/ia32_win.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/ia32_win.expect
new file mode 100644
index 0000000..c427c0c
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/ia32_win.expect
@@ -0,0 +1,9 @@
+S+0 int32
+S+4 double
+S+12 int32
+S+16 double
+S+24 int32
+S+28 int32
+S+32 int32
+=>
+eax void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/riscv32_linux.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/riscv32_linux.expect
new file mode 100644
index 0000000..6fcafab
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/riscv32_linux.expect
@@ -0,0 +1,9 @@
+a0 int32
+fa0 double
+a1 int32
+fa1 double
+a2 int32
+a3 int32
+a4 int32
+=>
+a0 void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/riscv64_linux.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/riscv64_linux.expect
new file mode 100644
index 0000000..3486370
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/riscv64_linux.expect
@@ -0,0 +1,9 @@
+a0 int64
+fa0 double
+a1 int32
+fa1 double
+a2 int32
+a3 int64
+a4 int64
+=>
+a0 void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_fuchsia.expect
new file mode 100644
index 0000000..5b59ddb
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_fuchsia.expect
@@ -0,0 +1,9 @@
+rdi int64
+xmm0 double
+rsi int32
+xmm1 double
+rdx int32
+rcx int64
+r8 int64
+=>
+rax void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_ios.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_ios.expect
new file mode 100644
index 0000000..5b59ddb
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_ios.expect
@@ -0,0 +1,9 @@
+rdi int64
+xmm0 double
+rsi int32
+xmm1 double
+rdx int32
+rcx int64
+r8 int64
+=>
+rax void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_linux.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_linux.expect
new file mode 100644
index 0000000..5b59ddb
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_linux.expect
@@ -0,0 +1,9 @@
+rdi int64
+xmm0 double
+rsi int32
+xmm1 double
+rdx int32
+rcx int64
+r8 int64
+=>
+rax void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_macos.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_macos.expect
new file mode 100644
index 0000000..5b59ddb
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_macos.expect
@@ -0,0 +1,9 @@
+rdi int64
+xmm0 double
+rsi int32
+xmm1 double
+rdx int32
+rcx int64
+r8 int64
+=>
+rax void
diff --git a/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_win.expect b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_win.expect
new file mode 100644
index 0000000..b45a2e4
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/regress_fuchsia105336/x64_win.expect
@@ -0,0 +1,9 @@
+rcx int64
+xmm1 double
+r8 int32
+xmm3 double
+S+0 int32
+S+8 int64
+S+16 int64
+=>
+rax void
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct128bytesx1/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct128bytesx1/arm64_fuchsia.expect
new file mode 100644
index 0000000..19a9509
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct128bytesx1/arm64_fuchsia.expect
@@ -0,0 +1,4 @@
+P(r0 int64) Struct(size: 128)
+r1 int32
+=>
+P(r8 int64) Struct(size: 128)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct128bytesx1/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct128bytesx1/x64_fuchsia.expect
new file mode 100644
index 0000000..c918afa
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct128bytesx1/x64_fuchsia.expect
@@ -0,0 +1,4 @@
+S+0 Struct(size: 128)
+rsi int32
+=>
+P(rdi int64, ret:rax int64) Struct(size: 128)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_fuchsia.expect
new file mode 100644
index 0000000..e14f6b1
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/arm64_fuchsia.expect
@@ -0,0 +1,8 @@
+M(v0 float, v1 float, v2 float) Struct(size: 12)
+M(v3 float, v4 float, v5 float) Struct(size: 12)
+S+0 Struct(size: 12)
+S+16 Struct(size: 12)
+S+32 Struct(size: 12)
+S+48 Struct(size: 12)
+=>
+r0 int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_fuchsia.expect
new file mode 100644
index 0000000..c4a4cc2
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct12bytesFloatx6/x64_fuchsia.expect
@@ -0,0 +1,8 @@
+M(xmm0 double, xmm1 double) Struct(size: 12)
+M(xmm2 double, xmm3 double) Struct(size: 12)
+M(xmm4 double, xmm5 double) Struct(size: 12)
+M(xmm6 double, xmm7 double) Struct(size: 12)
+S+0 Struct(size: 12)
+S+16 Struct(size: 12)
+=>
+rax int64
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct16bytesHomogenousx10/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct16bytesHomogenousx10/arm64_fuchsia.expect
new file mode 100644
index 0000000..123cea6
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct16bytesHomogenousx10/arm64_fuchsia.expect
@@ -0,0 +1,15 @@
+M(v0 float, v1 float, v2 float, v3 float) Struct(size: 16)
+v4 float
+S+0 Struct(size: 16)
+S+16 Struct(size: 16)
+S+32 Struct(size: 16)
+S+48 Struct(size: 16)
+S+64 Struct(size: 16)
+S+80 Struct(size: 16)
+S+96 Struct(size: 16)
+S+112 Struct(size: 16)
+S+128 float
+r0 int8
+S+136 Struct(size: 16)
+=>
+M(v0 float, v1 float, v2 float, v3 float) Struct(size: 16)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct16bytesHomogenousx10/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct16bytesHomogenousx10/x64_fuchsia.expect
new file mode 100644
index 0000000..4e2829c
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct16bytesHomogenousx10/x64_fuchsia.expect
@@ -0,0 +1,15 @@
+M(xmm0 double, xmm1 double) Struct(size: 16)
+xmm2 float
+M(xmm3 double, xmm4 double) Struct(size: 16)
+M(xmm5 double, xmm6 double) Struct(size: 16)
+S+0 Struct(size: 16)
+S+16 Struct(size: 16)
+S+32 Struct(size: 16)
+S+48 Struct(size: 16)
+S+64 Struct(size: 16)
+S+80 Struct(size: 16)
+xmm7 float
+rdi int32[int8]
+S+96 Struct(size: 16)
+=>
+M(xmm0 double, xmm1 double) Struct(size: 16)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct16bytesMixedx10/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct16bytesMixedx10/x64_fuchsia.expect
new file mode 100644
index 0000000..62ce615
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct16bytesMixedx10/x64_fuchsia.expect
@@ -0,0 +1,13 @@
+M(xmm0 double, rdi int64) Struct(size: 16)
+M(xmm1 double, rsi int64) Struct(size: 16)
+M(xmm2 double, rdx int64) Struct(size: 16)
+M(xmm3 double, rcx int64) Struct(size: 16)
+M(xmm4 double, r8 int64) Struct(size: 16)
+M(xmm5 double, r9 int64) Struct(size: 16)
+S+0 Struct(size: 16)
+S+16 Struct(size: 16)
+S+32 Struct(size: 16)
+S+48 Struct(size: 16)
+xmm6 float
+=>
+M(xmm0 double, rax int64) Struct(size: 16)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct16bytesMixedx10_2/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct16bytesMixedx10_2/x64_fuchsia.expect
new file mode 100644
index 0000000..71af233
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct16bytesMixedx10_2/x64_fuchsia.expect
@@ -0,0 +1,17 @@
+xmm0 float
+xmm1 float
+xmm2 float
+xmm3 float
+M(xmm4 double, rdi int64) Struct(size: 16)
+M(xmm5 double, rsi int64) Struct(size: 16)
+M(xmm6 double, rdx int64) Struct(size: 16)
+M(xmm7 double, rcx int64) Struct(size: 16)
+S+0 Struct(size: 16)
+S+16 Struct(size: 16)
+S+32 Struct(size: 16)
+S+48 Struct(size: 16)
+S+64 Struct(size: 16)
+S+80 Struct(size: 16)
+r8 int32
+=>
+M(xmm0 double, rax int64) Struct(size: 16)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct16bytesMixedx10_3/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct16bytesMixedx10_3/x64_fuchsia.expect
new file mode 100644
index 0000000..e3119e6
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct16bytesMixedx10_3/x64_fuchsia.expect
@@ -0,0 +1,13 @@
+M(rdi int64, xmm0 double) Struct(size: 16)
+M(rsi int64, xmm1 double) Struct(size: 16)
+M(rdx int64, xmm2 double) Struct(size: 16)
+M(rcx int64, xmm3 double) Struct(size: 16)
+M(r8 int64, xmm4 double) Struct(size: 16)
+M(r9 int64, xmm5 double) Struct(size: 16)
+S+0 Struct(size: 16)
+S+16 Struct(size: 16)
+S+32 Struct(size: 16)
+S+48 Struct(size: 16)
+xmm6 float
+=>
+M(rax int64, xmm0 double) Struct(size: 16)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct3bytesx10/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct3bytesx10/arm64_fuchsia.expect
new file mode 100644
index 0000000..0eb0d54
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct3bytesx10/arm64_fuchsia.expect
@@ -0,0 +1,12 @@
+M(r0 int64) Struct(size: 3)
+M(r1 int64) Struct(size: 3)
+M(r2 int64) Struct(size: 3)
+M(r3 int64) Struct(size: 3)
+M(r4 int64) Struct(size: 3)
+M(r5 int64) Struct(size: 3)
+M(r6 int64) Struct(size: 3)
+M(r7 int64) Struct(size: 3)
+M(S+0 int64) Struct(size: 3)
+M(S+8 int64) Struct(size: 3)
+=>
+M(r0 int64) Struct(size: 3)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct3bytesx10/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct3bytesx10/x64_fuchsia.expect
new file mode 100644
index 0000000..cbc1757
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct3bytesx10/x64_fuchsia.expect
@@ -0,0 +1,12 @@
+M(rdi int64) Struct(size: 3)
+M(rsi int64) Struct(size: 3)
+M(rdx int64) Struct(size: 3)
+M(rcx int64) Struct(size: 3)
+M(r8 int64) Struct(size: 3)
+M(r9 int64) Struct(size: 3)
+S+0 Struct(size: 3)
+S+8 Struct(size: 3)
+S+16 Struct(size: 3)
+S+24 Struct(size: 3)
+=>
+M(rax int64) Struct(size: 3)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct8bytesPackedx10/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct8bytesPackedx10/arm64_fuchsia.expect
new file mode 100644
index 0000000..0857db5
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct8bytesPackedx10/arm64_fuchsia.expect
@@ -0,0 +1,12 @@
+M(r0 int64) Struct(size: 8)
+M(r1 int64) Struct(size: 8)
+M(r2 int64) Struct(size: 8)
+M(r3 int64) Struct(size: 8)
+M(r4 int64) Struct(size: 8)
+M(r5 int64) Struct(size: 8)
+M(r6 int64) Struct(size: 8)
+M(r7 int64) Struct(size: 8)
+S+0 Struct(size: 8)
+S+8 Struct(size: 8)
+=>
+M(r0 int64) Struct(size: 8)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct8bytesPackedx10/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct8bytesPackedx10/x64_fuchsia.expect
new file mode 100644
index 0000000..fab8720
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct8bytesPackedx10/x64_fuchsia.expect
@@ -0,0 +1,12 @@
+S+0 Struct(size: 8)
+S+8 Struct(size: 8)
+S+16 Struct(size: 8)
+S+24 Struct(size: 8)
+S+32 Struct(size: 8)
+S+40 Struct(size: 8)
+S+48 Struct(size: 8)
+S+56 Struct(size: 8)
+S+64 Struct(size: 8)
+S+72 Struct(size: 8)
+=>
+P(rdi int64, ret:rax int64) Struct(size: 8)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct8bytesx1/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct8bytesx1/arm64_fuchsia.expect
new file mode 100644
index 0000000..a6404ed
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct8bytesx1/arm64_fuchsia.expect
@@ -0,0 +1,3 @@
+M(r0 int64) Struct(size: 8)
+=>
+M(r0 int64) Struct(size: 8)
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct8bytesx1/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct8bytesx1/x64_fuchsia.expect
new file mode 100644
index 0000000..fa9bb3c
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct8bytesx1/x64_fuchsia.expect
@@ -0,0 +1,3 @@
+M(rdi int64) Struct(size: 8)
+=>
+M(rax int64) Struct(size: 8)
diff --git a/runtime/vm/compiler/ffi/unit_tests/structPacked/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/structPacked/arm64_fuchsia.expect
new file mode 100644
index 0000000..9653167
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/structPacked/arm64_fuchsia.expect
@@ -0,0 +1,15 @@
+M(r0 int64, r1 int64) Struct(size: 9)
+M(r2 int64, r3 int64) Struct(size: 9)
+M(r4 int64, r5 int64) Struct(size: 9)
+M(r6 int64, r7 int64) Struct(size: 9)
+S+0 Struct(size: 9)
+S+16 Struct(size: 9)
+S+32 Struct(size: 9)
+S+48 Struct(size: 9)
+S+64 Struct(size: 9)
+S+80 Struct(size: 9)
+v0 double
+S+96 int32
+S+104 int32
+=>
+v0 double
diff --git a/runtime/vm/compiler/ffi/unit_tests/structPacked/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/structPacked/x64_fuchsia.expect
new file mode 100644
index 0000000..404a10f
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/structPacked/x64_fuchsia.expect
@@ -0,0 +1,15 @@
+S+0 Struct(size: 9)
+S+16 Struct(size: 9)
+S+32 Struct(size: 9)
+S+48 Struct(size: 9)
+S+64 Struct(size: 9)
+S+80 Struct(size: 9)
+S+96 Struct(size: 9)
+S+112 Struct(size: 9)
+S+128 Struct(size: 9)
+S+144 Struct(size: 9)
+xmm0 double
+rdi int32
+rsi int32
+=>
+xmm0 double
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct_VeryLargeStruct/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct_VeryLargeStruct/arm64_fuchsia.expect
new file mode 100644
index 0000000..59f05bb1
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct_VeryLargeStruct/arm64_fuchsia.expect
@@ -0,0 +1,17 @@
+Struct(size: 88, field alignment: 8, stack alignment: 8, members: {
+  0: int8,
+  2: int16,
+  4: int32,
+  8: int64,
+  16: uint8,
+  18: uint16,
+  20: uint32,
+  24: uint64,
+  32: int64,
+  40: double,
+  48: float,
+  56: int64,
+  64: int64,
+  72: int64,
+  80: int8
+})
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct_VeryLargeStruct/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct_VeryLargeStruct/x64_fuchsia.expect
new file mode 100644
index 0000000..59f05bb1
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct_VeryLargeStruct/x64_fuchsia.expect
@@ -0,0 +1,17 @@
+Struct(size: 88, field alignment: 8, stack alignment: 8, members: {
+  0: int8,
+  2: int16,
+  4: int32,
+  8: int64,
+  16: uint8,
+  18: uint16,
+  20: uint32,
+  24: uint64,
+  32: int64,
+  40: double,
+  48: float,
+  56: int64,
+  64: int64,
+  72: int64,
+  80: int8
+})
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct_floatarray/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct_floatarray/arm64_fuchsia.expect
new file mode 100644
index 0000000..728e016
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct_floatarray/arm64_fuchsia.expect
@@ -0,0 +1,3 @@
+Struct(size: 16, field alignment: 4, stack alignment: 8, members: {
+  0: Array(element type: Struct(size: 8, field alignment: 4, stack alignment: 8, members: {0: Array(element type: float, length: 2)}), length: 2)
+})
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct_floatarray/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct_floatarray/x64_fuchsia.expect
new file mode 100644
index 0000000..728e016
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct_floatarray/x64_fuchsia.expect
@@ -0,0 +1,3 @@
+Struct(size: 16, field alignment: 4, stack alignment: 8, members: {
+  0: Array(element type: Struct(size: 8, field alignment: 4, stack alignment: 8, members: {0: Array(element type: float, length: 2)}), length: 2)
+})
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct_floatx4/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct_floatx4/arm64_fuchsia.expect
new file mode 100644
index 0000000..c065867
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct_floatx4/arm64_fuchsia.expect
@@ -0,0 +1,6 @@
+Struct(size: 16, field alignment: 4, stack alignment: 8, members: {
+  0: float,
+  4: float,
+  8: float,
+  12: float
+})
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct_floatx4/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct_floatx4/x64_fuchsia.expect
new file mode 100644
index 0000000..c065867
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct_floatx4/x64_fuchsia.expect
@@ -0,0 +1,6 @@
+Struct(size: 16, field alignment: 4, stack alignment: 8, members: {
+  0: float,
+  4: float,
+  8: float,
+  12: float
+})
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct_int8array/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct_int8array/arm64_fuchsia.expect
new file mode 100644
index 0000000..02a0124
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct_int8array/arm64_fuchsia.expect
@@ -0,0 +1,3 @@
+Struct(size: 8, field alignment: 1, stack alignment: 8, members: {
+  0: Array(element type: int8, length: 8)
+})
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct_int8array/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct_int8array/x64_fuchsia.expect
new file mode 100644
index 0000000..02a0124
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct_int8array/x64_fuchsia.expect
@@ -0,0 +1,3 @@
+Struct(size: 8, field alignment: 1, stack alignment: 8, members: {
+  0: Array(element type: int8, length: 8)
+})
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct_int8x10/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct_int8x10/arm64_fuchsia.expect
new file mode 100644
index 0000000..e2ae57e
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct_int8x10/arm64_fuchsia.expect
@@ -0,0 +1,12 @@
+Struct(size: 10, field alignment: 1, stack alignment: 8, members: {
+  0: int8,
+  1: int8,
+  2: int8,
+  3: int8,
+  4: int8,
+  5: int8,
+  6: int8,
+  7: int8,
+  8: int8,
+  9: int8
+})
diff --git a/runtime/vm/compiler/ffi/unit_tests/struct_int8x10/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/struct_int8x10/x64_fuchsia.expect
new file mode 100644
index 0000000..e2ae57e
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/struct_int8x10/x64_fuchsia.expect
@@ -0,0 +1,12 @@
+Struct(size: 10, field alignment: 1, stack alignment: 8, members: {
+  0: int8,
+  1: int8,
+  2: int8,
+  3: int8,
+  4: int8,
+  5: int8,
+  6: int8,
+  7: int8,
+  8: int8,
+  9: int8
+})
diff --git a/runtime/vm/compiler/ffi/unit_tests/union16bytesHomogenousx10/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/union16bytesHomogenousx10/arm64_fuchsia.expect
new file mode 100644
index 0000000..c2dcf8c
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/union16bytesHomogenousx10/arm64_fuchsia.expect
@@ -0,0 +1,13 @@
+M(v0 float, v1 float, v2 float, v3 float) Union(size: 16)
+M(v4 float, v5 float, v6 float, v7 float) Union(size: 16)
+S+0 Union(size: 16)
+S+16 Union(size: 16)
+S+32 Union(size: 16)
+S+48 Union(size: 16)
+S+64 Union(size: 16)
+S+80 Union(size: 16)
+S+96 Union(size: 16)
+r0 int8
+S+112 Union(size: 16)
+=>
+M(v0 float, v1 float, v2 float, v3 float) Union(size: 16)
diff --git a/runtime/vm/compiler/ffi/unit_tests/union16bytesHomogenousx10/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/union16bytesHomogenousx10/x64_fuchsia.expect
new file mode 100644
index 0000000..1b1354d
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/union16bytesHomogenousx10/x64_fuchsia.expect
@@ -0,0 +1,13 @@
+M(xmm0 double, xmm1 double) Union(size: 16)
+M(xmm2 double, xmm3 double) Union(size: 16)
+M(xmm4 double, xmm5 double) Union(size: 16)
+M(xmm6 double, xmm7 double) Union(size: 16)
+S+0 Union(size: 16)
+S+16 Union(size: 16)
+S+32 Union(size: 16)
+S+48 Union(size: 16)
+S+64 Union(size: 16)
+rdi int32[int8]
+S+80 Union(size: 16)
+=>
+M(xmm0 double, xmm1 double) Union(size: 16)
diff --git a/runtime/vm/compiler/ffi/unit_tests/union5bytesPackedx10/arm64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/union5bytesPackedx10/arm64_fuchsia.expect
new file mode 100644
index 0000000..5e76e36
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/union5bytesPackedx10/arm64_fuchsia.expect
@@ -0,0 +1,12 @@
+M(r0 int64) Union(size: 5)
+M(r1 int64) Union(size: 5)
+M(r2 int64) Union(size: 5)
+M(r3 int64) Union(size: 5)
+M(r4 int64) Union(size: 5)
+M(r5 int64) Union(size: 5)
+M(r6 int64) Union(size: 5)
+M(r7 int64) Union(size: 5)
+M(S+0 int64) Union(size: 5)
+M(S+8 int64) Union(size: 5)
+=>
+M(r0 int64) Union(size: 5)
diff --git a/runtime/vm/compiler/ffi/unit_tests/union5bytesPackedx10/x64_fuchsia.expect b/runtime/vm/compiler/ffi/unit_tests/union5bytesPackedx10/x64_fuchsia.expect
new file mode 100644
index 0000000..5119d88
--- /dev/null
+++ b/runtime/vm/compiler/ffi/unit_tests/union5bytesPackedx10/x64_fuchsia.expect
@@ -0,0 +1,12 @@
+S+0 Union(size: 5)
+S+8 Union(size: 5)
+S+16 Union(size: 5)
+S+24 Union(size: 5)
+S+32 Union(size: 5)
+S+40 Union(size: 5)
+S+48 Union(size: 5)
+S+56 Union(size: 5)
+S+64 Union(size: 5)
+S+72 Union(size: 5)
+=>
+P(rdi int64, ret:rax int64) Union(size: 5)