[Interface Types] Avoid memory copy #88
Description
Hi all,
Seems like from proposal of interface type I've understood that adapter functions would copy types from one abi to another abi ?
If so than it can hit performance, consider case of one million elements in some data type ...
... and I would suggest the better approach ...
What if instead of coping we will use just interface like in Java, C#, C++ (abstract type) or Rust (traits) ?
Lets imagine that list (vector or some other type in language) will be presented through the bunch on functions, it will provide additional wrapper functions that should be called instead of native api of some language
Lets consider List ...
In the following language it has the following types:
- C++ -> std::vector<>
- Rust -> std::Vec<>
- Swift -> std::Vec<>
From all this types we can see common semantic and instead of coping types between platforms lets add additional functions ...
I think will be better if these functions will be just interface and provide mechanism of reading and writing data in native abi of the wasm module
For List we can add the following common api:
- T * data() (pointer to a data)
- size() (size that is stored by this pointer)
- insert(T) (or add)
- delete(T) (or remove)
This approach will increase overall performance, because it does not require coping data between languages abi, but just provides mechanism of accessing data from native abi
I wrote this idea to @linclark at twitter, but seems like she has lots of messages and she did not see mine, that is why I decided to write here ;)