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.
This commit is contained in:
Ilija Tovilo 2024-12-09 18:45:29 +01:00 committed by GitHub
parent 5a482a139c
commit 3590890716
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)