Stream: git-wasmtime

Topic: wasmtime / issue #1453 Rejiggering the CodeSinks for Spid...


view this post on Zulip Wasmtime GitHub notifications bot (May 04 2022 at 22:39):

cfallin commented on issue #1453:

I'm doing some gardening on old issues and I think the above may not be as relevant anymore: we've removed some of the old-backend-isms from the emission and sink design, IIRC. Updated suggestions based on the current state of our implementation are certainly welcome! In the meantime I will go ahead and close this issue.

view this post on Zulip Wasmtime GitHub notifications bot (May 04 2022 at 22:39):

cfallin closed issue #1453:

Cranelift is used in Spidermonkey, as part of an integration called Baldrdash. In Baldrdash, we're currently barely using the RelocSink capabilities, because the information it provides us is incomplete:

  1. when tracking call relocations, we'd need to get the source loc information. This is useful for stack frame iteration, e.g. displaying the wasm bytecode offset in stack traces, when an error occurs.
  2. indirect calls don't have relocations, but Spidermonkey needs to track the call site during stack frame iteration, again (the return address is used as a key for a mapping from call sites to call metadata, including the wasm bytecode offset).
  3. stack maps in Spidermonkey are keyed by the address of the instruction following the instruction to which the stack map relates. This is because when we want to get a stack map for a call/software interrupt, we're usually in the middle of stack frame iteration, and we only have access to the return address for calls, or the address of the next value of PC for software interrupts. Currently, the StackMapSink doesn't offer the information of the next instruction's address, so we have to do something very manual for this (iterate over every instruction, if it's a safepoint remember it for the next instruction, if there was a remembered safepoint add the stackmap with the instruction+size offset to the list of stackmaps). An example may help understanding here:
; Cranelift IR
   safepoint
   call $0; for instance
   iadd
; Machine code
   ; safepoint generates nothing
   call {reloc}
   iadd ; effectively the return address of the above call, so the address we have access to when looking up a stack map for the call during stack frame iteration.

For the new backend integration, we won't be able to do this anymore, for several reasons:

My proposal is the following:

Alternatives I've considered:

I will implement my proposal locally, but I'd be happy to read what people think of it!


Last updated: Nov 22 2024 at 16:03 UTC