-
Notifications
You must be signed in to change notification settings - Fork 6k
[fuchsia] [ffi] Basic support for Channels and Handles #27849
[fuchsia] [ffi] Basic support for Channels and Handles #27849
Conversation
bdebe56
to
0be0100
Compare
Tested in fxr/565162 |
f506671
to
e57aff3
Compare
#include "include/dart_api_dl.h" | ||
|
||
int zircon_dart_dl_initialize(void* initialize_api_dl_data) { | ||
if (Dart_InitializeApiDL(initialize_api_dl_data) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we gonna expose this through the embedder C API? The version of dart used and access to the dart VM is hidden behind the embedder C API....
It works for now with the code in-engine-tree, but how will we guarantee that it will continue to work when we are consuming only embedder.h & libflutter.so? What happens if the dart API versions of the embedder and engine diverge? Does the Dart API also present a stable ABI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the engine and embedding use diverging versions of dart we will also have AOT considerations to worry about. I think in the short-medium term we will be using the same version for both fuchsia-embedding and the engine. When we decide to allow divergence of dart versions, we can likely piggyback on the same solution as AOT to resolve this.
Also Dart_InitializeApiDL
is currently only checking for a min version of dart. I think the dart_api_dl.h
does give us a stable ABI, but I will confirm can report back to you.
|
||
bool close() { | ||
if (isValid()) { | ||
int? ret = zirconFFIBindings?.zircon_dart_handle_close(_ptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's assert(isValid()) here, then do the if check. 99% of the time, isValid() being false here indicates a coding error in the dart application
This is the behavior that the existing implementation has (DCHECK on handle validity, then proceed forward with an if)
@pragma('vm:entry-point') | ||
ZDChannel._(this.handlePair); | ||
|
||
final ZDHandlePair handlePair; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why keep both ends of the channel-pair inside of one object? Conceptually, a channel represents only one half of the pair, and very often dart code will only possess one half with no ability to refer to the other half
The old implementation has a shim object called "ChannelPair" to handle this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after adding the assert(isValid())
// ZIRCON_FFI_EXPORT zircon_dart_handle_t* zircon_dart_duplicate_handle( | ||
// zircon_dart_handle_t* handle, | ||
// uint32_t rights); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to leave this in?
This looks good to go. Can we commit this? |
This PR also adds FFI variants of Handle and HandlePair with finalizers.
c4fe774
to
46dbb00
Compare
Add basic channel support for
dart:zircon
usingdart:ffi
.