News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Stack Alignment Without Stack Frame in 64-bit ABI

Started by coder, April 04, 2017, 04:31:09 AM

Previous topic - Next topic

johnsa

I've made a change to hjwasm (for the next update) to set stackbase:rbp as the default when nothing is specified. It's technically required, but shouldn't accidentally cause things to go off if omitted.
I've also put an option in to optimise the amount of stack used with win64:15 / stackbase:rsp but in all cases things will be aligned as planned.


nidud

#16
deleted

nidud

#17
deleted

johnsa

Quote from: nidud on April 10, 2017, 07:04:14 AM
Come to think of it this should probably also apply to 32-bit. Maybe 16-bit as well.

option alignlocals:[on|off]

32 and 64 would still be correct, you're checking the alignment with bsf, so if something is aligned 64 doesn't preclude 16.. that's just by virtue of the fact that cyclic aligns to 16 will eventually be aligned to a > power 2. I'm not bothering to align 32 for ymmword, as the OS doesn't give you a 32byte aligned stack on entry, or at least it's not guaranteed. C/C++ use movups to refer to ymm locals so I'll do the same for now (until we get guaranteed 32byte entry alignment). You can manually compensate on entry into an asm app, but if you were making a library and using it from HLL without that, assuming ymm locals are aligned will probably not work ?

nidud

#19
deleted

habran

#20
here is an interesting explanation about AVX alignment requirement.
Cod-Father

coder

Quote from: johnsa on April 10, 2017, 08:26:14 AM
Quote from: nidud on April 10, 2017, 07:04:14 AM
Come to think of it this should probably also apply to 32-bit. Maybe 16-bit as well.

option alignlocals:[on|off]

32 and 64 would still be correct, you're checking the alignment with bsf, so if something is aligned 64 doesn't preclude 16.. that's just by virtue of the fact that cyclic aligns to 16 will eventually be aligned to a > power 2. I'm not bothering to align 32 for ymmword, as the OS doesn't give you a 32byte aligned stack on entry, or at least it's not guaranteed. C/C++ use movups to refer to ymm locals so I'll do the same for now (until we get guaranteed 32byte entry alignment). You can manually compensate on entry into an asm app, but if you were making a library and using it from HLL without that, assuming ymm locals are aligned will probably not work ?

Why bother bro? AVX don't take alignment too seriously anyway. HJWASM should just stick to the ABI requirements as specified, for now. Since M$ never stated that their ABI is closed-ended, it is highly likely that they would, in the future introduce the 32-byte or even 64-bytes extensions to the current ABI. Then you can put the finishing touch to HJWASM once and for all. 

coder

Quote from: habran on April 10, 2017, 09:48:41 AM
here is an interesting explanation about AVX alignment requirement.

My thoughts exactly!