[vm/ffi] added docs regarding isLeaf parameter in ffi
Fixes https://github.com/dart-lang/sdk/issues/50160
Change-Id: I1c100260f1ff55645ca0e5de56a65d815c30c6f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269000
Reviewed-by: Hossein Yousefi <yousefi@google.com>
Auto-Submit: Hossein Yousefi <yousefi@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Hossein Yousefi <yousefi@google.com>
diff --git a/sdk/lib/ffi/dynamic_library.dart b/sdk/lib/ffi/dynamic_library.dart
index 5009ab6..e31b2d7 100644
--- a/sdk/lib/ffi/dynamic_library.dart
+++ b/sdk/lib/ffi/dynamic_library.dart
@@ -68,6 +68,11 @@
/// Looks up a native function and returns it as a Dart function.
///
/// [T] is the C function signature, and [F] is the Dart function signature.
+ ///
+ /// [isLeaf] specifies whether the function is a leaf function.
+ /// A leaf function must not run Dart code or call back into the Dart VM.
+ /// Leaf calls are faster than non-leaf calls.
+ ///
/// For example:
///
/// ```c
diff --git a/sdk/lib/ffi/ffi.dart b/sdk/lib/ffi/ffi.dart
index 2668e71..98a7909 100644
--- a/sdk/lib/ffi/ffi.dart
+++ b/sdk/lib/ffi/ffi.dart
@@ -155,6 +155,10 @@
on Pointer<NativeFunction<NF>> {
/// Convert to Dart function, automatically marshalling the arguments
/// and return value.
+ ///
+ /// [isLeaf] specifies whether the function is a leaf function.
+ /// A leaf function must not run Dart code or call back into the Dart VM.
+ /// Leaf calls are faster than non-leaf calls.
external DF asFunction<@DartRepresentationOf('NF') DF extends Function>(
{bool isLeaf = false});
}
@@ -876,7 +880,13 @@
@Since('2.14')
class FfiNative<T> {
final String nativeName;
+
+ /// Specifies whether the function is a leaf function.
+ ///
+ /// A leaf function must not run Dart code or call back into the Dart VM.
+ /// Leaf calls are faster than non-leaf calls.
final bool isLeaf;
+
const FfiNative(this.nativeName, {this.isLeaf = false});
}