-
Notifications
You must be signed in to change notification settings - Fork 8
/
atomic_cas_handtune.s
63 lines (63 loc) · 1.23 KB
/
atomic_cas_handtune.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
.file "atomic_wait_free_cas.c"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "atomic counter val: %lu\n"
.section .text.unlikely,"ax",@progbits
.LCOLDB1:
.text
.LHOTB1:
.p2align 4,,15
.globl test
.type test, @function
test:
.LFB38:
.cfi_startproc
subq $24, %rsp
.cfi_def_cfa_offset 32
movl (%rdi), %ecx
movl $1, %eax
salq %cl, %rax
testq %rax, %rax
je .L6
movq %rax, %rcx
xorl %esi, %esi
.L8:
movq atomic_counter(%rip), %rax
.p2align 4,,10
.p2align 3
.L12:
# cmpxchgq
# Compare RAX with r/m64. If equal, ZF is set and r64 is loaded into r/m64.
# Else, clear ZF and load r/m64 into RAX
# Original compiled program:
# movq %rax, 8(%rsp)
# leaq 1(%rax), %rdx
# movq 8(%rsp), %rax
# lock cmpxchgq %rdx, atomic_counter(%rip)
# jne .L12
leaq 1(%rax), %rdx
lock cmpxchgq %rdx, atomic_counter(%rip)
jne .L12
addq $1, %rsi
cmpq %rsi, %rcx
jne .L8
.L6:
movq atomic_counter(%rip), %rsi
movl $.LC0, %edi
xorl %eax, %eax
call printf
xorl %eax, %eax
addq $24, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE38:
.size test, .-test
.section .text.unlikely
.LCOLDE1:
.text
.LHOTE1:
.local atomic_counter
.comm atomic_counter,8,8
.ident "GCC: (GNU) 5.2.1 20150902 (Red Hat 5.2.1-2)"
.section .note.GNU-stack,"",@progbits