Coder Social home page Coder Social logo

Thoughts on js-promise-integration about wasmi HOT 4 CLOSED

tommie avatar tommie commented on July 28, 2024
Thoughts on js-promise-integration

from wasmi.

Comments (4)

Robbepop avatar Robbepop commented on July 28, 2024 1

Context This would solve a headache I have (currently using wasm3): I want an event main loop, but once I start WASM, it has to do everything blocking, unless I make the WASM code async. Since WASM is already interpreted and should be trivially re-entrant, it seems the interpreter could do more to help me "get out" again while waiting for I/O. (Running on the second core of RP2040.)

It should be possible to solve this headache with Wasmi's resumable function calls:
https://docs.rs/wasmi/0.32.1/wasmi/struct.Func.html#method.call_resumable

When using Wasmi's resumable functions, errors returned from called host functions will yield back the execution and also make it possible for the host side to resolve the error and resume the call afterwards. So whenever your host functions would perform I/O tasks you could instead return a host error that stores all the needed information about the I/O operation. Then Wasmi would yield control back to the host side where the async I/O operation could be performed just to resume the Wasm execution via Wasmi, finally.

This is how smoldot solves a very similar use case. (https://github.com/smol-dot/smoldot/blob/main/lib/src/executor/vm/interpreter.rs)

Some people believe that resumable calls are a more powerful concept than async calls.

from wasmi.

tommie avatar tommie commented on July 28, 2024 1

Aight. Thanks.

from wasmi.

tommie avatar tommie commented on July 28, 2024

Thank you, that sounds great.

I could make a PR for the README to include the proposal and suggest resumables, if you'd like.

from wasmi.

Robbepop avatar Robbepop commented on July 28, 2024

Thank you, that sounds great.

I could make a PR for the README to include the proposal and suggest resumables, if you'd like.

A write-up is probably welcome, though I would prefer to have a discussion item for it in our Wasmi discussions GitHub forums. So we can simply refer people to the write-up. :)

Can we close this issue now? :)

from wasmi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.