mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
acdf82de17
This CL adds support for users defining integers which are mapped to differing sizes and signedness based on the application binary interface the Dart VM is running on. Notable implementation design decisions: - ABIs are open world, so that adding an ABI to the Dart VM does not break existing definitions. Thus, we only figure out in the VM that we're missing a mapping. We throw compile-time errors. - In AOT, these show up in the precompilation step. - In JIT, these show up as `_CompileTimeError` at runtime. Note that these can be caught. So in subsequent compilation steps we need to ensure that we also throw the same compile-time error. - We match on the call-sites (streaming_flowgraph_builder) rather than method bodies (kernel_to_il) of AbiSpecific loads and stores so that we can compile for the int-size of the call site. API design decisions: https://github.com/dart-lang/sdk/issues/42563#issuecomment-981774001 Closes: https://github.com/dart-lang/sdk/issues/42563 TEST=tests/ffi_2/abi_*_test.dart TEST=tests/ffi/function_*_generated_test.dart TEST=tests/ffi/vmspecific_static_checks_test.dart Change-Id: I8c8df36fab939b6fb614c5f1ee8e1bf46b6e9521 Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,benchmark-linux-try,dart-sdk-linux-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-fuchsia-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64c-try,vm-kernel-mac-debug-x64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221501 Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
25 lines
698 B
Dart
25 lines
698 B
Dart
// 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.
|
|
|
|
// @dart = 2.9
|
|
|
|
// SharedObjects=ffi_test_functions
|
|
|
|
import 'dart:ffi';
|
|
|
|
// We want at least 1 mapping to satisfy the static checks.
|
|
const notTestingOn = Abi.fuchsiaArm64;
|
|
|
|
@AbiSpecificIntegerMapping({
|
|
notTestingOn: Int8(),
|
|
})
|
|
class Incomplete extends AbiSpecificInteger {
|
|
const Incomplete();
|
|
}
|
|
|
|
void main() {
|
|
// Any use that causes the class to be used, causes a compile-time error
|
|
// during loading of the class.
|
|
nullptr.cast<Incomplete>(); //# 1: compile-time error
|
|
}
|