Skip to content

Host Functions #287

@ubiquitous-dev

Description

@ubiquitous-dev

What is your question?

How can I call a host (imported) function from within a javascript application compiled with javy?

Details

First of all, great work on Javy! It's really awesome what ya'll are building.

Pulling out the quickjs runtime into a separate dynamic module is a great idea. It's a lot of overhead to ship an entire interpreter or runtime with every wasm program when it's going to be the same code every time (other than the user's code).

One thing I'm not clear on with Javy is how to call host (imported) functions. I believe calling code outside of the WASM module is already being done via the dynamic linker, but it seems to be calling wasm <=> wasm, rather than from wasm => host.

For example, if I am running wasmtime embedded within a Go application - how can I have the javascript code running inside the quickjs runtime (with or without dynamic linking) invoke a Go method and get the response back into the javascript execution environment?

I believe WASI is implemented basically the same as host functions, but the signature of WASI is known ahead-of-time, so I'm guessing that WASI's structure is hardcoded into the javy compiler, as are the function signatures used for the runtime linking. Is that right, and if so, is there a way to build the code so that it relies on an import that doesn't exist during compile time, but only during execution time?

Thanks in advance, and great work on Javy!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions