Branch: Tag:


2013-06-12 15:46:22 by Per Hedbor <>

[performance] Slightly smaller low_mega_apply.

There is now only one instance of the inclusion of apply_low.h (does
anyone else feel a need for less lowness around here?) which actually
made it faster (previously there were two cases, one for scoped
functions calles and one for calls without scope).

Also created a new version of mega_apply (named lower_mega_apply) that
can only do APPLY_LOW, and only the most common cases.

It falls back to using the old low_mega_apply when needed.

Added a lot of lowness to places to utilize the optimization.

This actually saves surprising amounts of CPU in code calling a lot of
small functions, lower_mega_apply() is about 2x faster than
low_mega_apply(APPLY_LOW,...) when it does not hit one of the cases it
does not support (trampolines, calling non function constants,
variables or arrays).

There is unfortunately now even more code duplication around, but
since the code is slightly different that is rather hard to avoid.

60:    free_item(p); \   }while(0)    + #if __GNUC__ > 2 + /* FIXME: Add real test for this. +  +  It has been around since 1999 in gcc, but also exists in many other +  compilers. +  */ + #define UNLIKELY(X) __builtin_expect( (X), 0 ) + #else + #define UNLIKELY(X) X + #endif +    /* This variant never leaves p pointing at a deallocated block, as the    * one above can do. I.e. it frees a ref to the item p points at, and    * sets p to the same or next item with references, or sets it to