On 4/24/2015 5:59 AM, John Colvin wrote:
one reason why it might be faster is that e.g. gcc can produce code like this:#include<alloca.h> void bar(char* a); void foo(unsigned int n) { char *a = (char*)alloca(n); bar(a); } foo: movl %edi, %eax pushq %rbp addq $46, %rax movq %rsp, %rbp shrq $4, %rax salq $4, %rax subq %rax, %rsp leaq 31(%rsp), %rdi andq $-32, %rdi call bar leave ret which is neat.
It's a cowboy implementation that's fine until it someone tries a largish value of n.