From 0b185ad7eadf94f0eb8861cb03832003d63cf484 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Fri, 6 Dec 2024 01:11:04 +0000 Subject: [PATCH] Auto-generate files after cl/703295900 --- php/ext/google/protobuf/php-upb.c | 14 +++++++++++++- php/ext/google/protobuf/php-upb.h | 12 ++++++++++++ ruby/ext/google/protobuf_c/ruby-upb.c | 14 +++++++++++++- ruby/ext/google/protobuf_c/ruby-upb.h | 12 ++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index a1e1f0664ef5..fc6e6e06bf07 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -127,6 +127,17 @@ Error, UINTPTR_MAX is undefined #define UPB_UNLIKELY(x) (x) #endif +#ifdef __has_builtin +#if __has_builtin(__builtin_expect_with_probability) +#define UPB_UNPREDICTABLE(x) \ + __builtin_expect_with_probability((bool)(x), 1, 0.5) +#else +#define UPB_UNPREDICTABLE(x) (x) +#endif +#else +#define UPB_UNPREDICTABLE(x) (x) +#endif + // Macros for function attributes on compilers that support them. #if defined(__GNUC__) || defined(__clang__) #define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static @@ -6133,7 +6144,7 @@ const upb_MiniTableField* upb_MiniTable_FindFieldByNumber( if (num == number) { return &base[mid]; } - if (num < number) { + if (UPB_UNPREDICTABLE(num < number)) { lo = lo_mid; } else { hi = hi_mid; @@ -17309,6 +17320,7 @@ upb_ServiceDef* _upb_ServiceDefs_New(upb_DefBuilder* ctx, int n, #undef UPB_MALLOC_ALIGN #undef UPB_LIKELY #undef UPB_UNLIKELY +#undef UPB_UNPREDICTABLE #undef UPB_FORCEINLINE #undef UPB_NOINLINE #undef UPB_NORETURN diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index 10474556d604..f775fe28cfed 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -126,6 +126,17 @@ Error, UINTPTR_MAX is undefined #define UPB_UNLIKELY(x) (x) #endif +#ifdef __has_builtin +#if __has_builtin(__builtin_expect_with_probability) +#define UPB_UNPREDICTABLE(x) \ + __builtin_expect_with_probability((bool)(x), 1, 0.5) +#else +#define UPB_UNPREDICTABLE(x) (x) +#endif +#else +#define UPB_UNPREDICTABLE(x) (x) +#endif + // Macros for function attributes on compilers that support them. #if defined(__GNUC__) || defined(__clang__) #define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static @@ -15702,6 +15713,7 @@ upb_MethodDef* _upb_MethodDefs_New(upb_DefBuilder* ctx, int n, #undef UPB_MALLOC_ALIGN #undef UPB_LIKELY #undef UPB_UNLIKELY +#undef UPB_UNPREDICTABLE #undef UPB_FORCEINLINE #undef UPB_NOINLINE #undef UPB_NORETURN diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index a2a5c485795e..7ca943b7eca8 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -127,6 +127,17 @@ Error, UINTPTR_MAX is undefined #define UPB_UNLIKELY(x) (x) #endif +#ifdef __has_builtin +#if __has_builtin(__builtin_expect_with_probability) +#define UPB_UNPREDICTABLE(x) \ + __builtin_expect_with_probability((bool)(x), 1, 0.5) +#else +#define UPB_UNPREDICTABLE(x) (x) +#endif +#else +#define UPB_UNPREDICTABLE(x) (x) +#endif + // Macros for function attributes on compilers that support them. #if defined(__GNUC__) || defined(__clang__) #define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static @@ -6133,7 +6144,7 @@ const upb_MiniTableField* upb_MiniTable_FindFieldByNumber( if (num == number) { return &base[mid]; } - if (num < number) { + if (UPB_UNPREDICTABLE(num < number)) { lo = lo_mid; } else { hi = hi_mid; @@ -16796,6 +16807,7 @@ upb_ServiceDef* _upb_ServiceDefs_New(upb_DefBuilder* ctx, int n, #undef UPB_MALLOC_ALIGN #undef UPB_LIKELY #undef UPB_UNLIKELY +#undef UPB_UNPREDICTABLE #undef UPB_FORCEINLINE #undef UPB_NOINLINE #undef UPB_NORETURN diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index ea668e070b04..ac37d786755a 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -128,6 +128,17 @@ Error, UINTPTR_MAX is undefined #define UPB_UNLIKELY(x) (x) #endif +#ifdef __has_builtin +#if __has_builtin(__builtin_expect_with_probability) +#define UPB_UNPREDICTABLE(x) \ + __builtin_expect_with_probability((bool)(x), 1, 0.5) +#else +#define UPB_UNPREDICTABLE(x) (x) +#endif +#else +#define UPB_UNPREDICTABLE(x) (x) +#endif + // Macros for function attributes on compilers that support them. #if defined(__GNUC__) || defined(__clang__) #define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static @@ -15515,6 +15526,7 @@ upb_MethodDef* _upb_MethodDefs_New(upb_DefBuilder* ctx, int n, #undef UPB_MALLOC_ALIGN #undef UPB_LIKELY #undef UPB_UNLIKELY +#undef UPB_UNPREDICTABLE #undef UPB_FORCEINLINE #undef UPB_NOINLINE #undef UPB_NORETURN