diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2023-10-30 03:44:06 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-10-30 03:44:45 -0700 |
commit | f4106724bf9cc54ed055e8d6364ae91e0d7c1547 (patch) | |
tree | 145372b284f9130ca74f6bf228a47c1766003f73 /absl/strings/internal/str_format/convert_test.cc | |
parent | 89d2caa104563ad8c2182282f5d4676f6747bd0e (diff) | |
download | abseil-f4106724bf9cc54ed055e8d6364ae91e0d7c1547.tar.gz abseil-f4106724bf9cc54ed055e8d6364ae91e0d7c1547.tar.bz2 abseil-f4106724bf9cc54ed055e8d6364ae91e0d7c1547.zip |
absl: speed up Mutex::Lock
Currently Mutex::Lock contains not inlined non-tail call:
TryAcquireWithSpinning -> GetMutexGlobals -> LowLevelCallOnce -> init closure
This turns the function into non-leaf with stack frame allocation
and additional register use. Remove this non-tail call to make the function leaf.
Move spin iterations initialization to LockSlow.
Current Lock happy path:
00000000001edc20 <absl::Mutex::Lock()>:
1edc20: 55 push %rbp
1edc21: 48 89 e5 mov %rsp,%rbp
1edc24: 53 push %rbx
1edc25: 50 push %rax
1edc26: 48 89 fb mov %rdi,%rbx
1edc29: 48 8b 07 mov (%rdi),%rax
1edc2c: a8 19 test $0x19,%al
1edc2e: 75 0e jne 1edc3e <absl::Mutex::Lock()+0x1e>
1edc30: 48 89 c1 mov %rax,%rcx
1edc33: 48 83 c9 08 or $0x8,%rcx
1edc37: f0 48 0f b1 0b lock cmpxchg %rcx,(%rbx)
1edc3c: 74 42 je 1edc80 <absl::Mutex::Lock()+0x60>
... unhappy path ...
1edc80: 48 83 c4 08 add $0x8,%rsp
1edc84: 5b pop %rbx
1edc85: 5d pop %rbp
1edc86: c3 ret
New Lock happy path:
00000000001eea80 <absl::Mutex::Lock()>:
1eea80: 48 8b 07 mov (%rdi),%rax
1eea83: a8 19 test $0x19,%al
1eea85: 75 0f jne 1eea96 <absl::Mutex::Lock()+0x16>
1eea87: 48 89 c1 mov %rax,%rcx
1eea8a: 48 83 c9 08 or $0x8,%rcx
1eea8e: f0 48 0f b1 0f lock cmpxchg %rcx,(%rdi)
1eea93: 75 01 jne 1eea96 <absl::Mutex::Lock()+0x16>
1eea95: c3 ret
... unhappy path ...
PiperOrigin-RevId: 577790105
Change-Id: I20793534050302ff9f7a20aed93791c088d98562
Diffstat (limited to 'absl/strings/internal/str_format/convert_test.cc')
0 files changed, 0 insertions, 0 deletions