-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[vm/ffi] wrong alignment of stack arguments in iOS #39637
Comments
The generated code for the trampoline - which is huge:
|
If possible, it would be good to fix this before flutter stable is released. Not sure if it's possible to do fixes afterwards. /cc @mit-mit |
Probable cause is the difference in ABI:
Update:
float should be 18.0 (0x41900000) instead is 0x00000000 The float is put into place of the int, instead of to the place where it is supposed to be. FfiCall:130( pointer=v157, v75 (@r0 int64), v79 (@v0 float), v83 (@r1 int64), v87 (@v1 double), v91 (@r2 int64), v95 (@v2 float), v99 (@r3 int64), v103 (@V3 double), v107 (@r4 int64), v111 (@v4 float), v115 (@R5 int64), v119 (@v5 double), v123 (@r6 int64), v127 (@v6 float), v131 (@r7 int64), v135 (@v7 double), v139 (@s+0 int64), v143 (@s+8 float), v147 (@s+16 int64), v151 (@s+24 double)) T{*?} Expected by iOS arm64 : ..., v139 (@s+0 int32), v143 (@s+4 float), v147 (@s+8 int32), v151 (@s+16 double)) T{*?} The int type seems to be the culprit for this specific test. Update #2: The actual stack alignment problem is also fixed v89 <- FfiCall:90( pointer=v87, v45 (@r0 int32[int8]), v49 (@r1 int32[int16]), v53 (@r2 int32[int8]), v57 (@r3 int32[int16]), v61 (@r4 int32[int8]), v65 (@R5 int32[int16]), v69 (@r6 int32[int8]), v73 (@r7 int32[int16]), v77 (@s+0 int8), v81 (@s+2 int16)) |
Test exercises alignment on stack, will currently fail on iOS arm64. In addition, the Dart functions used as callbacks in tests now print their arguments for debugging purposes. Issue: #39637 Splitting test off large CL (https://dart-review.googlesource.com/c/sdk/+/129081) to be able to land separately. Change-Id: Iba3c63338f5d91d6e3819e54c166bbfade48d53f Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131074 Reviewed-by: Teagan Strickland <sstrickl@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com>
sizeof(int) on iOS arm64 in Flutter test projects returns 4. Issue: #36140 Issue: #39637 Change-Id: I7b471fa1da653e9bee169c34d1bd36a96fa6a704 Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132607 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com>
Introduces NativeRepresentation and NativeLocation for the compilation of FFI. NativeRepresentations are able to express all representations (or types) of the native ABIs we bind to with FFI, this is more representations that than that are used in Dart itself. NativeLocations are able to express all locations of the native ABIs we bind to with FFI, this is more types of locations than that are used for the Dart calling convention. See the documentation in the respective files. These NativeLocations and NativeRepresentations are computed by the NativeCallingConvention and consumed by the Marshaller and Assemblers. This reenginering is required for go/dart-ffi-by-value, hardfp (Arm S and D fpu registers), and iOS 64 bit (non-word-aligned stack arguments). In addition, by using the NativeRepresentations we also get slightly reduced code size: * The tracking of sizes is improved, so less sign/zero-extension operations are required. * UnboxedWidthExtenderInstr is fully removed, the size extension is done inside the native moves, coalescing moves and size extension when possible. * BitCastInstr is only used when really needed. This reduces code-size on arm32 softfp. This fixes the iOS arm64 calling convention, manually tested with flutter/flutter#46078 and https://dart-review.googlesource.com/c/sdk/+/131074. Fixes: dart-lang#39637 Issue: dart-lang#36309 Issue: dart-lang#36730 Change-Id: I8878bc0f314277bab4ca22f417c6295ecc017720 Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129081 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com>
The test (part of
tests/ffi/function_test.dart
)ends up passing the
18.0
(akar
) in the wrong place (not where C++ code expects it).=> Might be due to difference in iOS ABI.
The bug should be reproducible with the flutter/flutter FFI integration test, which is waiting as PR atm: flutter/flutter#46078
The text was updated successfully, but these errors were encountered: