commit | b6b82dd3ac756b39e7fe9cab21f060fae74e358d | [log] [tgz] |
---|---|---|
author | Daco Harkes <dacoharkes@google.com> | Fri Dec 18 09:34:35 2020 +0000 |
committer | commit-bot@chromium.org <commit-bot@chromium.org> | Fri Dec 18 09:34:35 2020 +0000 |
tree | 34f623433adf1a162bfc6db74174b90d0ea34d99 | |
parent | ba0a7c5df757bf23193bdb8d5c4aeb8adc473fb8 [diff] |
[vm/ffi] Support nested structs This CL adds support for nested structs in FFI calls, callbacks, and memory loads and stores through the Struct classes itself. Nesting empty structs and nesting a structs in themselves (directly or indirectly) is reported as error. This feature is almost fully implemented in the CFE transformation. Because structs depend on the sizes of their nested structs, the structs now need to be processed in topological order. Field access to nested structs branches at runtime on making a derived Pointer if the backing memory of the outer struct was a Pointer or making a TypedDataView if the backing memory of the outer struct was a TypedData. Assigning to a nested struct is a byte for byte copy from the source. The only changes in the VM are contained in the native calling convention calculation which now recursively needs to reason about fundamental types instead of just 1 struct deep. Because of the amount of corner cases in the calling conventions that need to be covered, the tests are generated, rather than hand-written. ABIs tested on CQ: x64 (Linux, MacOS, Windows), ia32 (Linux, Windows), arm (Android softFP, Linux hardFP), arm64 Android. ABIs tested locally through Flutter: arm64 iOS. ABIs not tested: ia32 Android (emulator), x64 iOS (simulator), arm iOS. TEST=runtime/bin/ffi_test/ffi_test_functions_generated.cc TEST=runtime/bin/ffi_test/ffi_test_functions.cc TEST=tests/{ffi,ffi_2}/function_structs_by_value_generated_test.dart TEST=tests/{ffi,ffi_2}/function_callbacks_structs_by_value_generated_tes TEST=tests/{ffi,ffi_2}/function_callbacks_structs_by_value_test.dart TEST=tests/{ffi,ffi_2}/vmspecific_static_checks_test.dart Closes https://github.com/dart-lang/sdk/issues/37271. Contains a temporary workaround for https://github.com/dart-lang/sdk/issues/44454. Change-Id: I5e5d10e09e5c3fc209f5f7e997efe17bd362214d Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,analyzer-analysis-server-linux-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169221 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Dart is:
Optimized for UI: Develop with a programming language specialized around the needs of user interface creation
Productive: Make changes iteratively: use hot reload to see the result instantly in your running app
Fast on all platforms: Compile to ARM & x64 machine code for mobile, desktop, and backend. Or compile to JavaScript for the web
Dart's flexible compiler technology lets you run Dart code in different ways, depending on your target platform and goals:
Dart Native: For programs targeting devices (mobile, desktop, server, and more), Dart Native includes both a Dart VM with JIT (just-in-time) compilation and an AOT (ahead-of-time) compiler for producing machine code.
Dart Web: For programs targeting the web, Dart Web includes both a development time compiler (dartdevc) and a production time compiler (dart2js).
Dart is free and open source.
See LICENSE and PATENT_GRANT.
Visit dart.dev to learn more about the language, tools, getting started, and more.
Browse pub.dev for more packages and libraries contributed by the community and the Dart team.
If you want to build Dart yourself, here is a guide to getting the source, preparing your machine to build the SDK, and building.
There are more documents on our wiki.
The easiest way to contribute to Dart is to file issues.
You can also contribute patches, as described in Contributing.