Hacker News new | ask | show | jobs
by dhhwrongagain 2271 days ago
Yeah that’s a very good point.

There may be multiple reasons but a performance reason of which I’m aware is downward stacks are more efficient for allocating aligned memory:

    sp = (sp - size) & align;
That’s only two instructions, with a stack that grows upward:

    sp += size;
    if (sp & (align - 1))
      sp += align - (sp & (align - 1)); 
Which is a few more instructions. Of course you can alleviate this by requiring an alignment invariant in the ABI, which is usually done anyway.