Stream: git-wasmtime

Topic: wasmtime / issue #8912 What is the equivalent of WAMR's ...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2024 at 16:25):

asibahi opened issue #8912:

Hello

This is a question, not an issue/problem.

I have been trying to reimplement HarfBuzz's wasm shaper in rustybuzz, using Wasmtime here. HarfBuzz uses wasm-micro-runtime (WAMR) and makes heavy use of wasm_runtime_module_dup_data to pass in buffers.

I know how to write memory into an arbitrary location in the machine's memory. What I can't figure out is how to choose an appropriate place to write in the buffer.

What I am currently doing is growing the memory, and write there. However, many of the buffers are much, much smaller than a page, and surely this isn't sustainable.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2024 at 16:36):

alexcrichton commented on issue #8912:

Generally the way that you get a pointer to write to within a guest module is to somehow call malloc. In the modules you're working with is a malloc-like symbol exposed to invoke to get a pointer into linear memory of where to write?

One point to note, however, is that you'll want to be sure that the guest module is aware that it's receiving allocated memory from the host so it knows to deallocate it when it's done with it.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2024 at 16:48):

asibahi commented on issue #8912:

Yeah HarfBuzz's example modules do not export a malloc at all. Looking at wasm_runtime_module_dup_data it seems to do some logic that bypasses that, but I am illiterate at C++.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2024 at 16:51):

asibahi edited a comment on issue #8912:

Yeah HarfBuzz's example modules do not export a malloc at all. Looking at wasm_runtime_module_dup_data it seems to do some logic that bypasses that, but I am illiterate at C++.

The pattern throughout the API is as follow: there is a struct defined with a pointer field. say struct Blob { length: u32, data:u32 } and the imported function is called with blob: *mut Blob parameter. Then I, as the host, am supposed to pass in a pointer to the array of data, or binary data, in the data field.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2024 at 18:20):

asibahi closed issue #8912:

Hello

This is a question, not an issue/problem.

I have been trying to reimplement HarfBuzz's wasm shaper in rustybuzz, using Wasmtime here. HarfBuzz uses wasm-micro-runtime (WAMR) and makes heavy use of wasm_runtime_module_dup_data to pass in buffers.

I know how to write memory into an arbitrary location in the machine's memory. What I can't figure out is how to choose an appropriate place to write in the buffer.

What I am currently doing is growing the memory, and write there. However, many of the buffers are much, much smaller than a page, and surely this isn't sustainable.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2024 at 18:50):

alexcrichton commented on issue #8912:

AFAIK whatever wasm_runtime_module_dup_data is doing (I haven't read it myself) is probably non-standard and specific to WAMR. It can likely be done with Wasmtime APIs but that would require understanding what WAMR is doing which would likely require reading the internal implementation details as this is something that's probably not documented.


Last updated: Oct 23 2024 at 20:03 UTC