mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-18 19:50:54 +00:00
e11f727c95
For HPACK we'll need to perform a lot of string manipulation between the dynamic headers table and the output stream, and we need an efficient way to deal with that, considering that the zero character is not an end of string marker here. It turns out that gcc supports returning structs from functions and is able to place up to two words directly in registers when -freg-struct is used, which is the case by default on x86 and armv8. On other architectures the caller reserves some stack space where the callee can write, which is equivalent to passing a pointer to the return value. So let's implement a few functions to deal with this as the resulting code will be optimized on certain architectures where retrieving the length of a string will simply consist in reading one of the two returned registers. Extreme care was taken to ensure that the compiler gets maximum opportunities to optimize out every bit of unused code. This is also the reason why no call to regular string functions (such as strlen(), memcmp(), memcpy() etc) were used. The code involving them is often larger than when they are open coded. Given that strings are usually very small, especially when manipulating headers, the time spent calling a function optimized for large vectors often ends up being higher than the few cycles needed to count a few bytes. An issue was met with __builtin_strlen() which can automatically convert a constant string to its constant length. It doesn't accept NULLs and there is no way to hide them using expressions as the check is made before the optimizer is called. On gcc 4 and above, using an intermediary variable is enough to hide it. On older versions, calls to ist() with an explicit NULL argument will issue a warning. There is normally no reason to do this but taking care of it the best possible still seems important. |
||
---|---|---|
.. | ||
common | ||
import | ||
proto | ||
types |