Stream: git-wasmtime

Topic: wasmtime / issue #4536 cranelift-frontend: Reuse visited ...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 26 2022 at 23:11):

jameysharp commented on issue #4536:

Very cool!

If I'm not mis-reading things, Block does not need to be dropped (it's just a newtype for u32 and it doesn't implement Drop), so HashSet::clear is constant-time. In that case, how about just clearing the set before using it, where you're currently debug_asserting that it's empty, and removing all the magic drop-guard machinery?

view this post on Zulip Wasmtime GitHub notifications bot (Jul 26 2022 at 23:24):

jameysharp commented on issue #4536:

Also, can_optimize_var_lookup is only called from use_var_nonlocal, which has a &mut self. So you could change can_optimize_var_lookup to also take &mut self and then get rid of the RefCell.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 26 2022 at 23:24):

fitzgen commented on issue #4536:

Also, can_optimize_var_lookup is only called from use_var_nonlocal, which has a &mut self. So you could change can_optimize_var_lookup to also take &mut self and then get rid of the RefCell.

Nice, I didn't notice that!

view this post on Zulip Wasmtime GitHub notifications bot (Jul 26 2022 at 23:25):

fitzgen commented on issue #4536:

If I'm not mis-reading things, Block does not need to be dropped (it's just a newtype for u32 and it doesn't implement Drop), so HashSet::clear is constant-time. In that case, how about just clearing the set before using it, where you're currently debug_asserting that it's empty, and removing all the magic drop-guard machinery?

The idea was to empty the set as soon as it isn't used anymore, rather than at the last minute before use, but I guess there isn't really a good reason for that since it doesn't cut down on peak memory usage (which is kind of the whole point of this PR!)

view this post on Zulip Wasmtime GitHub notifications bot (Jul 26 2022 at 23:28):

jameysharp commented on issue #4536:

Yeah, rather than saying "clear is constant-time", I should have said that it doesn't do anything except mark the table as empty. So it doesn't matter when you do it, as long as nobody else looks at it.


Last updated: Nov 22 2024 at 16:03 UTC