Skip to content
Sarah Lim edited this page Jun 1, 2018 · 1 revision

Getting internal functions and ring buffer size

10:37 AM 1. there is the custom "name" section that provides a name for each internal function, and is included in the wasm when compiling with debug info enabled
10:37 AM https://webassembly.github.io/spec/core/appendix/custom.html#name-section
10:38 AM 2. 1024 entries is probably fine for a first cut; but yeah making it customizable is best

Epilogue

To duplicate the return value and pass it into the logger:

tee_local $my_local
get_local $my_local
call $insert_return_value_into_ringbuffer
1:07 PM <slim> Sarah Lim for the epilogue proof of concept, the return value (if one exists) is going to be on the stack at the end of the function, right?
1:08 PM <fitzgen> Nick Fitzgerald correct
1:08 PM <slim> Sarah Lim for now could we just duplicate that value and make the `call` as the last 2 instructions before the `end`?
1:09 PM <fitzgen> Nick Fitzgerald exactly
1:11 PM <slim> Sarah Lim ok great -- what instruction should we actually be using to duplicate the value? I don't have a great model yet for translating between S-exps and the stack machine format
1:12 PM oh would we need to use `get_local`and also add a new local to the locals section?
1:12 PM <fitzgen> Nick Fitzgerald if you had your own local, you could use `tee_local $my_local` to copy the top of the stack into your local
1:12 PM I feel like there is a better instruction for duplicating the top of the stack though
1:12 PM let me check
1:15 PM hm, I think that is the only way
1:17 PM <slim> Sarah Lim ok, thanks!
1:23 PM <fitzgen> Nick Fitzgerald so I guess the whole sequence would be `tee_local $my_local; get_local $my_local; call $insert_return_value_into_ringbuffer`

Linking

10:48 AM <jimb> Can you define that data structure in a crate, compile the crate to wasm, and then use the linker to add that wasm to the existing binary? (I haven't used the wasm linker, so I'm not sure how this works.)
10:48 AM slim: ^
10:50 AM <slim> Sarah Lim @jimb 
10:51 AM oops, hit enter too soon -- sounds good
10:52 AM <jimb> slim: To see how rustc invokes the linker, this might work: https://www.reddit.com/r/rust/comments/3vpnkx/can_i_view_the_linker_command_that_rustc_invokes/
10:53 AM ⇐ pepyakin quit (textual@moz-nd873t.dip0.t-ipconnect.de) Quit: My MacBook has gone to sleep. ZZZzzz…
10:53 AM — jimb tries that, gets a double-screenful of output
10:54 AM <datapup> User I won't be able to make today's meeting unfortunately, but have fun everybody! there in spirit :)
10:55 AM <•fitzgen> Nick Fitzgerald jimb: slim: you will need to do some kind of magic linker flags to get rustc/lld to leave the relocations in the final compilation artifact, or else you won't be able to link in your data structure's wasm object
Clone this wiki locally