-
Notifications
You must be signed in to change notification settings - Fork 67
Support for external Strings. #914
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
Comments
I've replied in the other issue.
Yes. However, there are two issues currently:
Cross linking related Dart SDK bug: We haven't done anything about this yet, because we're not aware of any use cases in which the copying is prohibitive. @modulovalue What is your use case? If you can get the |
Would it perhaps be an option to expose the ability to create external strings from within library dart.ffi
// ...
abstract class NativeApi {
// ...
external static String utf16String<T>(
Pointer<Uint16> storage,
int size,
T finalizationToken,
void Function(T) callback,
);
external static String latin1String<T>(
Pointer<Uint8> storage,
int size,
T finalizationToken,
void Function(T) callback,
);
// ...
}
// ... However, this might not be the best option because Ropes couldn't be optimally implemented with just a contiguous array of memory. (V8, for example, uses its version of Ropes and heuristics to achieve more performant strings on the web.)
I will try to do that.
There's quite a bit of context that would need to be considered around my use case. I'll try to collect it in one issue and present it as a coherent unit that way. (In short, I'd like to beat the Web in performance and memory overhead w.r.t. Strings, which |
I was delighted to find
Dart_NewExternalXString
indart_api.h
. My understanding is that these APIs allow Strings to be backed by native memory.I've tried using them from within Dart, but I can't manage to get the finalizer machinery to work. My attempt can be found here: dart-lang/sdk#50452.
I was wondering, have the maintainers of package:ffi considered to support e.g.
Dart_NewExternalUTF16String
for providing a view over native memory as a String?For my use cases I'd like to share native memory across isolates, and the ability to create Strings from native memory in some zero-cost way would make that much more practical by making it significantly more efficient.
The text was updated successfully, but these errors were encountered: