Would it be better to
load.r64
and store.r64
and fill_nop.r64
etc, orraw_bitcast
from r64
to i64
and then use that bitcast'd value as the pointer for subsequent loads/stores?Using raw_bitcast
is leading to errors like "error: inst13: v13 is a real GPR value defined by a ghost instruction", while adding encodings seems like it touches a lot more stuff. I haven't got either approach working yet. I'm also a little wary that approach (2) might mess up stack maps generation.
Any suggestions as to which is the better approach?
cc @Dan Gohman @Benjamin Bouvier
When we do a load or store, do we keep track of the memory location for stackmaps?
@Dan Gohman can you clarify a bit more? do you mean do we insert safepoints for loads/stores?
When we do a store, do we remember the memory location as a root that a GC would want to scan from?
the way that stack maps work is we ask the register allocator which variables are live after a safepoint, and filter that set for values which are reference types. If the r64
is not used again after the bitcast
, the register allocator will presumably believe it to be dead, and we won't include it in stack maps. The results of the bitcast will never be included in stack maps.
this is making me think that adding load.r64
etc encodings is the most promising course of action
Yeah. Also, we use these load.64
and store.64
for accessing wasm tables, right?
and in the future, GC struct fields and so on
yeah, that's what I am using them for now
where Cranelift itself isn't in charge of identifying the roots; the roots come from the wasm runtime which knows where all the tables are
implementing the inline fast path for table.get
and table.set
From the POV of embeddings like SpiderMonkey, they should definitely be separate instructions, I think -- a store of a GC'd pointer sometimes involves other logic (adding to a write buffer during incremental GC in progress, etc) so we want to be able to distinguish that from an i64
yeah, so then adding encodings for load.64
and store.r64
makes sense to me.
@Dan Gohman great, thanks!
@Chris Fallin I have barriers here as well, I am expanding them inline in FuncEnvironment::translate_table_{get,set}
. This should work well until sometime in the (fairly distant) future when we want to do barrier coalescing. See https://github.com/bytecodealliance/wasmtime/issues/1146#issuecomment-566790342 for details on the design space of when/where we handle barriers.
oh neat, I'll go do my homework -- thanks :-)
(sorry, wasn't trying to be trite, I just did a Whole Write Up on that subject and might as well link it rather than poorly reproduce it here :-p )
No worries, happy to see all of this thought out already; thanks for the pointer!
ok, these changes are part of https://github.com/bytecodealliance/wasmtime/pull/1923 and I've flagged you, @Dan Gohman, for review (feel free to redirect, if someone else makes more sense)
@Chris Fallin if by chance you're interested in what the GC barrier implementation looks like, they're in that PR too (inside the func_environ.rs
file)
Is this PR branched off of the wiggle integration PR? It looks like there are a lot of unrelated commits
I think I may have messed that up by accident, a rebase should make those go away
Yeah, just the last commit is relevant. I’ll rebase when I’m done with lunch
Last updated: Nov 22 2024 at 16:03 UTC