Commit 4258a59
[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: #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>1 parent 112cba1 commit 4258a59
File tree
7 files changed
+96
-27
lines changed- runtime/vm/compiler
- backend
- ffi
- frontend
7 files changed
+96
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6506 | 6506 | | |
6507 | 6507 | | |
6508 | 6508 | | |
| 6509 | + | |
| 6510 | + | |
| 6511 | + | |
| 6512 | + | |
| 6513 | + | |
6509 | 6514 | | |
6510 | 6515 | | |
6511 | 6516 | | |
| |||
6621 | 6626 | | |
6622 | 6627 | | |
6623 | 6628 | | |
| 6629 | + | |
| 6630 | + | |
| 6631 | + | |
| 6632 | + | |
| 6633 | + | |
| 6634 | + | |
| 6635 | + | |
| 6636 | + | |
| 6637 | + | |
| 6638 | + | |
| 6639 | + | |
| 6640 | + | |
| 6641 | + | |
| 6642 | + | |
| 6643 | + | |
| 6644 | + | |
| 6645 | + | |
| 6646 | + | |
| 6647 | + | |
| 6648 | + | |
| 6649 | + | |
| 6650 | + | |
6624 | 6651 | | |
6625 | 6652 | | |
6626 | 6653 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
392 | 401 | | |
393 | 402 | | |
394 | 403 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4007 | 4007 | | |
4008 | 4008 | | |
4009 | 4009 | | |
4010 | | - | |
| 4010 | + | |
4011 | 4011 | | |
4012 | | - | |
4013 | | - | |
4014 | | - | |
4015 | | - | |
4016 | | - | |
4017 | | - | |
4018 | | - | |
| 4012 | + | |
| 4013 | + | |
4019 | 4014 | | |
4020 | 4015 | | |
4021 | 4016 | | |
| |||
4039 | 4034 | | |
4040 | 4035 | | |
4041 | 4036 | | |
4042 | | - | |
| 4037 | + | |
4043 | 4038 | | |
4044 | 4039 | | |
4045 | | - | |
| 4040 | + | |
4046 | 4041 | | |
4047 | 4042 | | |
4048 | 4043 | | |
| |||
4528 | 4523 | | |
4529 | 4524 | | |
4530 | 4525 | | |
4531 | | - | |
4532 | | - | |
| 4526 | + | |
4533 | 4527 | | |
4534 | 4528 | | |
4535 | 4529 | | |
| |||
4538 | 4532 | | |
4539 | 4533 | | |
4540 | 4534 | | |
4541 | | - | |
| 4535 | + | |
4542 | 4536 | | |
4543 | 4537 | | |
4544 | 4538 | | |
| |||
4621 | 4615 | | |
4622 | 4616 | | |
4623 | 4617 | | |
4624 | | - | |
4625 | 4618 | | |
4626 | 4619 | | |
4627 | 4620 | | |
4628 | 4621 | | |
4629 | 4622 | | |
4630 | 4623 | | |
4631 | | - | |
| 4624 | + | |
| 4625 | + | |
| 4626 | + | |
| 4627 | + | |
4632 | 4628 | | |
4633 | | - | |
4634 | 4629 | | |
4635 | 4630 | | |
4636 | 4631 | | |
| |||
4652 | 4647 | | |
4653 | 4648 | | |
4654 | 4649 | | |
4655 | | - | |
| 4650 | + | |
| 4651 | + | |
| 4652 | + | |
| 4653 | + | |
| 4654 | + | |
| 4655 | + | |
4656 | 4656 | | |
4657 | 4657 | | |
4658 | 4658 | | |
| |||
4703 | 4703 | | |
4704 | 4704 | | |
4705 | 4705 | | |
| 4706 | + | |
| 4707 | + | |
4706 | 4708 | | |
4707 | 4709 | | |
4708 | 4710 | | |
| |||
4721 | 4723 | | |
4722 | 4724 | | |
4723 | 4725 | | |
| 4726 | + | |
| 4727 | + | |
4724 | 4728 | | |
4725 | 4729 | | |
4726 | 4730 | | |
| |||
4805 | 4809 | | |
4806 | 4810 | | |
4807 | 4811 | | |
4808 | | - | |
4809 | | - | |
| 4812 | + | |
| 4813 | + | |
4810 | 4814 | | |
4811 | 4815 | | |
4812 | 4816 | | |
| |||
4830 | 4834 | | |
4831 | 4835 | | |
4832 | 4836 | | |
4833 | | - | |
4834 | | - | |
| 4837 | + | |
4835 | 4838 | | |
4836 | 4839 | | |
4837 | 4840 | | |
| |||
4853 | 4856 | | |
4854 | 4857 | | |
4855 | 4858 | | |
4856 | | - | |
4857 | | - | |
| 4859 | + | |
4858 | 4860 | | |
4859 | 4861 | | |
4860 | 4862 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
309 | | - | |
| 308 | + | |
310 | 309 | | |
311 | 310 | | |
312 | 311 | | |
| |||
388 | 387 | | |
389 | 388 | | |
390 | 389 | | |
391 | | - | |
| 390 | + | |
392 | 391 | | |
393 | 392 | | |
394 | 393 | | |
| |||
399 | 398 | | |
400 | 399 | | |
401 | 400 | | |
402 | | - | |
| 401 | + | |
403 | 402 | | |
404 | 403 | | |
405 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
667 | 667 | | |
668 | 668 | | |
669 | 669 | | |
| 670 | + | |
670 | 671 | | |
671 | 672 | | |
672 | 673 | | |
| |||
0 commit comments