Stack allocation is a bit more expensive if you enabled / GS in the VC ++ compiler, which provides a security check for buffer overflows (GS is enabled by default). Indeed, you should profile two options and see which is faster. Perhaps something like localizing the cache in static memory and on the stack may matter.
Here's a non-static version with a VC ++ c / O 2 compiler.
_main PROC ; COMDAT ; Line 5 mov eax, 5124 ; 00001404H call __chkstk mov eax, DWORD PTR ___security_cookie xor eax, esp mov DWORD PTR __$ArrayPad$[esp+5124], eax ; Line 7 push 5120 ; 00001400H lea eax, DWORD PTR _buf$[esp+5128] push 0 push eax call _memset ; Line 9 mov ecx, DWORD PTR __$ArrayPad$[esp+5136] movsx eax, BYTE PTR _buf$[esp+5139] add esp, 12 ; 0000000cH xor ecx, esp call @__security_check_cookie@4 add esp, 5124 ; 00001404H ret 0 _main ENDP _TEXT ENDS
And here is the static version
; COMDAT _main _TEXT SEGMENT _main PROC ; COMDAT ; Line 7 push 5120 ; 00001400H push 0 push OFFSET ?buf@?1??main@@9@4PADA call _memset ; Line 8 movsx eax, BYTE PTR ?buf@?1??main@@9@4PADA+3 add esp, 12 ; 0000000cH ; Line 9 ret 0 _main ENDP _TEXT ENDS END
Drew hoskins
source share