Comments (7)
is non-default memory supposed to be accessible from languages like C at all?
No, not without a language extension to add some notion of new address spaces with incompatible pointers. It's possible that we will have such language extensions in clang in the future, but probably not soon.
Other existing languages are in similar situations, although brand new languages could try to account for the possibility of having multiple memories in their core design.
is this feature mainly for offline tools which rewrite instructions?
Exactly. Multi-memory will be useful for code instrumentation and for merging multiple modules into one.
from multi-memory.
is non-default memory supposed to be accessible from languages like C at all?
as memory index is encoded as an immediate, it doesn't seem straightforward to implement "far" pointers which can access those memories.
There are languages that supports address spaces, OpenCL for example, and they should be able to handle memory indices without fat pointers.
from multi-memory.
is non-default memory supposed to be accessible from languages like C at all?
No, not without a language extension to add some notion of new address spaces with incompatible pointers. It's possible that we will have such language extensions in clang in the future, but probably not soon.
Other existing languages are in similar situations, although brand new languages could try to account for the possibility of having multiple memories in their core design.
is this feature mainly for offline tools which rewrite instructions?
Exactly. Multi-memory will be useful for code instrumentation and for merging multiple modules into one.
ok. thank you for explanation.
from multi-memory.
is non-default memory supposed to be accessible from languages like C at all?
as memory index is encoded as an immediate, it doesn't seem straightforward to implement "far" pointers which can access those memories.There are languages that supports address spaces, OpenCL for example, and they should be able to handle memory indices without fat pointers.
interesting.
do you mean this stuff? https://en.wikipedia.org/wiki/OpenCL#Memory_hierarchy
from multi-memory.
The best option so far would be the fancy pointers in C++ allocators (which was supposed to be to support near/far) wasm::ptr<T, uint memidx=0>
however you will need to create specific specializations for nearly everything because most of the std lib assumes that those can be converted to a raw dereferenceable pointer which is the entire issue with the index being an immediate of the instruction.
Unless you implement the deref of a "far" pointer when multiple memories are present through a switch. Same with all other memory ops taking that memory index as an immediate. And then you are hoping that the compiler and/or the implementation can inline and constant fold the memory index and pick the correct intrinsic.
from multi-memory.
Sorry, I missed the notification somehow.
do you mean this stuff? https://en.wikipedia.org/wiki/OpenCL#Memory_hierarchy
Yes, that is what I meant. LLVM supports this via addrspace annotation which works similarly to memindex in this proposal: 0 is the default, and there are no assigned meaning to other ones. It should be possible to lower those annotations to mulit-memory. OpenCL doesn't have to be the source language, especially given what it is meant to be used for, it just has a very similar model built into it.
fancy pointers in C++ allocators (which was supposed to be to support near/far)
wasm::ptr<T, uint memidx=0>
This actually sounds like a good option. The problem, as pointed out, is referencing locations across memories. It is a useful feature, as it would eliminate duplicating code for the sake of targeting a different memory. OpenCL also considered that and has 'generic' (address space agnostic) pointer since version 2.0.
Filed #32 for cross-memory references.
from multi-memory.
Closing this as answered.
from multi-memory.
Related Issues (20)
- 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
- 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
- JS-API limits test still tests for limit of 1 memory
- Tracking Phase 4 Requirements HOT 8
- Is there a way to access a non-hardcoded memory? HOT 2
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.