Open Bug 1765346 Opened 2 years ago Updated 2 years ago

Consider removing alignas(8) from JS::Value

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

People

(Reporter: jandem, Unassigned)

References

(Blocks 1 open bug)

Details

We can't pass JS::Value by value as function argument due to its alignas(8). It's not clear to me if/why we still need this. Value contains just a uint64_t asBits_ field nowadays.

If I remove the alignas, things seem to work fine. We need some JIT codegen changes for 32-bit platforms where Map/Set entries are a bit smaller now, but that's easy to fix.

My understanding of this alignas is the requirement that JS::Value hold double value which are read/written as double and some architecture cause a SIGBUS when the memory is not properly aligned. (ARM?)

Good point, but alignof(Value) would still be 8 on 32-bit ARM due to its uint64_t member.

There could be an issue with the ARM simulator because it has LDRD/STRD alignment assertions and compiles for x86-32 where the alignment is 4. It does pass all jit-tests for me though.

Unaligned FP loads are dicey on some ARM systems depending on the code the C++ compiler generates. Generally these days it seems that the kernel will patch up for you if you have an unaligned integer access, if the CPU traps, but for FP accesses you must generate the correct unaligned-friendly instruction to avoid the trap.

You need to log in before you can comment on or make changes to this bug.