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 useswasm-micro-runtime
(WAMR) and makes heavy use ofwasm_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.
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.
asibahi commented on issue #8912:
Yeah HarfBuzz's example modules do not export a
malloc
at all. Looking atwasm_runtime_module_dup_data
it seems to do some logic that bypasses that, but I am illiterate at C++.
asibahi edited a comment on issue #8912:
Yeah HarfBuzz's example modules do not export a
malloc
at all. Looking atwasm_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. saystruct Blob { length: u32, data:u32 }
and the imported function is called withblob: *mut Blob
parameter. Then I, as the host, am supposed to pass in a pointer to the array of data, or binary data, in thedata
field.
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 useswasm-micro-runtime
(WAMR) and makes heavy use ofwasm_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.
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: Dec 23 2024 at 12:05 UTC