-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[vm/ffi] Support FFI callbacks in AOT configurations #37295
Comments
API ChangesCurrently the function argument to Since we don't have a ImplementationPrecompiling callback trampolinesIn the JIT, we allocate "callback ids" and setup associated thead-local state when compiling a callback (during Object _nativeCallbackFunction<NS extends Function>(Function target, Object exceptionalReturn) native "...";
Pointer<NS> _pointerFromFunction<NS extends NativeFunction>(Object function) native "...";
// Compile-time transformation (after static checks):
fromFunction<NS>(f, e) =>
_pointerFromFunction<NativeFunction<NS>>(
_nativeCallbackFunction<NS>(f, e));
|
/cc @mkustermann @rmacnak-google @alexmarkov Martin: I think this reflects the design we discussed. |
Since the Dart callbacks which C code invokes have a lifetime until the end of the isolate (we don't know how long C code hangs on to them, so the GC cannot know it either) we want to have a bounded number of those (i.e. we restrict ourselves to static methods). We also enforce the error value to be a compile-time constant. Precompiling callback trampolines: Since we restrict ourselves to static methods it seems weird if we have to call Finding the Thread & Relocation: This aligns with my original suggestion, i.e. use pc-relative loads to get the address of the c function which, when invoked, returns the current thread. So far there seem to be no blockers on this. It also might allow us to use the data/bss section for other purposes in the future. Blobs: Preferably we would change the embedder API to give us the filename (and/or buffer) of the blob and the VM can map the text and data/bss section appropriately. We can add a small header to the blobs format which describes the relative offsets to which the data/bss sections have to be mapped. This would simplify our embedders and gives us more flexibility |
Absolutely, I'll do that.
I agree with the idea of consolidating the blobs format from 4 files into 1, and adding a header so the VM can create the mappings as appropriate. |
…cl. blobs). To do this, we add writable data sections (currently uninitialzed) to ELF and Asm snapshots and allow Instructions to have patchable relocations against (the start of) these sections. Issue #37295 (see also for design & discussion). Change-Id: If20bfa55776f4044aaa6bb8ea2101d2ada41842c Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-android-release-arm-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110221 Commit-Queue: Samir Jindel <sjindel@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
…hots (excl. blobs)." This reverts commit ecbea5a. Reason for revert: broken with bare instructions and ABI bot Original change's description: > [vm/ffi] Implement FFI callbacks on AOT for ELF and Asm snapshots (excl. blobs). > > To do this, we add writable data sections (currently uninitialzed) to ELF and Asm snapshots > and allow Instructions to have patchable relocations against (the start of) these sections. > > Issue #37295 (see also for design & discussion). > > Change-Id: If20bfa55776f4044aaa6bb8ea2101d2ada41842c > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-android-release-arm-try > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110221 > Commit-Queue: Samir Jindel <sjindel@google.com> > Reviewed-by: Martin Kustermann <kustermann@google.com> TBR=kustermann@google.com,rmacnak@google.com,alexmarkov@google.com,sjindel@google.com Change-Id: I9787da6d42575ca4f5ae0a698052a19ac4275afd No-Presubmit: true No-Tree-Checks: true No-Try: true Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-product-x64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-android-release-arm-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115240 Reviewed-by: Samir Jindel <sjindel@google.com> Commit-Queue: Samir Jindel <sjindel@google.com>
@sjindel-google We can close this issue, right? |
I was leaving it open as a marker for deprecating blobs, but as we discussed that should happen asynchronously. |
@sjindel-google It seems like the code related this issue has been reverted. I wonder will it still can be used in next dev release? |
@ForelaxX Yes, code has been re-landed and it's ready to use. |
…cl. blobs). To do this, we add writable data sections (currently uninitialzed) to ELF and Asm snapshots and allow Instructions to have patchable relocations against (the start of) these sections. Issue dart-lang#37295 (see also for design & discussion). Change-Id: If20bfa55776f4044aaa6bb8ea2101d2ada41842c Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-android-release-arm-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110221 Commit-Queue: Samir Jindel <sjindel@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
…hots (excl. blobs)." This reverts commit ecbea5a. Reason for revert: broken with bare instructions and ABI bot Original change's description: > [vm/ffi] Implement FFI callbacks on AOT for ELF and Asm snapshots (excl. blobs). > > To do this, we add writable data sections (currently uninitialzed) to ELF and Asm snapshots > and allow Instructions to have patchable relocations against (the start of) these sections. > > Issue dart-lang#37295 (see also for design & discussion). > > Change-Id: If20bfa55776f4044aaa6bb8ea2101d2ada41842c > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-android-release-arm-try > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110221 > Commit-Queue: Samir Jindel <sjindel@google.com> > Reviewed-by: Martin Kustermann <kustermann@google.com> TBR=kustermann@google.com,rmacnak@google.com,alexmarkov@google.com,sjindel@google.com Change-Id: I9787da6d42575ca4f5ae0a698052a19ac4275afd No-Presubmit: true No-Tree-Checks: true No-Try: true Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-product-x64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-android-release-arm-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115240 Reviewed-by: Samir Jindel <sjindel@google.com> Commit-Queue: Samir Jindel <sjindel@google.com>
No description provided.
The text was updated successfully, but these errors were encountered: