Comments (4)
Right, you can think of the function instance as implicitly closing over its module instance. As another example:
(module $A
;; This memory is not exported.
(memory $M 1)
;; This function is exported, and always accesses memory $M.
(func (export "f")
...
i32.load ;; This loads implicitly from memory $M
...
)
)
This module only defines one export, the function f
. When you call this function, it will always use its module's own memory, regardless of who calls it.
from multi-memory.
Awesome, thanks for the clarification!
from multi-memory.
But suppose same function was then exported and then imported into a separate module; is it expected that the this function would still be bound to this same memindex in the new module?
It would be bound to the memory with the same memory address in the store. The memory index is local to the module. You can already see this behavior with functions and globals:
(module $A
(func (export "f0") ...) ;; func 0 in module $A
(func (export "f1" ...) ;; func 1 in module $A
(global (export "g0") ...) ;; global 0 in module $A
(global (export "g1") ...) ;; global 1 in module $A
)
(module $B
(import "A" "f1" (func ...)) ;; func 0 in module $B
(import "A" "f0" (func ...)) ;; func 1 in module $B
(import "A" "g1" (global ...)) ;; global 0 in module $B
(import "A" "g0" (global ...)) ;; global 1 in module $B
(func $test
...
call 0 ;; calls $A.f1
)
)
from multi-memory.
Ah, thanks for the response! So just to clarify, if function F, defined in module A had a load instruction that read from some offset of memory M of the same module, then if F were imported into module B, that load instruction would still read from memory M, even if M was not imported into B, correct?
from multi-memory.
Related Issues (20)
- Text format for data segments may be confusing with passive data segments HOT 2
- Read only memories? HOT 11
- Binary format is out of date HOT 3
- How is a non-default memory index to be denoted in the text format? HOT 3
- Text syntax for SIMD lane index vs memory index operands HOT 1
- Possibility to dynamically add memories at runtime? HOT 2
- Overlap with recent issue raised on the main WASM design repo HOT 5
- Contradiction in multi-memory binary format instruction rules HOT 3
- A question about high level language interaction HOT 7
- Referencing locations across memories HOT 10
- Text format: parsing `v128.loadX_lane` and `v128.storeX_lane` requires backtracking HOT 6
- Multi-Memory Lowering & Memory Imports HOT 1
- Use-case for multi-memory: Flutter Web Engine linking with wasm-compiled skia (C++) and ICU4X (Rust) HOT 5
- Use-case for multi-memory: dart2wasm to implement ByteBuffer/TypedList objects with linear memory HOT 8
- Use-case for multi-memory: Component Model object transfer browser polyfill HOT 2
- Additional test cases for multi-memory HOT 3
- Use-case for multi-memory: Less overhead tracking of store calls to facilitate networked rollback HOT 1
- Use case for multi-memory: Sharing persistent datastructures between threads
- Toolchain support for multiple memories HOT 22
- Implementation support HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multi-memory.