From ae4631e1003f16edaa92a44ffae54a739275c129 Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Wed, 3 Feb 2021 10:21:08 +0000 Subject: [PATCH] [vm/ffi] Fix test `sizeOf` struct on arm32 Bug introduced in https://dart-review.googlesource.com/c/sdk/+/182262. See documentation on alignment in the following places: - pkg/vm/lib/transformations/ffi.dart - runtime/vm/compiler/ffi/abi.cc - runtime/vm/compiler/ffi/native_type.cc Closes: https://github.com/dart-lang/sdk/issues/44835 Change-Id: I114dd4286e559bb230e1ee27ae5cfd8a0b0d2927 Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182501 Commit-Queue: Daco Harkes Reviewed-by: Clement Skau --- tests/ffi/sizeof_test.dart | 7 ++++--- tests/ffi_2/sizeof_test.dart | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/ffi/sizeof_test.dart b/tests/ffi/sizeof_test.dart index 4fd42fd6f65..35cb36c7c4b 100644 --- a/tests/ffi/sizeof_test.dart +++ b/tests/ffi/sizeof_test.dart @@ -16,9 +16,10 @@ get is64Bit => 8 == sizeOf(); void main() async { if (is32Bit) { Expect.equals(4, sizeOf()); - Expect.equals(20, sizeOf()); - } - if (is64Bit) { + // Struct is 20 bytes on ia32 and arm32-iOS, but 24 bytes on arm32-Android + // and arm32-Linux due to alignment. + Expect.isTrue(20 == sizeOf() || 24 == sizeOf()); + } else if (is64Bit) { Expect.equals(8, sizeOf()); Expect.equals(24, sizeOf()); } diff --git a/tests/ffi_2/sizeof_test.dart b/tests/ffi_2/sizeof_test.dart index 4fd42fd6f65..35cb36c7c4b 100644 --- a/tests/ffi_2/sizeof_test.dart +++ b/tests/ffi_2/sizeof_test.dart @@ -16,9 +16,10 @@ get is64Bit => 8 == sizeOf(); void main() async { if (is32Bit) { Expect.equals(4, sizeOf()); - Expect.equals(20, sizeOf()); - } - if (is64Bit) { + // Struct is 20 bytes on ia32 and arm32-iOS, but 24 bytes on arm32-Android + // and arm32-Linux due to alignment. + Expect.isTrue(20 == sizeOf() || 24 == sizeOf()); + } else if (is64Bit) { Expect.equals(8, sizeOf()); Expect.equals(24, sizeOf()); }