完全编译而不优化
void Add(T data)
{
node<T> *pNode = new node<T>;
pNode->m_pNext = NULL;
pNode->m_data = data;
uint32_t cPushes;
uint32_t cPops;
node<T> *pTail;
while (true)
{
cPushes = m_cPushes;
cPops = m_cPops;
pTail = (node<T>*)m_pTail;
if (cPushes != m_cPushes)
continue;
if (!pTail)
if (CAS2(&m_pTail, NULL, cPushes, (uint32_t)pNode, cPushes +1))
break;
else if (CAS(&pTail->m_pNext, NULL, (uint32_t)pNode))
break;
else
CAS2(&m_pTail, (uint32_t)pTail, cPushes, (uint32_t)pTail->m_pNext, cPushes + 1);
}
CAS2(&m_pHead, NULL, cPops, (uint32_t)pNode, cPops + 1);
CAS2(&m_pTail, (uint32_t)pTail, cPushes, (uint32_t)pNode, cPushes + 1);
}
反汇编:http://pastebin.com/7EaH3whu(pastebinned 因为它很大,而且它以某种方式破坏了 SO 的代码标签)
如果你看一下,几乎每条跳转指令的地址都混淆了
例如,如果这个语句失败:'if (!pTail)',而不是在 'else if' 处继续,它会跳回到循环的开头(实际上,它会跳转到跳转到环形)
完整代码: http: //pastebin.com/U5qGgT0E