Stream: wasmtime

Topic: externref stack maps


view this post on Zulip Alex Crichton (Jun 12 2020 at 18:19):

@fitzgen (he/him) question before I get much further, there's a comment about wasm code reading the next field of the activations table

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:19):

is that still used?

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:19):

I can't actually find where wasm reads the next field

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:20):

this will happen in future PRs, as I implement table.get and all that. currently it is not yet used by Wasm

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:20):

hm...

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:20):

so you'd basically inline the fast path in jit code?

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:25):

exactly, and only call out to host code when next == end

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:32):

@fitzgen (he/him) why is the stack map registry stored in the VMContext?

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:33):

or rather, do you have a future intention in the jit to read that?

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:44):

no intentions for the JIT to read the registry -- but it is needed for GC, and that means wasmtime-runtime needs a way to get it from inside a libcall, and hanging it off the VMContext is the easiest way to do that

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:44):

@Alex Crichton

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:44):

ah ok

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:44):

I'm personally less of a fan than others I think about making code future-proof

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:45):

I would personally just go ahead and drop it from this PR if it's not needed yet, saving it for later when it's needed

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:45):

I'm always afraid that the actual feature would look different than a pre-implementation b/c requirements change over time or something like that

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:45):

minor point though

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:46):

when next == end, we need to do a libcall to insert the reference into the table, which will basically do:

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:46):

I'm p sure of the requirement in this case

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:47):

oh sorry yeah next/end make sense

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:47):

but the registry for GC far in the future is what I mean

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:47):

next/end is like "the next PR needs this" which is fine

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:47):

but afaik we don't even have plans yet for GC in the future

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:48):

when I say "gc" I mean the wasmtime_runtime::gc function that is in the PR now

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:48):

not the wasm GC proposal

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:48):

oh wait it's actually used?

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:48):

I think I missed where it was used?

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:49):

table.get of a reference type will have a fast path where it can bump into the table if it isn't full, but if next == end, then the current chunk is full, so it will call out to host code via a libcall, that will do gc(); infallible_insert_into_table() as described above

this isn't in the current PR, but coming in the next PR

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:50):

does that make sense?

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:50):

er sorry I'm not talking about next/end

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:50):

lemme get a link

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:51):

in order to do gc(); infallible_insert_into_table() we need the stack map registry

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:51):

because the gc function takes it as a parameter

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:51):

hence, we hang the stack map registry off the vmctx

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:51):

aha I see

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:52):

does that clear it up for you?

view this post on Zulip Alex Crichton (Jun 12 2020 at 18:52):

yeah thanks

view this post on Zulip fitzgen (he/him) (Jun 12 2020 at 18:52):

np! thanks for review!


Last updated: Nov 22 2024 at 16:03 UTC