Stream: cranelift

Topic: What happens to unused block indices?


view this post on Zulip osa1 (May 24 2020 at 09:17):

If I create a block but don't use it, or it becomes unused later (maybe some optimization merges blocks), what happens to the actual block? Is it ever "collected"? I think not, as otherwise mapping a Block to the actual block details won't be as easy (an array indexing).

view this post on Zulip bjorn3 (May 24 2020 at 10:08):

The Block itself (aka the index) is not reused. Optimizations can remove the block itself from the layout though, in which case there all instructions are removed from it.

view this post on Zulip osa1 (May 24 2020 at 10:09):

OK so in the vector that maps Blocks (indices) to the actual Block data, the slot for the block is left unused?

view this post on Zulip bjorn3 (May 24 2020 at 10:12):

Yes. The Layout struct is defined in https://github.com/bytecodealliance/wasmtime/blob/51f9ac2150bd880dc7b92952ba92e72ea3ab60b7/cranelift/codegen/src/ir/layout.rs by the way.

Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime

view this post on Zulip osa1 (May 24 2020 at 10:14):

Thanks for the link, really helpful.

view this post on Zulip osa1 (May 24 2020 at 10:17):

I'm curious, is this ever a problem in practice? That is, the unused slots in secondary maps every become large enough to be problematic?

view this post on Zulip bjorn3 (May 24 2020 at 10:18):

Probably not in the common case. Cranelift is made to compile one function at a time, so peak memory usage is relatively small compared to for example LLVM anyway.


Last updated: Nov 22 2024 at 16:03 UTC