Stream: git-wasmtime

Topic: wasmtime / issue #6716 Support specifying stack slot alig...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 12 2023 at 19:18):

bjorn3 opened issue #6716:

Feature

See title.

Benefit

Correct alignment are necessary to avoid crashes on some architectures and code may depend on correct alignment. In addition rustc checks that the right alignment is used when dereferencing a raw pointer in debug mode. This breaks rayon which allocates a stack value with cacheline alignment and then takes a raw pointer which it later dereferences. See https://github.com/bjorn3/rustc_codegen_cranelift/issues/1381.

Implementation

Sort stackslots by alignment for better packing and then add padding as necessary and if the alignment of a stack slot exceeds the ABI stack alignment realign the stack at runtime.

Alternatives

Doing dynamic alignment at runtime in the cranelift ir producer. This is slower and has higher stack usage overhead.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 12 2023 at 19:19):

bjorn3 commented on issue #6716:

Also necessary to fix https://github.com/bjorn3/rustc_codegen_cranelift/issues/1258.

view this post on Zulip Wasmtime GitHub notifications bot (May 16 2024 at 17:02):

cfallin closed issue #6716:

Feature

See title.

Benefit

Correct alignment are necessary to avoid crashes on some architectures and code may depend on correct alignment. In addition rustc checks that the right alignment is used when dereferencing a raw pointer in debug mode. This breaks rayon which allocates a stack value with cacheline alignment and then takes a raw pointer which it later dereferences. See https://github.com/bjorn3/rustc_codegen_cranelift/issues/1381.

Implementation

Sort stackslots by alignment for better packing and then add padding as necessary and if the alignment of a stack slot exceeds the ABI stack alignment realign the stack at runtime.

Alternatives

Doing dynamic alignment at runtime in the cranelift ir producer. This is slower and has higher stack usage overhead.

view this post on Zulip Wasmtime GitHub notifications bot (May 16 2024 at 19:51):

bjorn3 commented on issue #6716:

Would you mind reopening this? It hasn't been fully resolved yet: https://github.com/bytecodealliance/wasmtime/pull/8635/files#r1603954465

view this post on Zulip Wasmtime GitHub notifications bot (May 16 2024 at 21:15):

cfallin reopened issue #6716:

Feature

See title.

Benefit

Correct alignment are necessary to avoid crashes on some architectures and code may depend on correct alignment. In addition rustc checks that the right alignment is used when dereferencing a raw pointer in debug mode. This breaks rayon which allocates a stack value with cacheline alignment and then takes a raw pointer which it later dereferences. See https://github.com/bjorn3/rustc_codegen_cranelift/issues/1381.

Implementation

Sort stackslots by alignment for better packing and then add padding as necessary and if the alignment of a stack slot exceeds the ABI stack alignment realign the stack at runtime.

Alternatives

Doing dynamic alignment at runtime in the cranelift ir producer. This is slower and has higher stack usage overhead.

view this post on Zulip Wasmtime GitHub notifications bot (May 16 2024 at 21:15):

cfallin commented on issue #6716:

Sure; to summarize here, the issue is that alignment is now correct with respect to the start of stack frame, but start of stack frame is only aligned as per ABI (e.g. 16 bytes on x86-64 and aarch64) so we need to dynamically align SP (it must be dynamic).

view this post on Zulip Wasmtime GitHub notifications bot (May 16 2024 at 21:15):

cfallin edited a comment on issue #6716:

Sure; to summarize here, the issue is that alignment is now correct with respect to the start of stack frame, but start of stack frame is only aligned as per ABI (e.g. 16 bytes on x86-64 and aarch64) so we need to dynamically align SP (it must be dynamic, we can't know statically anything more than the ABI guarantee).


Last updated: Dec 23 2024 at 12:05 UTC