[PATCH] [libcxxabi] On single threaded systems, turn mutexes into nops

kledzik at apple.com kledzik at apple.com
Mon May 5 17:08:38 PDT 2014


That comment is in the context when _cxa_get_globals() and _cxa_get_globals_fast() are different.  In the single threaded and thread local case, they are the same.

Background: there was originally just _cxa_get_globals().  But it had to always check if the global had been allocated for the current thread.  Someone realized extra check was a waste of performance, given the way it was used in the unwinder. The only way to get into the bowels of the unwinder was to pass through some code that already called _cxa_get_globals(). Therefore, there were uses that did not need the allocation check.  So, _cxa_get_globals_fast() was created which was exactly the same, except did not check for allocation.  Then someone said, what if someone refactors the unwinder and forgets to make sure _cxa_get_globals() was called before _cxa_get_globals()?  Adding an assert in _cxa_get_globals_fast would slow down the unwinder in the case that is supposed to be fast.  So, instead they decided to return NULL which should immediately cause a bus error on use.  

None of that applies to the single threaded and thread local cases.

http://reviews.llvm.org/D3386






More information about the cfe-commits mailing list