-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vm/ffi] Support inline arrays in
Struct
s
Adds support for single dimension inline arrays in structs. Multi- dimensional arrays will be supported in a future CL. This CL adds: - CFE static error checks for inline arrays. - CFE transformations for inline arrays. - VM consumption of inline array fields for NativeType. - Test generator support for inline arrays + generated tests. Previous CLs added support for inline arrays in: - analyzer https://dart-review.googlesource.com/c/sdk/+/183684 - updated in this CL to new API. - ABI calculation https://dart-review.googlesource.com/c/sdk/+/183682 Closes: #35763 Open issue: #45101 CFE transformations are tested with expectation files: TEST=pkg/front_end/testcases/(.*)/ffi_struct_inline_array.dart Trampolines and CArray API are tested with end-to-end Dart tests: TEST=tests/ffi(_2)/(.*)by_value(.*)test.dart TEST=tests/ffi(_2)/inline_array_test.dart Compile-time errors (both CFE and analyzer) are tested in: TEST=tests/ffi(_2)/vmspecific_static_checks_test.dart Change-Id: I014c0e4153f1b885638adce80de6ab3cac8e6bb2 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/+/183640 Commit-Queue: Daco Harkes <[email protected]> Reviewed-by: Martin Kustermann <[email protected]> Reviewed-by: Clement Skau <[email protected]>
- Loading branch information
1 parent
3a4a4f5
commit d45fd0f
Showing
42 changed files
with
6,549 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:ffi'; | ||
|
||
import "package:ffi/ffi.dart"; | ||
|
||
class StructInlineArray extends Struct { | ||
@Array(8) | ||
external Array<Uint8> a0; | ||
} | ||
|
||
main() {} |
27 changes: 27 additions & 0 deletions
27
pkg/front_end/testcases/nnbd/ffi_struct_inline_array.dart.strong.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:ffi" as ffi; | ||
|
||
import "dart:ffi"; | ||
import "package:ffi/ffi.dart"; | ||
|
||
class StructInlineArray extends ffi::Struct { | ||
synthetic constructor •() → self::StructInlineArray | ||
: super ffi::Struct::•() | ||
; | ||
@#C2 | ||
external get a0() → ffi::Array<ffi::Uint8>; | ||
@#C2 | ||
external set a0(ffi::Array<ffi::Uint8> #externalFieldValue) → void; | ||
} | ||
static method main() → dynamic {} | ||
|
||
constants { | ||
#C1 = 8 | ||
#C2 = ffi::_ArraySize<ffi::NativeType> {dimension1:#C1} | ||
} | ||
|
||
|
||
Constructor coverage from constants: | ||
org-dartlang-testcase:///ffi_struct_inline_array.dart: | ||
- _ArraySize. (from org-dartlang-sdk:///sdk/lib/ffi/ffi.dart:107:9) |
Oops, something went wrong.