refactor: zend_call_stack_get_linux_pthread

GCC doesn't pessimize the error cases correctly:
https://godbolt.org/z/Pa6xsKMWc

This speeds up the happy case and in this case the code size is also
smaller, so it's a double-win.
This commit is contained in:
Levi Morrison 2024-06-10 10:25:13 -06:00 committed by Levi Morrison
parent 550f840a22
commit 62bfb01e00
No known key found for this signature in database

View File

@ -133,12 +133,12 @@ static bool zend_call_stack_get_linux_pthread(zend_call_stack *stack)
ZEND_ASSERT(!zend_call_stack_is_main_thread());
error = pthread_getattr_np(pthread_self(), &attr);
if (error) {
if (UNEXPECTED(error)) {
return false;
}
error = pthread_attr_getstack(&attr, &addr, &max_size);
if (error) {
if (UNEXPECTED(error)) {
pthread_attr_destroy(&attr);
return false;
}
@ -148,7 +148,7 @@ static bool zend_call_stack_get_linux_pthread(zend_call_stack *stack)
size_t guard_size;
/* In glibc prior to 2.8, addr and size include the guard pages */
error = pthread_attr_getguardsize(&attr, &guard_size);
if (error) {
if (UNEXPECTED(error)) {
pthread_attr_destroy(&attr);
return false;
}