I have stopped liking the idea to utilize the GS segment register for storing the pointer to a thread-local storage. Despite my efforts, the GS register still sometimes ends up containing zero.
Apart for the GS registers there are different options for accessing the thread-local data:
CMPS
) since those instructions use the ES register. Apparently, they are not used since in Clozure CL only EAX register may contains an untagged value which also helps to make the garbage collection precise. Consequently, this approach would require SBCL to not generate string instructions and to save/restore the ES register while calling foreign code. I consider such tradeoffs unacceptable.%FS:0x14
. Using this approach will entail changing in just some places related to handling the current thread. Having skimmed the code, it seems that there are just a couple of such places and they are pretty straightforward.For now I'm betting on using %FS:0x14
.