dart-sdk/runtime
Clement Skau 4258a59789 [vm][ffi] Passes FFI handles on stack.
Passing handles in FFI calls has significant overhead due to
how each handle requires a runtime entry to allocate in the
handle scope.

This change removes that runtime entry by relying on the
register allocator to allocate all handle arguments on the stack,
so that we don't need to allocate them separately.
To pass the stack handles to the native call we then pass a pointer
to the stack slot as the native argument.

Testing:
- We already have comprehensive tests for correctness in the form
  of the FFI tests. These make calls with various combinations of
  Handle and non-handle arguments.
- Correct GC behaviour is likewise covered in
  `vmspecific_handle_test.dart` which makes calls with handles
  arguments and triggers GC in-flight.
  In case we do not correctly pass the handles on the stack, the
  GC will trash them during the call.

TEST=Existing.
Bug: https://github.com/dart-lang/sdk/issues/47624
Change-Id: Ic837bad5484daaa5534b7c2e8707ac2c5dfa480f
Cq-Include-Trybots: luci.dart.try:vm-kernel-gcc-linux-try,vm-kernel-linux-debug-simriscv64-try,vm-kernel-nnbd-mac-release-arm64-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-simriscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243320
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2022-05-11 06:43:14 +00:00
..
bin [VM/io] - Add missing native entry to enable resolution. 2022-05-09 16:24:02 +00:00
docs [vm] Expose whether extension stream has listeners, guard postEvent 2022-04-26 07:53:43 +00:00
include [dart:io] Publish implementations of the VM file callbacks. 2022-04-19 23:27:17 +00:00
lib [vm] New async/await implementation in the VM, part 2 - vm 2022-04-29 01:03:50 +00:00
observatory [ VM / Service ] Add libraryFilters to getSourceReport RPC 2022-05-10 18:08:43 +00:00
observatory_2 [ VM / Service ] Add libraryFilters to getSourceReport RPC 2022-05-10 18:08:43 +00:00
platform Reland "[build] Fix Android build for ARM64 Mac." 2022-05-10 16:11:53 +00:00
tests Revert "[vm] Only call .hashCode once when adding to Map and Set" 2022-05-06 10:24:29 +00:00
third_party [vm] More pieces of Windows ARM support. 2022-04-07 23:15:48 +00:00
tools move runtime/tools/wiki/xref_extractor to package:lints 2022-04-19 15:39:57 +00:00
vm [vm][ffi] Passes FFI handles on stack. 2022-05-11 06:43:14 +00:00
.clang-tidy
.gitignore
BUILD.gn [build] -fno-strict-vtable-pointers is a Clang-only flag. 2022-03-30 17:34:20 +00:00
codereview.settings
configs.gni Reland "[vm] Build dart2native dependencies with the normal "create_sdk" target" 2020-06-17 16:12:26 +00:00
CPPLINT.cfg
OWNERS [infra] Add OWNERS to the Dart SDK 2022-02-14 14:06:34 +00:00
PRESUBMIT.py [python3] Migrate PRESUBMIT.py files 2021-08-16 08:29:54 +00:00
runtime_args.gni [VM] error: ‘mallinfo mallinfo()’ is deprecated 2021-12-08 00:25:10 +00:00