Skip to content
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] Add _nativeEffect top-level function #45607

Closed
dcharkes opened this issue Apr 7, 2021 · 0 comments
Closed

[vm] Add _nativeEffect top-level function #45607

dcharkes opened this issue Apr 7, 2021 · 0 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@dcharkes
Copy link
Contributor

dcharkes commented Apr 7, 2021

We should add a _nativeEffect top-level function which can be used to describe the effects of native calls in Dart code as one of its arguments. This enables us to describe arbitrary side-effects as long as they are expressible in Dart code, rather than for every new type of side effect introducing a new pragma.

This _nativeEffect should then be compiled to nothing in the backends, or be removed as the last step of the CFE.

Currently, we do without _nativeEffect, this does not express intent well. For example:

let #keepConstructorAlive = MyStruct.#fromTypedDataBase(Int8List(1)) in
dynamicLibrary.lookupFunction<MyStruct Function(), MyStruct Function()>('foo');

With _nativeEffect the intent is explicit:

let #keepConstructorAlive = _nativeEffect(MyStruct.#fromTypedDataBase(Int8List(1))) in
dynamicLibrary.lookupFunction<MyStruct Function(), MyStruct Function()>('foo');

Background internal doc: go/dart-ffi-struct-treeshaking

@dcharkes dcharkes added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

1 participant