Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Interface Types and Isolation? #99

Open
kripken opened this issue Feb 28, 2020 · 3 comments
Open

Interface Types and Isolation? #99

kripken opened this issue Feb 28, 2020 · 3 comments

Comments

@kripken
Copy link
Member

kripken commented Feb 28, 2020

Is Interface Types an isolation mechanism, or an interfacing mechanism? @tlively and I were surprised to hear from @fgmccabe that a wasm module using IT should not be able to share its memory with other modules, which led to some discussion and now this issue.

An example of a concrete use case for sharing memory: Imagine a game engine that has some compiled script language code as well (e.g. the engine might be C++ and the script language could be C# or Python). It might be nice to link the compiled game engine and the compiled script code and hook them up using IT. But in this case we'd want to share large amounts of memory between them, for example a script plugin might render the game's UI, or generate audio samples. We would want to use IT to avoid the engine rolling its own string, array, etc. conversions and just use IT there, but we would not want to use it for everything. For large binary data we'd like to just share memory (and are willing to take the risks).

More generally, we would like to allow Interface Types to be used for some interactions between two modules while preserving the ability for those two modules to drop down to the current style of coordination for other interactions.

Thoughts?

@lukewagner
Copy link
Member

I think IT should allow modules to isolate themselves, but it's not clear that IT should require it by actively preventing modules from importing or exporting memory; that seems a bit paternalistic.

That being said, isolation seems especially valuable in the context of a scripting engine. And even when large buffers are at play, there is usually a copy happening somewhere (e.g., out of a JS typed array and into a WebGL resource), so it seems like one could often achieve isolation and efficiency by having the copy happen at the isolation boundary.

@jgravelle-google
Copy link
Contributor

One of the core advantages I can see Interface Types having is the ability to non-paternalistically add convenience+sanity to module boundaries. To that end, my intuition says we absolutely should allow exporting memory through IT.

I am starting to worry about what a world where people DO share memory via IT looks like. It sounds like "I want to use these foreign APIs that I don't know about, but everyone else should be fine accessing my ABI" in the worst case, which if everyone does that would be sub-good. Though the more likely case is "I want to use and publish convenient APIs, but for huge data structures direct access is too important to give up". Memory slices is probably how we solve that problem more-goodly, but raw memory can work as a stopgap.

Also we really can't prevent people from having the capability to mess around with memory if the module wants them to. If we disallow people from exporting memory directly, they can always export memory accessor functions that do the same things, only less efficiently. In general I don't think we'll be able to remove any core wasm capabilities, and we probably shouldn't try to.

@fgmccabe
Copy link
Contributor

fgmccabe commented Mar 13, 2020 via email

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

No branches or pull requests

4 participants