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

How to polkavm_import/export with non-numeric types? #110

Open
xlc opened this issue May 1, 2024 · 5 comments
Open

How to polkavm_import/export with non-numeric types? #110

xlc opened this issue May 1, 2024 · 5 comments

Comments

@xlc
Copy link

xlc commented May 1, 2024

Looks like currently only a few numeric types are supported and the ABI is simply pass the arguments via register. This means we can only pass small arguments by value.
How can we pass large objects? Or a string or just bunch of bytes?

@koute
Copy link
Collaborator

koute commented May 1, 2024

You can pass a pointer to a preallocated chunk of memory and then have the host function write to it. Alternatively if the size of the data is not known you could do it in two steps - first query the host how much memory is needed, have the guest allocate it, and then have the host write to it.

On the guest side there's the derive macro which can be used to define custom marshaling strategies for custom types (e.g. see here for an example.)

@xlc
Copy link
Author

xlc commented May 1, 2024

thanks. will give it a play and see if I can something working

@xlc
Copy link
Author

xlc commented May 1, 2024

any plan to update polkavm_import/export macro to support advanced argument passing? or it will stick with registers and then in that case we need another library to abstract the argument marshalling work

@koute
Copy link
Collaborator

koute commented May 1, 2024

Depends on what exactly you mean by "advanced argument passing", but in general at least in the short term I'm not planing on expanding its capabilities beyond the basics and concentrate on making the fundamentals really solid.

@nazar-pc
Copy link

Probably a duplicate of #108

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants