clarify the purpose of this project
[nyanglibc.git] / nptl / elision-lock.s
blob0e8063a59204f27ec4d58e332e665c098b5f1c97
1 .text
2 .p2align 4,,15
3 .globl _dl_tunable_set_elision_skip_lock_busy
4 .type _dl_tunable_set_elision_skip_lock_busy, @function
5 _dl_tunable_set_elision_skip_lock_busy:
6 movq (%rdi), %rax
7 movl %eax, __elision_aconf(%rip)
8 ret
9 .size _dl_tunable_set_elision_skip_lock_busy, .-_dl_tunable_set_elision_skip_lock_busy
10 .p2align 4,,15
11 .globl _dl_tunable_set_elision_skip_lock_internal_abort
12 .type _dl_tunable_set_elision_skip_lock_internal_abort, @function
13 _dl_tunable_set_elision_skip_lock_internal_abort:
14 movq (%rdi), %rax
15 movl %eax, 4+__elision_aconf(%rip)
16 ret
17 .size _dl_tunable_set_elision_skip_lock_internal_abort, .-_dl_tunable_set_elision_skip_lock_internal_abort
18 .p2align 4,,15
19 .globl _dl_tunable_set_elision_retry_try_xbegin
20 .type _dl_tunable_set_elision_retry_try_xbegin, @function
21 _dl_tunable_set_elision_retry_try_xbegin:
22 movq (%rdi), %rax
23 movl %eax, 8+__elision_aconf(%rip)
24 ret
25 .size _dl_tunable_set_elision_retry_try_xbegin, .-_dl_tunable_set_elision_retry_try_xbegin
26 .p2align 4,,15
27 .globl _dl_tunable_set_elision_skip_trylock_internal_abort
28 .type _dl_tunable_set_elision_skip_trylock_internal_abort, @function
29 _dl_tunable_set_elision_skip_trylock_internal_abort:
30 movq (%rdi), %rax
31 movl %eax, 12+__elision_aconf(%rip)
32 ret
33 .size _dl_tunable_set_elision_skip_trylock_internal_abort, .-_dl_tunable_set_elision_skip_trylock_internal_abort
34 .p2align 4,,15
35 .type elision_init, @function
36 elision_init:
37 pushq %rbx
38 leaq _dl_tunable_set_elision_enable(%rip), %rdx
39 movl $7, %edi
40 subq $16, %rsp
41 leaq 12(%rsp), %rbx
42 movq %rbx, %rsi
43 call __tunable_get_val@PLT
44 leaq _dl_tunable_set_elision_skip_lock_busy(%rip), %rdx
45 movq %rbx, %rsi
46 movl $10, %edi
47 call __tunable_get_val@PLT
48 leaq _dl_tunable_set_elision_skip_lock_internal_abort(%rip), %rdx
49 movq %rbx, %rsi
50 movl $21, %edi
51 call __tunable_get_val@PLT
52 leaq _dl_tunable_set_elision_retry_try_xbegin(%rip), %rdx
53 movq %rbx, %rsi
54 movl $6, %edi
55 call __tunable_get_val@PLT
56 leaq _dl_tunable_set_elision_skip_trylock_internal_abort(%rip), %rdx
57 movq %rbx, %rsi
58 movl $17, %edi
59 call __tunable_get_val@PLT
60 movl __pthread_force_elision(%rip), %eax
61 testl %eax, %eax
62 jne .L6
63 movl $0, 8+__elision_aconf(%rip)
64 .L6:
65 addq $16, %rsp
66 popq %rbx
67 ret
68 .size elision_init, .-elision_init
69 .p2align 4,,15
70 .globl _dl_tunable_set_elision_enable
71 .type _dl_tunable_set_elision_enable, @function
72 _dl_tunable_set_elision_enable:
73 cmpl $1, (%rdi)
74 je .L11
75 rep ret
76 .p2align 4,,10
77 .p2align 3
78 .L11:
79 movl 72+_dl_x86_cpu_features(%rip), %eax
80 shrl $11, %eax
81 andl $1, %eax
82 movl %eax, __pthread_force_elision(%rip)
83 ret
84 .size _dl_tunable_set_elision_enable, .-_dl_tunable_set_elision_enable
85 .p2align 4,,15
86 .globl __lll_lock_elision
87 .type __lll_lock_elision, @function
88 __lll_lock_elision:
89 movzwl (%rsi), %eax
90 testw %ax, %ax
91 jg .L13
92 movl 8+__elision_aconf(%rip), %ecx
93 testl %ecx, %ecx
94 jle .L21
95 movl $-1, %r8d
96 jmp .L22
97 .p2align 4,,10
98 .p2align 3
99 .L16:
100 testb $2, %al
101 je .L35
102 subl $1, %ecx
103 je .L21
104 .L22:
105 movl %r8d, %eax
106 xbegin .L15
107 .L15:
108 cmpl $-1, %eax
109 jne .L16
110 movl (%rdi), %eax
111 testl %eax, %eax
112 je .L32
113 xabort $255
114 subl $1, %ecx
115 jne .L22
116 .p2align 4,,10
117 .p2align 3
118 .L21:
119 xorl %eax, %eax
120 movl $1, %ecx
121 lock cmpxchgl %ecx, (%rdi)
122 jne .L30
123 .L32:
124 xorl %eax, %eax
126 .p2align 4,,10
127 .p2align 3
128 .L13:
129 movzwl (%rsi), %eax
130 subl $1, %eax
131 movw %ax, (%rsi)
132 jmp .L21
133 .p2align 4,,10
134 .p2align 3
135 .L35:
136 testb $1, %al
137 je .L20
138 shrl $24, %eax
139 cmpl $255, %eax
140 je .L36
141 .L20:
142 movswl (%rsi), %eax
143 movl 4+__elision_aconf(%rip), %ecx
144 cmpl %ecx, %eax
145 je .L21
146 .L34:
147 movw %cx, (%rsi)
148 jmp .L21
149 .L30:
150 subq $8, %rsp
151 movl %edx, %esi
152 call __lll_lock_wait@PLT
153 xorl %eax, %eax
154 addq $8, %rsp
156 .L36:
157 movswl (%rsi), %eax
158 movl __elision_aconf(%rip), %ecx
159 cmpl %ecx, %eax
160 je .L21
161 jmp .L34
162 .size __lll_lock_elision, .-__lll_lock_elision
163 .globl __pthread_init_array
164 .section .preinit_array,"aw"
165 .align 8
166 .type __pthread_init_array, @object
167 .size __pthread_init_array, 8
168 __pthread_init_array:
169 .quad elision_init
170 .globl __pthread_force_elision
171 .bss
172 .align 4
173 .type __pthread_force_elision, @object
174 .size __pthread_force_elision, 4
175 __pthread_force_elision:
176 .zero 4
177 .globl __elision_aconf
178 .data
179 .align 16
180 .type __elision_aconf, @object
181 .size __elision_aconf, 16
182 __elision_aconf:
183 .long 3
184 .long 3
185 .long 3
186 .long 3