curthread is aliased to curthread(). curthread() is currently an inline function with the const attribute.
The const attribute should mean that the compiler only emits one call to curthread() per function and caches the result. However, in practice, the compiler is emitting multiple calls to curthread() (each of which involves a read of a %gs register) and even assuming the result can change in between invocations.
This change makes __curthread() a real function. To avoid some of the potential pitfalls of making this a function, the function is defined with the no_caller_saved_registers attribute and the function is written in assembly to avoid unnecessarily storing/restoring the stack pointer.
The end result seems to be more compact assembly with less overall instructions.