dart-sdk/benchmarks
Zach Anderson 2742d90033 Revert "[vm/ffi] Throw on returning Error in Handle"
This reverts commit d9c442bce8.

Reason for revert: https://github.com/flutter/flutter/issues/112726

Original change's description:
> [vm/ffi] Throw on returning `Error` in `Handle`
>
> 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: Ie8fabeb6d53bc80689541bc4470cb37ee2200581
> 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/+/261603
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

TBR=kustermann@google.com,rmacnak@google.com,dacoharkes@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I94cc63de16b54db2b0a4f92759c39a1e569b8e63
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
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/+/262270
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2022-09-30 21:51:59 +00:00
..
AsyncLiveVars Roll benchmark_harness and use AsyncBenchmarkBase. 2022-05-02 09:27:49 +00:00
BigIntParsePrint Fixed various typos in a lot of files 2022-07-25 12:21:59 +00:00
Calls [benchmarks/vm] Add benchmarks for #45908 2021-05-27 07:54:14 +00:00
DartCLIStartup [ Benchmarks ] Add benchmarks for SDK snapshot sizes and Dart CLI 2021-05-25 17:52:41 +00:00
Dynamic [benchmark] Add language version comments to benchmarks. 2020-10-13 01:43:22 +00:00
EventLoopLatencyJson [vm] Change EventLoopLatency benchmark to use RunTimeRaw latency 2020-10-23 18:31:01 +00:00
EventLoopLatencyJson350KB [vm/concurrency] Add EventLoopLatencyJson350KB bechmark 2020-10-28 16:28:38 +00:00
EventLoopLatencyRegexp [benchmark] Fix import statement in dart2/EventLoopLatencyRegexp benchmark. 2021-08-24 15:54:14 +00:00
Example Fix typo 2022-08-04 09:22:39 +00:00
FfiAsTypedList [vm/ffi] Optimize Pointer<T>.asTypedList() 2021-11-29 17:38:04 +00:00
FfiBoringssl Reland "[vm/ffi] Roll package:ffi to Allocator and Opaque" 2021-02-10 10:19:28 +00:00
FfiCall Revert "[vm/ffi] Throw on returning Error in Handle" 2022-09-30 21:51:59 +00:00
FfiMemory Reland "[vm/ffi] Add common C types" 2022-01-27 13:09:01 +00:00
FfiStruct Reland "[vm/ffi] Roll package:ffi to Allocator and Opaque" 2021-02-10 10:19:28 +00:00
InstantiateTypeArgs [benchmarks] Address post-review comments for InstantiateTypeArgs. 2022-07-27 08:54:57 +00:00
IntegerSetLookup [gardening] Fix copyright statement typo. 2022-09-15 18:00:59 +00:00
Isolate [benchmarks] Follow-up to "Roll benchmark_harness" 2022-05-02 12:26:41 +00:00
IsolateBaseOverhead [vm/concurrency] Add IsolateBaseOverhead benchmark 2022-05-30 08:14:52 +00:00
IsolateFibonacci [vm/concurrency] Remove --(no-)enable-isolate-groups flag usage in tests 2021-11-04 18:57:21 +00:00
IsolateJson [vm/sendandexit] Introduce Isolate.exit([port, message]). 2021-09-30 20:20:24 +00:00
IsolateSendExitLatency Move benchmark IsolateSendExitLatency to correct directory 2022-06-07 16:50:40 +00:00
IsolateSpawn [benchmark] Add language version comments to benchmarks. 2020-10-13 01:43:22 +00:00
IsolateSpawnMemory [vm/concurrency] Remove --(no-)enable-isolate-groups flag usage in tests 2021-11-04 18:57:21 +00:00
Iterators Add system list polymorphism cases in Iterators benchmark 2022-02-10 18:38:41 +00:00
ListCopy [benchmark] Add language version comments to benchmarks. 2020-10-13 01:43:22 +00:00
MapCopy [benchmark] Add MapCopy benchmark 2022-01-06 03:32:34 +00:00
MapLookup [benchmarks/vm] Add benchmarks for #45908 2021-05-27 07:54:14 +00:00
MD5 [benchmark] Add language version comments to benchmarks. 2020-10-13 01:43:22 +00:00
NativeCall [benchmark] Adds native call benchmark. 2021-11-04 15:16:24 +00:00
ObjectHash Add benchmark for Object.hash 2021-06-30 21:06:34 +00:00
Omnibus Add MapCopy to Omnibus benchmarks 2022-06-28 19:53:23 +00:00
OmnibusDeferred Add MapCopy to Omnibus benchmarks 2022-06-28 19:53:23 +00:00
Richards Fixed various typos in a lot of files 2022-07-25 12:21:59 +00:00
RuntimeType [benchmark] Add language version comments to benchmarks. 2020-10-13 01:43:22 +00:00
SDKArtifactSizes Remove dartanalyzer from SDKArtifactSizes benchmark 2022-07-19 10:51:45 +00:00
SendPort [vm] Prevent tree shaking of fields in SendPort benchmark 2021-07-16 04:39:37 +00:00
SHA1 [benchmark] Add language version comments to benchmarks. 2020-10-13 01:43:22 +00:00
SHA256 [benchmark] Add language version comments to benchmarks. 2020-10-13 01:43:22 +00:00
SkeletalAnimation [benchmark] Add language version comments to benchmarks. 2020-10-13 01:43:22 +00:00
SkeletalAnimationSIMD [benchmark] Add language version comments to benchmarks. 2020-10-13 01:43:22 +00:00
SoundSplayTreeSieve Fix typos 2022-09-16 19:35:00 +00:00
Startup [benchmarks] Apparently Golem has a metric called StartupTime. 2022-04-25 16:44:33 +00:00
StringPool [benchmarks] Add benchmark to measure dart2js string pool cost 2021-06-03 03:11:44 +00:00
TypedDataDuplicate [benchmark] Add language version comments to benchmarks. 2020-10-13 01:43:22 +00:00
TypeLiteral/dart [vm] Add TypeLiteral benchmark 2022-04-25 08:49:12 +00:00
Utf8Decode [benchmark] Add language version comments to benchmarks. 2020-10-13 01:43:22 +00:00
Utf8Encode [benchmark] Add language version comments to benchmarks. 2020-10-13 01:43:22 +00:00
analysis_options.yaml Roll benchmarks-internal to 02695da98bcf006b95630d3c386f4169d7ec4ecf 2020-06-26 01:56:03 +00:00
OWNERS [infra] Add OWNERS to the Dart SDK 2022-02-14 14:06:34 +00:00