flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
vivik 28 Jun 2017, 16:02
Anybody have a code for 16-byte (or even better if I can pass required alignment as one of parameters) allocator? Preferrably in pure winapi.
|
|||
![]() |
|
Furs 29 Jun 2017, 12:08
VirtualAlloc allocates in chunks of 4k bytes (pages), it may be overkill or not, up to your use case. (alignment is guaranteed to be 4096 bytes obviously)
|
|||
![]() |
|
revolution 29 Jun 2017, 12:20
VirtualAlloc is a little it more complicated than a simple 4kB alignment though.
The page size is not actually guaranteed to be 4kB. While is it probably true that every existing and previous x86/x64 Windows version does use 4kB, it is still prudent to check the actual page size in use by calling GetSystemInfo. Future proofing and all that. |
|||
![]() |
|
Furs 29 Jun 2017, 13:52
But I doubt they'd use smaller pages which aren't even supported by the CPU (likely they'd be larger), which still means 4096 alignment is guaranteed, just not more. Anyway, depending on his use case, it's just an alternative. If he does a lot of allocations then it's overkill and will be inefficient. Still something to keep in mind.
|
|||
![]() |
|
revolution 29 Jun 2017, 14:22
When you mention "doubt" then you should already start to take measures to fix that - Call GetSystemInfo. Then no more doubt needed. It is easy to do. Why assume when you can know?
|
|||
![]() |
|
vivik 30 Jun 2017, 14:32
Hoped for an allocator that works on top of VirtualAlloc, maybe somebody made something like that already.
About future proofing, I'll probably just release source code. |
|||
![]() |
|
alexfru 20 Jul 2017, 06:32
Look up HeapAlloc(). It isn't as wasteful as VirtualAlloc(). AFAIK, it returns 8-byte aligned addresses.
|
|||
![]() |
|
vivik 20 Jul 2017, 12:12
SSE requires 16-byte alignment though.
I heard it's actually 16-byte aligned on 64-bit windows, but I'm targeting 32-bit windows for now. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.