bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly
https://wasmtime.dev/
Apache License 2.0
15.1k stars 1.26k forks source link

Eagerly cast pointers in aarch64 relocation code to `usize` to avoid `unsafe` blocks in cranelift-jit #7588

Open elliottt opened 9 months ago

elliottt commented 9 months ago

When performing relocations in cranelift-jit, there are many introductions of a variable what that's defined as an unsafe pointer offset. These variables are almost always cast to usize or isize before they're used, so perhaps we should instead turn the base pointer into its target numeric type eagerly, to avoid needing the unsafe blocks for calling the offset method on the pointers.

https://github.com/bytecodealliance/wasmtime/blob/cd97c9f14713d81de5453fb9861319e78a761432/cranelift/jit/src/compiled_blob.rs#L55-L57

bjorn3 commented 9 months ago

Using wrapping_offset it also an option. On CHERI you would need to use the current code to preserve the pointer capability I think, but we don't support CHERI yet anyway.

sudoHackIn commented 4 days ago

Hi, @elliottt @bjorn3,is this issue is still actual? Unfortunately from glaziermag's pr and this comment (https://github.com/bytecodealliance/wasmtime/pull/8041#discussion_r1509922915) i cannot understand, whether pr is not correct, or bjorn3 decided that any modification(about this issue) doesn't make sense at all