GithubHelp home page GithubHelp logo

Access memory used by module about wasmi HOT 6 CLOSED

NikVolf avatar NikVolf commented on May 14, 2024
Access memory used by module

from wasmi.

Comments (6)

pepyakin avatar pepyakin commented on May 14, 2024 1

i don't think any meaningful interaction with module is possible without sharing the linear memory

Why not? Consider some module that have a function that do some pure computation: e.g. some argument in and result out. This computation requires some memory in form of a stack in linear memory. The stack is transient: that is, stack pointer starts with zero at the start of the computation and ends with zero at the end of the computation.
So this is an example of meaningful interaction with a module that doesn't expose it's memory.

Second example: the module doesn't export a memory but provides an interface in form of exported functions, that user might use to set up some initial information and get results back. (In the end, your module doesn't have to have any memory at all and still might be able to do something useful)

But such kind of interaction might be inconvenient or not efficient or both. So for these kinds of problems we can provide this method default_memory(&self) → Option<MemoryRef>.

Why I'm calling this an escape hatch? Because it isn't required by the spec and this will certanly mean that some execution engines might not support this kind of interaction. And to not mislead users I want to clearly state that this is an escape hatch

from wasmi.

pepyakin avatar pepyakin commented on May 14, 2024

We can provide something like “default_memory(&self) → Option”

However, i think that we should document this is escape hatch, and the user might not find similar functionality in another execution engine

from wasmi.

NikVolf avatar NikVolf commented on May 14, 2024

why is it escape hatch?
i don't think any meaningful interaction with module is possible without sharing the linear memory, and compilers are not obliged to produce module with exported memory

from wasmi.

NikVolf avatar NikVolf commented on May 14, 2024

on the second thought, i realized that js api indeed provides no way to interact with such internal memory

from wasmi.

pepyakin avatar pepyakin commented on May 14, 2024

i realized that js api indeed provides no way to interact with such internal memory

Good point!

from wasmi.

pepyakin avatar pepyakin commented on May 14, 2024

Closing tilll the spec come up with the official way to do this, at least in JS.

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.