-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontention.s
392 lines (390 loc) · 10.1 KB
/
contention.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 11, 0 sdk_version 11, 3
.globl _get_time_in_nsecs ; -- Begin function get_time_in_nsecs
.p2align 2
_get_time_in_nsecs: ; @get_time_in_nsecs
.cfi_startproc
; %bb.0:
sub sp, sp, #48 ; =48
stp x29, x30, [sp, #32] ; 16-byte Folded Spill
add x29, sp, #32 ; =32
.cfi_def_cfa w29, 16
.cfi_offset w30, -8
.cfi_offset w29, -16
mov w8, #0
mov x0, x8
add x1, sp, #16 ; =16
bl _clock_gettime
ldr x9, [sp, #16]
mov x10, #51712
movk x10, #15258, lsl #16
mul x9, x9, x10
ldr x10, [sp, #24]
add x9, x9, x10
str x9, [sp, #8]
ldr x9, [sp, #8]
mov x0, x9
ldp x29, x30, [sp, #32] ; 16-byte Folded Reload
add sp, sp, #48 ; =48
ret
.cfi_endproc
; -- End function
.globl _pthread_barrier_init ; -- Begin function pthread_barrier_init
.p2align 2
_pthread_barrier_init: ; @pthread_barrier_init
.cfi_startproc
; %bb.0:
sub sp, sp, #48 ; =48
stp x29, x30, [sp, #32] ; 16-byte Folded Spill
add x29, sp, #32 ; =32
.cfi_def_cfa w29, 16
.cfi_offset w30, -8
.cfi_offset w29, -16
str x0, [sp, #16]
str w1, [sp, #12]
str wzr, [sp, #8]
ldr x0, [sp, #16]
mov x8, #0
mov x1, x8
bl _pthread_mutex_init
str w0, [sp, #8]
cbz w0, LBB1_2
; %bb.1:
ldr w8, [sp, #8]
stur w8, [x29, #-4]
b LBB1_5
LBB1_2:
ldr x8, [sp, #16]
add x0, x8, #64 ; =64
mov x8, #0
mov x1, x8
bl _pthread_cond_init
str w0, [sp, #8]
cbz w0, LBB1_4
; %bb.3:
ldr w8, [sp, #8]
stur w8, [x29, #-4]
b LBB1_5
LBB1_4:
ldr x8, [sp, #16]
str wzr, [x8, #112]
ldr x8, [sp, #16]
str xzr, [x8, #120]
ldrsw x8, [sp, #12]
ldr x9, [sp, #16]
str x8, [x9, #128]
stur wzr, [x29, #-4]
LBB1_5:
ldur w0, [x29, #-4]
ldp x29, x30, [sp, #32] ; 16-byte Folded Reload
add sp, sp, #48 ; =48
ret
.cfi_endproc
; -- End function
.globl _pthread_barrier_wait ; -- Begin function pthread_barrier_wait
.p2align 2
_pthread_barrier_wait: ; @pthread_barrier_wait
.cfi_startproc
; %bb.0:
sub sp, sp, #48 ; =48
stp x29, x30, [sp, #32] ; 16-byte Folded Spill
add x29, sp, #32 ; =32
.cfi_def_cfa w29, 16
.cfi_offset w30, -8
.cfi_offset w29, -16
str x0, [sp, #16]
str wzr, [sp, #12]
str wzr, [sp, #8]
ldr x0, [sp, #16]
bl _pthread_mutex_lock
str w0, [sp, #12]
cbz w0, LBB2_2
; %bb.1:
ldr w8, [sp, #12]
stur w8, [x29, #-4]
b LBB2_18
LBB2_2:
ldr x8, [sp, #16]
ldr w9, [x8, #112]
str w9, [sp, #8]
ldr x8, [sp, #16]
ldr x10, [x8, #120]
add x10, x10, #1 ; =1
str x10, [x8, #120]
ldr x8, [sp, #16]
ldr x8, [x8, #120]
ldr x10, [sp, #16]
ldr x10, [x10, #128]
subs x8, x8, x10
b.ne LBB2_8
; %bb.3:
ldr x8, [sp, #16]
str xzr, [x8, #120]
ldr x8, [sp, #16]
ldr w9, [x8, #112]
mov w10, #1
subs w9, w10, w9
ldr x8, [sp, #16]
str w9, [x8, #112]
ldr x8, [sp, #16]
add x0, x8, #64 ; =64
bl _pthread_cond_broadcast
str w0, [sp, #12]
cbz w0, LBB2_5
; %bb.4:
ldr w8, [sp, #12]
stur w8, [x29, #-4]
b LBB2_18
LBB2_5:
ldr x0, [sp, #16]
bl _pthread_mutex_unlock
str w0, [sp, #12]
cbz w0, LBB2_7
; %bb.6:
ldr w8, [sp, #12]
stur w8, [x29, #-4]
b LBB2_18
LBB2_7:
mov w8, #1
stur w8, [x29, #-4]
b LBB2_18
LBB2_8:
LBB2_9: ; =>This Inner Loop Header: Depth=1
ldr x8, [sp, #16]
ldr w9, [x8, #112]
ldr w10, [sp, #8]
subs w9, w9, w10
b.ne LBB2_13
; %bb.10: ; in Loop: Header=BB2_9 Depth=1
ldr x8, [sp, #16]
add x0, x8, #64 ; =64
ldr x1, [sp, #16]
bl _pthread_cond_wait
str w0, [sp, #12]
ldr w9, [sp, #12]
cbz w9, LBB2_12
; %bb.11:
ldr w8, [sp, #12]
stur w8, [x29, #-4]
b LBB2_18
LBB2_12: ; in Loop: Header=BB2_9 Depth=1
b LBB2_14
LBB2_13:
b LBB2_15
LBB2_14: ; in Loop: Header=BB2_9 Depth=1
b LBB2_9
LBB2_15:
ldr x0, [sp, #16]
bl _pthread_mutex_unlock
str w0, [sp, #12]
cbz w0, LBB2_17
; %bb.16:
ldr w8, [sp, #12]
stur w8, [x29, #-4]
b LBB2_18
LBB2_17:
stur wzr, [x29, #-4]
LBB2_18:
ldur w0, [x29, #-4]
ldp x29, x30, [sp, #32] ; 16-byte Folded Reload
add sp, sp, #48 ; =48
ret
.cfi_endproc
; -- End function
.globl _loopFunc ; -- Begin function loopFunc
.p2align 2
_loopFunc: ; @loopFunc
.cfi_startproc
; %bb.0:
sub sp, sp, #16 ; =16
.cfi_def_cfa_offset 16
str wzr, [sp, #12]
str wzr, [sp, #8]
LBB3_1: ; =>This Inner Loop Header: Depth=1
ldr w8, [sp, #8]
mov w9, #38528
movk w9, #152, lsl #16
subs w8, w8, w9
b.ge LBB3_4
; %bb.2: ; in Loop: Header=BB3_1 Depth=1
ldr w8, [sp, #12]
add w8, w8, #1 ; =1
str w8, [sp, #12]
; %bb.3: ; in Loop: Header=BB3_1 Depth=1
ldr w8, [sp, #8]
add w8, w8, #1 ; =1
str w8, [sp, #8]
b LBB3_1
LBB3_4:
add sp, sp, #16 ; =16
ret
.cfi_endproc
; -- End function
.globl _threadLoopFunc ; -- Begin function threadLoopFunc
.p2align 2
_threadLoopFunc: ; @threadLoopFunc
.cfi_startproc
; %bb.0:
sub sp, sp, #80 ; =80
stp x29, x30, [sp, #64] ; 16-byte Folded Spill
add x29, sp, #64 ; =64
.cfi_def_cfa w29, 16
.cfi_offset w30, -8
.cfi_offset w29, -16
stur x0, [x29, #-8]
adrp x0, _barrier@GOTPAGE
ldr x0, [x0, _barrier@GOTPAGEOFF]
bl _pthread_barrier_wait
bl _get_time_in_nsecs
stur x0, [x29, #-16]
bl _loopFunc
bl _get_time_in_nsecs
stur x0, [x29, #-24]
ldur x8, [x29, #-24]
ldur x9, [x29, #-16]
subs x8, x8, x9
; kill: def $w8 killed $w8 killed $x8
mov w10, #16960
movk w10, #15, lsl #16
sdiv w8, w8, w10
stur w8, [x29, #-28]
ldur w8, [x29, #-28]
; implicit-def: $x0
mov x0, x8
adrp x9, l_.str@PAGE
add x9, x9, l_.str@PAGEOFF
str x0, [sp, #24] ; 8-byte Folded Spill
mov x0, x9
mov x9, sp
ldr x11, [sp, #24] ; 8-byte Folded Reload
str x11, [x9]
mov x12, #10
str x12, [x9, #8]
bl _printf
mov x9, #0
mov x0, x9
ldp x29, x30, [sp, #64] ; 16-byte Folded Reload
add sp, sp, #80 ; =80
ret
.cfi_endproc
; -- End function
.globl _main ; -- Begin function main
.p2align 2
_main: ; @main
.cfi_startproc
; %bb.0:
sub sp, sp, #160 ; =160
stp x29, x30, [sp, #144] ; 16-byte Folded Spill
add x29, sp, #144 ; =144
.cfi_def_cfa w29, 16
.cfi_offset w30, -8
.cfi_offset w29, -16
adrp x8, ___stack_chk_guard@GOTPAGE
ldr x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
ldr x8, [x8]
stur x8, [x29, #-8]
str wzr, [sp, #52]
str wzr, [sp, #48]
LBB5_1: ; =>This Inner Loop Header: Depth=1
ldr w8, [sp, #48]
cmp w8, #10 ; =10
b.ge LBB5_4
; %bb.2: ; in Loop: Header=BB5_1 Depth=1
bl _loopFunc
; %bb.3: ; in Loop: Header=BB5_1 Depth=1
ldr w8, [sp, #48]
add w8, w8, #1 ; =1
str w8, [sp, #48]
b LBB5_1
LBB5_4:
bl _get_time_in_nsecs
str x0, [sp, #40]
bl _loopFunc
bl _get_time_in_nsecs
str x0, [sp, #32]
ldr x8, [sp, #32]
ldr x9, [sp, #40]
subs x8, x8, x9
; kill: def $w8 killed $w8 killed $x8
mov w10, #16960
movk w10, #15, lsl #16
sdiv w8, w8, w10
str w8, [sp, #28]
ldr w8, [sp, #28]
; implicit-def: $x0
mov x0, x8
adrp x9, l_.str.1@PAGE
add x9, x9, l_.str.1@PAGEOFF
str x0, [sp, #16] ; 8-byte Folded Spill
mov x0, x9
mov x9, sp
ldr x11, [sp, #16] ; 8-byte Folded Reload
str x11, [x9]
bl _printf
adrp x9, _barrier@GOTPAGE
ldr x9, [x9, _barrier@GOTPAGEOFF]
mov x0, x9
mov w1, #10
bl _pthread_barrier_init
str wzr, [sp, #24]
LBB5_5: ; =>This Inner Loop Header: Depth=1
ldr w8, [sp, #24]
cmp w8, #10 ; =10
b.ge LBB5_8
; %bb.6: ; in Loop: Header=BB5_5 Depth=1
ldrsw x8, [sp, #24]
add x9, sp, #56 ; =56
add x0, x9, x8, lsl #3
mov x8, #0
mov x1, x8
adrp x2, _threadLoopFunc@PAGE
add x2, x2, _threadLoopFunc@PAGEOFF
mov x3, x8
bl _pthread_create
; %bb.7: ; in Loop: Header=BB5_5 Depth=1
ldr w8, [sp, #24]
add w8, w8, #1 ; =1
str w8, [sp, #24]
b LBB5_5
LBB5_8:
str wzr, [sp, #24]
LBB5_9: ; =>This Inner Loop Header: Depth=1
ldr w8, [sp, #24]
cmp w8, #10 ; =10
b.ge LBB5_12
; %bb.10: ; in Loop: Header=BB5_9 Depth=1
ldrsw x8, [sp, #24]
add x9, sp, #56 ; =56
ldr x0, [x9, x8, lsl #3]
mov x8, #0
mov x1, x8
bl _pthread_join
; %bb.11: ; in Loop: Header=BB5_9 Depth=1
ldr w8, [sp, #24]
add w8, w8, #1 ; =1
str w8, [sp, #24]
b LBB5_9
LBB5_12:
adrp x8, ___stack_chk_guard@GOTPAGE
ldr x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
ldr x8, [x8]
ldur x9, [x29, #-8]
subs x8, x8, x9
b.ne LBB5_14
; %bb.13:
mov w8, #0
mov x0, x8
ldp x29, x30, [sp, #144] ; 16-byte Folded Reload
add sp, sp, #160 ; =160
ret
LBB5_14:
bl ___stack_chk_fail
.cfi_endproc
; -- End function
.comm _barrier,136,3 ; @barrier
.section __TEXT,__cstring,cstring_literals
l_.str: ; @.str
.asciz "Took %d msecs with %d threads\n"
l_.str.1: ; @.str.1
.asciz "Took %d msecs with only 1 thread running\n"
.subsections_via_symbols