This repository has been archived by the owner on Apr 28, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The -fstack-protector-strong used in many distributions by default has a rather drastic slowdown of the fast path in generated _get_type() functions using G_DEFINE_* macros. To work around this, and return our fast-path to what we had previously, we need to break out the slow-path (registering the type) into a secondary function that is not allowed to be a candidate for inlining. This ensures that the common case (type registered, return the GType id) is the hot path and handled in the prologue of the generated assembly. Additionally, this has the benefit of moving the PRELUDE block added for GSocket deadlock prevention into the once function, meaning that we do not unconditionally call g_ensure_type() every time we enter _get_type() functions using PRELUDE. Compare the hot path for g_socket_get_type() before and after. Before: 7e8b0: f3 0f 1e fa endbr64 7e8b4: 55 push %rbp 7e8b5: 53 push %rbx 7e8b6: 48 83 ec 28 sub $0x28,%rsp 7e8ba: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax 7e8c1: 00 00 7e8c3: 48 89 44 24 18 mov %rax,0x18(%rsp) 7e8c8: 31 c0 xor %eax,%eax 7e8ca: e8 d1 29 02 00 callq a12a0 <g_socket_family_get_type@@base> 7e8cf: 48 89 c7 mov %rax,%rdi 7e8d2: e8 29 81 fb ff callq 36a00 <g_type_ensure@plt> 7e8d7: e8 44 2a 02 00 callq a1320 <g_socket_type_get_type@@base> 7e8dc: 48 89 c7 mov %rax,%rdi 7e8df: e8 1c 81 fb ff callq 36a00 <g_type_ensure@plt> 7e8e4: e8 37 2b 02 00 callq a1420 <g_socket_protocol_get_type@@base> 7e8e9: 48 89 c7 mov %rax,%rdi 7e8ec: e8 0f 81 fb ff callq 36a00 <g_type_ensure@plt> 7e8f1: e8 ea 64 00 00 callq 84de0 <g_socket_address_get_type@@base> 7e8f6: 48 89 c7 mov %rax,%rdi 7e8f9: e8 02 81 fb ff callq 36a00 <g_type_ensure@plt> 7e8fe: e8 5d 08 ff ff callq 6f160 <g_networking_init@@base> 7e903: 48 8b 05 3e 35 32 00 mov 0x32353e(%rip),%rax # 3a1e48 <_edata@@base+0x900> 7e90a: 48 85 c0 test %rax,%rax 7e90d: 74 29 je 7e938 <g_socket_get_type@@base+0x88> 7e90f: 48 8b 05 32 35 32 00 mov 0x323532(%rip),%rax # 3a1e48 <_edata@@base+0x900> 7e916: 48 8b 4c 24 18 mov 0x18(%rsp),%rcx 7e91b: 64 48 33 0c 25 28 00 xor %fs:0x28,%rcx 7e922: 00 00 7e924: 0f 85 e5 00 00 00 jne 7ea0f <g_socket_get_type@@base+0x15f> 7e92a: 48 83 c4 28 add $0x28,%rsp 7e92e: 5b pop %rbx 7e92f: 5d pop %rbp 7e930: c3 retq After: 7fbe0: 48 8b 05 21 ae 32 00 mov 0x32ae21(%rip),%rax # 3aaa08 <g_define_type_id__volatile.18420> 7fbe7: 48 85 c0 test %rax,%rax 7fbea: 74 0c je 7fbf8 <g_socket_get_type+0x18> 7fbec: 48 8b 05 15 ae 32 00 mov 0x32ae15(%rip),%rax # 3aaa08 <g_define_type_id__volatile.18420> 7fbf3: c3 retq https://bugzilla.gnome.org/show_bug.cgi?id=795180
- Loading branch information