Skip to content

FFI: Support hardfp calling conventions on Linux ARM #36309

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

Closed
sjindel-google opened this issue Mar 22, 2019 · 5 comments
Closed

FFI: Support hardfp calling conventions on Linux ARM #36309

sjindel-google opened this issue Mar 22, 2019 · 5 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-ffi

Comments

@sjindel-google
Copy link
Contributor

We have only implemented the softfp calling convention, which is used by Android and iOS (regardless of whether hardfp support is available).

Linux ("gnueabi") uses the hardfp calling convention, we which must implement to support FFI on Linux ARM.

@sjindel-google sjindel-google added library-ffi area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. labels Mar 22, 2019
dart-bot pushed a commit that referenced this issue Jul 19, 2019
Adds micro benchmarks to measure low level (1) C memory reads and writes from Dart and (2) calls from Dart into C. This CL also adds a macro benchmark to measure overall performance using BoringSSL to digest data. The shared libraries are precompiled for Linux and live in cipd packages. The benchmarks run on all hardware architectures (with the exception of Linux'es hardfp on Arm32: #36309).

Issue: #36247

Change-Id: I8dfb30cc66a26a2942bb09194c5eb0da0b6ca1b5
Cq-Include-Trybots: luci.dart.try:benchmark-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108724
Commit-Queue: Daco Harkes <[email protected]>
Reviewed-by: Jonas Termansen <[email protected]>
Auto-Submit: Daco Harkes <[email protected]>
@dcharkes
Copy link
Contributor

dcharkes commented Nov 1, 2019

To implement:

Any result whose type would satisfy the conditions for a VFP CPRC is returned in the appropriate number of consecutive VFP registers starting with the lowest numbered register (s0, d0, q0).

Float in s0, double in d0.

There is one VFP co-processor register class using registers s0-s15 (d0-d7) for passing arguments.

Floats in s-registers, doubles in d-registers.

Note that the rules require the ‘back-filling’ of unused co-processor registers that are skipped by the
alignment constraints of earlier arguments. The back-filling continues only so long as no VFP CPRC has been allocated to a slot on the stack.

Source: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ihi0042f/index.html

@mkustermann
Copy link
Member

Let's try to target to have this ready by D27, so our configuration space is completed and dart:ffi works on all sdks we distribute.

@dcharkes dcharkes added this to the D27 Release milestone Nov 1, 2019
@dcharkes
Copy link
Contributor

dcharkes commented Nov 1, 2019

In order to implement this we need refactor our logic in the FFI to compute the location of where arguments should be. We currently use the Location that is shared with the rest of the compiler that compiles everything according to the Dart ABI. And those Locations only support q-registers.

(Side note: supporting structs-by-value (#36730) requires the same refactoring. That introduces even more locations that are not used in the Dart ABI. Arbitrary size stack locations, allocated memory with a pointer in a register, etc.)

Let's see if it's feasible to get that done by D27.

@vsmenon
Copy link
Member

vsmenon commented Nov 4, 2019

How is this looking? Flutter will begin picking release candidates tomorrow. ( fyi @mraleph @a-siva )

@dcharkes
Copy link
Contributor

dcharkes commented Nov 4, 2019

That's far fetched.

@dcharkes dcharkes removed this from the D27 Release milestone Nov 4, 2019
dart-bot pushed a commit that referenced this issue Jan 22, 2020
To address the comment about tests from https://dart-review.googlesource.com/c/sdk/+/124136/3/runtime/bin/ffi_test/ffi_test_functions.cc

Issue: #36309

Change-Id: Ib6b56db22d44603d31006f3f099ab25a8a9c6d55
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/+/132843
Commit-Queue: Daco Harkes <[email protected]>
Reviewed-by: Martin Kustermann <[email protected]>
dart-bot pushed a commit that referenced this issue Feb 5, 2020
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: #39637
Issue: #36309
Issue: #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 <[email protected]>
Reviewed-by: Martin Kustermann <[email protected]>
Reviewed-by: Alexander Markov <[email protected]>
tekknolagi pushed a commit to tekknolagi/dart-assembler that referenced this issue Nov 3, 2020
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 <[email protected]>
Reviewed-by: Martin Kustermann <[email protected]>
Reviewed-by: Alexander Markov <[email protected]>
tekknolagi pushed a commit to tekknolagi/dart-assembler that referenced this issue Nov 3, 2020
Implement the hardfp calling convention.

Tested QEMU locally as the bots are not online yet.

tools/test.py -m debug -a arm -c dartkp --use-qemu ffi_2 ; tools/test.py -m debug -a arm -c dartk --use-qemu ffi_2
Test configuration:
    custom configuration(architecture: arm, compiler: dartkp, mode: debug, runtime: dart_precompiled, system: linux, use-qemu)
Suites tested: ffi_2
[00:45 | 100% | +  189 | -    0]
Test configuration:
    custom configuration(architecture: arm, compiler: dartk, mode: debug, runtime: vm, system: linux, use-qemu)
Suites tested: ffi_2
[09:52 | 100% | +  189 | -    0]

Fixes: dart-lang#36309

Change-Id: Ic34175bdf9b9f359f1126aeb157362e76443921a
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/+/124136
Commit-Queue: Daco Harkes <[email protected]>
Reviewed-by: Martin Kustermann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-ffi
Projects
None yet
Development

No branches or pull requests

4 participants