dart-sdk/tests
Daco Harkes b113fffb65 Reland "[vm/ffi] Throw on returning Error in Handle"
Fix: Check handle contents for Smi.
Closes: https://github.com/flutter/flutter/issues/112726

Orignal CL description:

Makes `Dart_Handle` FFI returns behave as the following snippet:

```
Dart_Handle ExampleSnippet() {
  Dart_Handle result = ...;
  if (Dart_IsError(result)) {
    Dart_PropagateError(result);
  }
  return result;
}
```

Also makes FFI consistent with Dart_NativeFunctions, which will
automatically throw upon return if Dart_SetReturnValue set the result
to an error.

`UnhandledExceptions` cannot flow out into Dart generated code. So,
the implementation needs to be in `FfiCallInstr::EmitNativeCode`.

Using `Dart_IsError` is slow compared to a machine code class id
check. So, we should do the handle unwrapping and class id check in
machine code.

Unwrapping Handles in machine code is only safe when the GC is
guaranteed to not run: Either (1) in `kThreadInGenerated`, or (2) in
`kThreadInNative`, but only when transitioned into safepoint. So, the
handle cannot be unwrapped immediately after the FFI call in machine code. We first need to transition back to generated.

This means we need to transition again to native to do the actual
`Dart_PropagateError` call. We can do so without the stub in JIT
because we never return with normal control flow.

Performance impact of this change is within benchmark noise in both
JIT and AOT.
Size impact is 42 bytes on x64, which is 10% in AOT and 12% in JIT.

For more numbers see: go/dart-ffi-handle-error

TEST=runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc
TEST=tests/ffi/vmspecific_handle_test.dart

Closes: https://github.com/dart-lang/sdk/issues/49936
Change-Id: Id8edfd841a7d6246438386007d83747868a0a151
Cq-Include-Trybots: luci.dart.try:vm-canary-linux-debug-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-msvc-windows-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-tsan-linux-release-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-release-arm64-try,vm-kernel-precomp-win-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262342
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-10-03 12:25:08 +00:00
..
co19 [dart2wasm] Add relevant co19 and lib tests 2022-09-21 16:11:22 +00:00
co19_2 [infra] Add missing parenthesis in co19 update scripts 2022-07-25 14:14:59 +00:00
corelib Make Uri treat \ as / in path and authority. 2022-09-13 11:48:19 +00:00
corelib_2 Make Uri treat \ as / in path and authority. 2022-09-13 11:48:19 +00:00
dartdevc Revert "Refactor _Future." 2022-06-09 16:51:55 +00:00
dartdevc_2 [ddc] Ensure status file entries are consistent 2022-08-08 17:23:50 +00:00
ffi Reland "[vm/ffi] Throw on returning Error in Handle" 2022-10-03 12:25:08 +00:00
ffi_2 Reland "[vm/ffi] Throw on returning Error in Handle" 2022-10-03 12:25:08 +00:00
language Fix test to account for obfuscation 2022-09-28 19:24:26 +00:00
language_2 Fix test to account for obfuscation 2022-09-28 19:24:26 +00:00
lib [pkg:js] Add proto argument to createStaticInteropMock 2022-09-16 20:13:30 +00:00
lib_2 [pkg:js] Add proto argument to createStaticInteropMock 2022-09-16 20:13:30 +00:00
modular [package:js] Add static interop stub for outlines 2022-06-17 19:58:49 +00:00
standalone Fix typos 2022-09-16 19:35:00 +00:00
standalone_2 Fix typos 2022-09-16 19:35:00 +00:00
web [dart2wasm] Correctly handle null when jsifying maps. 2022-09-30 21:09:29 +00:00
web_2 [dart2js] Handle private names correctly in K/J-model 2022-08-11 06:56:32 +00:00
legacy_status_dart2js.csv
OWNERS
README.md

This directory contains tests of the language and core library implementations. For more information, see https://github.com/dart-lang/sdk/wiki/Testing.