Patrick Baggett wrote:
Has anyone noticed how the functions atomic_add_8_nv and friends are
implemented? They really don't look optimal for amd64 architecture. I haven't
checked i386.
xref: /loficc/crypto/usr/src/common/atomic/amd64/atomic.s
movb (%rdi), %al / %al = old value
1:
movb %sil, %cl
addb %al, %cl / %cl = new value
lock
cmpxchgb %cl, (%rdi) / try to stick it in
jne 1b
movzbl %cl, %eax / return new value
ret
Wouldn't it be easier to use a sequence like:
movq %rsi, %rax //rax = rsi = delta
lock
xaddb %al, (%rdi) // Target += delta, %al = original value
addb %sil, %al // %al += delta (thus %al == Target)
ret
Maybe I am missing something really huge here?
No, probably just that they were implemented first on i386, and then implemented
"compatibly but perhaps not optimally" on amd64.
I doubt they're performance-critical, so probably aren't low-hanging fruit of
any kind.
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code