I'd like to get some input on #7287:
Currently
testing_roc_alloc
in crates/compiler/builtins/bitcode/src/utils.zig ignores the value passed as alignment and always returns a pointer to memory with alignment 1. This caused me a few hours of confusion trying to test an allocation that needed aligning.
Ideally, it would align to whatever value is passed (up to that supported by Zig), but allocating with an alignment not known at compile time seems hard (?).
Always aligning to 16 and panicking if a higher alignment is requested seems like it would cover all likely cases (without wasting too many bytes)
that idea seems fine to me! :+1:
Here is a discussion about roc_alloc
that might me relevant: #platform development > roc_alloc and alignment
OK, here is that implemented. I don't think I have the permissions to make a pull request
Technically it is aligning as whatever @alignOf(usize)
is. Making it 8 on arbitrary hardware is probably possible, but it's trickier and there isn't an obvious benefit.
It should align to 16. That is for u128.
Oh yeah, I even said 16 in the original post. Long week.
OK. The decallocate is going to have to assume it has access to the 16 bytes before the data starts, but that's fine right?
OK, here is that implemented. I don't think I have the permissions to make a pull request
You can make a pull request if you fork first
Anton said:
OK, here is that implemented. I don't think I have the permissions to make a pull request
You can make a pull request if you fork first
So I can! Here is the PR!
Last updated: Jul 06 2025 at 12:14 UTC