Giter Site home page Giter Site logo

Comments (2)

dshiell15 avatar dshiell15 commented on June 20, 2024 1

Excellent, thank you! - got a little too hung up on the other approach...

from lucet.

acfoltzer avatar acfoltzer commented on June 20, 2024

@dshiell15 we don't currently recommend calling back into Wasm from hostcalls. The memory management strategy I'd recommend is to have the guest provide the host with a pointer to a pre-allocated buffer that the host can copy results into. This of course means having to get the buffer size right, but we have had good results with the following approach:

  1. Return a status/error code from the hostcall so that you can identify when the write succeeds or fails.
  2. Use an nwritten output parameter in the hostcall so the host can return to the guest how many bytes were written by a successful copy.
  3. When the hostcall fails because the guest-provided buffer is not large enough, write the number of bytes that are necessary to an output parameter (you can reuse nwritten as the guest checks for the error case).
  4. Allocate a new buffer of the required size in the guest, and call the hostcall again.

from lucet.

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.