Which is a better write barrier on x86: lock+addl or xchgl?

前端 未结 5 1482
我在风中等你
我在风中等你 2020-11-29 03:14

The Linux kernel uses lock; addl $0,0(%%esp) as write barrier, while the RE2 library uses xchgl (%0),%0 as write barrier. What\'s the difference an

5条回答
  •  甜味超标
    2020-11-29 03:27

    As an aside to the other answers, the HotSpot devs found that lock; addl $0,0(%%esp) with a zero offset may not be optimal, on some processors it can introduce false data dependencies; related jdk bug.

    Touching a stack location with a different offset can improve performance under some circumstances.

提交回复
热议问题