From 359089071633ba92f095ae1e7038a561c6fa18f2 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 9 Dec 2024 18:45:29 +0100 Subject: [PATCH] Fix duplicate pattern usage in Z_TRY_(ADD|DEL)REF_P (GH-17097) GCC produces exactly the same binary with and without this change (without extensions), which demonstrates two things: * There is no additional register pressure. * All usages of the macros were correct in older branches, i.e. the expressions did not have any side-effects. --- Zend/zend_types.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 8f012868dda..f7d234c92c6 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -1273,14 +1273,16 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { #define Z_DELREF(z) Z_DELREF_P(&(z)) #define Z_TRY_ADDREF_P(pz) do { \ - if (Z_REFCOUNTED_P((pz))) { \ - Z_ADDREF_P((pz)); \ + zval *_pz = (pz); \ + if (Z_REFCOUNTED_P(_pz)) { \ + Z_ADDREF_P(_pz); \ } \ } while (0) #define Z_TRY_DELREF_P(pz) do { \ - if (Z_REFCOUNTED_P((pz))) { \ - Z_DELREF_P((pz)); \ + zval *_pz = (pz); \ + if (Z_REFCOUNTED_P(_pz)) { \ + Z_DELREF_P(_pz); \ } \ } while (0)