mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
take alignment into account when calculating stack size
This commit is contained in:
parent
2786e0e3d6
commit
eb5439ee96
3 changed files with 36 additions and 1 deletions
|
@ -636,6 +636,19 @@ impl<'a> Layout<'a> {
|
|||
}
|
||||
|
||||
pub fn stack_size(&self, pointer_size: u32) -> u32 {
|
||||
let width = self.stack_size_without_alignment(pointer_size);
|
||||
let alignment = self.alignment_bytes(pointer_size);
|
||||
|
||||
if alignment == 0 {
|
||||
width
|
||||
} else if width % alignment > 0 {
|
||||
width + alignment - (width % alignment)
|
||||
} else {
|
||||
width
|
||||
}
|
||||
}
|
||||
|
||||
fn stack_size_without_alignment(&self, pointer_size: u32) -> u32 {
|
||||
use Layout::*;
|
||||
|
||||
match self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue