文档详情

visibility - gcc wiki.pdf

发布:2016-03-08约1.57万字共6页下载文档
文本预览下载声明
Note : the text on this page was almost integrally written by Niall Douglas, the original author of the patch, and placed on . This is basically a local mirror (especially useful because the external website now appears to be down). Why is the new C++ visibility support so useful? Put simply, it hides most of the E F symbols which would have previously (and unnecessarily) been public. This means: It very substantially imp roves load times of y our DSO (Dy namic Shared Obj ect) . For example, a huge C++ template-based library which was tested (the TnFOX Boost.Python bindings library) now loads in eight seconds rather than over six minutes! It lets the op timiser p roduce better code. P T indirections (when a function call or variable access must be looked up via the Global Offset Table such as in PIC code) can be completely avoided, thus substantially avoiding pipeline stalls on modern processors and thus much faster code. Furthermore when most of the symbols are bound locally, they can be safely elided (removed) completely through the entire DSO. This gives greater latitude especially to the inliner which no longer needs to keep an entry point around just in case. It reduces the size of y our DSO by 5- 0%. E Fs exported symbol table format is quite a space hog, giving the complete mangled symbol name which with heavy template usage can average around 1000 bytes. C++ templates spew out a huge amount of symbols and a typical C++ library can easily surpass 30,000 symbols which is around 5-6Mb ! Therefore if you cut out the 60-80% of unnecessary symbols, your DSO can be megabytes smaller! Much lower chance of sy mbol collision. The old woe of two libraries internally using the same symbol for different things is finally behind us with this patch. Halleluj ah! Although the library quoted above is
显示全部
相似文档