Commit Graph

2 Commits

Author SHA1 Message Date
Daco Harkes 9d5846b86e [vm/ffi] Support Unions backend
This Splits the NativeCompoundType into NativeStructType and
NativeUnionType.

The calling conventions themselves did not have to be updated at all,
they rely on the 'queries' on NativeTypes.

Some interesting corner cases in the native calling conventions are:
1. Arm64 and arm hardfp still regard unions as homogeneous floats, even
   if the union members are different sizes.
2. Unions can be larger than their members if their largest member has
   a smaller alignment than a smaller member.
3. When a specific range in a struct contains floating points in one
   member, but integers in another, the integers take precedence.

Bug: https://github.com/dart-lang/sdk/issues/38491

tools/build.py run_ffi_unit_tests && tools/test.py ffi_unit
TEST=runtime/vm/compiler/ffi/native_calling_convention_test.cc
TEST=runtime/vm/compiler/ffi/native_type_test.cc
These tests are exercised on vm-precomp-ffi-qemu-linux-release-arm-try.

Change-Id: Ib97769457d1ad0fce47601e9e4a3008bd837167f
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194422
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-04-08 17:41:30 +00:00
Daco Harkes 9d1b447b23 [vm/ffi] Structs by value compiler frontend (part 1)
Split off https://dart-review.googlesource.com/c/sdk/+/140290 to make
that CL smaller.

This CL adds support for struct types in the ffi compiler frontend in
`runtime/vm/compiler/ffi/native_type.h`.

The code in this CL is unit tested:

1. From Dart source to `NativeCompoundType` are tested as VM test.
TEST=runtime/vm/compiler/ffi/native_type_vm_test.cc

2. The size and alignments for structs are tested with expect files.
TEST=runtime/vm/compiler/ffi/native_type_test.cc

The code in this CL has been end-to-end tested in the CL it is split off
from. And will be end-to-end tested when that CL also lands.

Issue: https://github.com/dart-lang/sdk/issues/36730

Change-Id: Ia7134e30daf028fea3ed97319ac7f5d0dbcc710f
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64-try,vm-ffi-android-debug-arm-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-mac-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172648
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2020-11-18 14:40:50 +00:00