Skip to content

Commit 7a5b557

Browse files
committed
zend_types: Remove Z_*CONSTANT_*()
This macro is very rarely used and badly named by neither including the `IS` nor the `AST` in its name.
1 parent 7c86d86 commit 7a5b557

7 files changed

Lines changed: 13 additions & 15 deletions

File tree

UPGRADING.INTERNALS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ PHP 8.6 INTERNALS UPGRADE NOTES
110110
. Added ZEND_CONTAINER_OF().
111111
. The OPENBASEDIR_CHECKPATH() compatibility macro has been removed, instead
112112
use php_check_open_basedir() directly.
113+
. The Z_CONSTANT(), Z_CONSTANT_P(), Z_OPT_CONSTANT(), and
114+
Z_OPT_CONSTANT_P() macros have been removed. Check for IS_CONSTANT_AST
115+
directly.
113116

114117
========================
115118
2. Build system changes

Zend/zend_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9207,7 +9207,7 @@ static void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t f
92079207
if (*value_ast_ptr) {
92089208
zend_const_expr_to_zval(&value_zv, value_ast_ptr, /* allow_dynamic */ false);
92099209

9210-
if (ZEND_TYPE_IS_SET(type) && !Z_CONSTANT(value_zv)
9210+
if (ZEND_TYPE_IS_SET(type) && Z_TYPE(value_zv) != IS_CONSTANT_AST
92119211
&& !zend_is_valid_default_value(type, &value_zv)) {
92129212
zend_string *str = zend_type_to_string(type);
92139213
if (Z_TYPE(value_zv) == IS_NULL && !ZEND_TYPE_IS_INTERSECTION(type)) {
@@ -9331,7 +9331,7 @@ static void zend_compile_class_const_decl(zend_ast *ast, uint32_t flags, zend_as
93319331

93329332
zend_const_expr_to_zval(&value_zv, value_ast_ptr, /* allow_dynamic */ false);
93339333

9334-
if (!Z_CONSTANT(value_zv) && ZEND_TYPE_IS_SET(type) && !zend_is_valid_default_value(type, &value_zv)) {
9334+
if (Z_TYPE(value_zv) != IS_CONSTANT_AST && ZEND_TYPE_IS_SET(type) && !zend_is_valid_default_value(type, &value_zv)) {
93359335
zend_string *type_str = zend_type_to_string(type);
93369336

93379337
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use %s as value for class constant %s::%s of type %s",

Zend/zend_ini_parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static void zend_ini_get_constant(zval *result, zval *name)
151151
&& (c = zend_get_constant(Z_STR_P(name))) != 0) {
152152
if (Z_TYPE_P(c) != IS_STRING) {
153153
ZVAL_COPY_OR_DUP(&tmp, c);
154-
if (Z_OPT_CONSTANT(tmp)) {
154+
if (Z_OPT_TYPE(tmp) == IS_CONSTANT_AST) {
155155
zval_update_constant_ex(&tmp, NULL);
156156
}
157157
convert_to_string(&tmp);

Zend/zend_types.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -929,8 +929,6 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
929929
} while(0)
930930

931931
/* All data types < IS_STRING have their constructor/destructors skipped */
932-
#define Z_CONSTANT(zval) (Z_TYPE(zval) == IS_CONSTANT_AST)
933-
#define Z_CONSTANT_P(zval_p) Z_CONSTANT(*(zval_p))
934932

935933
#if 1
936934
/* This optimized version assumes that we have a single "type_flag" */
@@ -948,9 +946,6 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
948946
#define Z_OPT_TYPE(zval) (Z_TYPE_INFO(zval) & Z_TYPE_MASK)
949947
#define Z_OPT_TYPE_P(zval_p) Z_OPT_TYPE(*(zval_p))
950948

951-
#define Z_OPT_CONSTANT(zval) (Z_OPT_TYPE(zval) == IS_CONSTANT_AST)
952-
#define Z_OPT_CONSTANT_P(zval_p) Z_OPT_CONSTANT(*(zval_p))
953-
954949
#define Z_OPT_REFCOUNTED(zval) Z_TYPE_INFO_REFCOUNTED(Z_TYPE_INFO(zval))
955950
#define Z_OPT_REFCOUNTED_P(zval_p) Z_OPT_REFCOUNTED(*(zval_p))
956951

Zend/zend_vm_def.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8320,7 +8320,7 @@ ZEND_VM_HANDLER(143, ZEND_DECLARE_CONST, CONST, CONST)
83208320
val = GET_OP2_ZVAL_PTR(BP_VAR_R);
83218321

83228322
ZVAL_COPY(&c.value, val);
8323-
if (Z_OPT_CONSTANT(c.value)) {
8323+
if (Z_OPT_TYPE(c.value) == IS_CONSTANT_AST) {
83248324
if (UNEXPECTED(zval_update_constant_ex(&c.value, EX(func)->op_array.scope) != SUCCESS)) {
83258325
zval_ptr_dtor_nogc(&c.value);
83268326
FREE_OP1();
@@ -8352,7 +8352,7 @@ ZEND_VM_HANDLER(210, ZEND_DECLARE_ATTRIBUTED_CONST, CONST, CONST)
83528352
val = GET_OP2_ZVAL_PTR(BP_VAR_R);
83538353

83548354
ZVAL_COPY(&c.value, val);
8355-
if (Z_OPT_CONSTANT(c.value)) {
8355+
if (Z_OPT_TYPE(c.value) == IS_CONSTANT_AST) {
83568356
if (UNEXPECTED(zval_update_constant_ex(&c.value, EX(func)->op_array.scope) != SUCCESS)) {
83578357
zval_ptr_dtor_nogc(&c.value);
83588358
FREE_OP1();

Zend/zend_vm_execute.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/opcache/jit/zend_jit_ir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10927,7 +10927,7 @@ static int zend_jit_recv_init(zend_jit_ctx *jit, const zend_op *opline, const ze
1092710927
zv, true);
1092810928
}
1092910929

10930-
if (Z_CONSTANT_P(zv)) {
10930+
if (Z_TYPE_P(zv) == IS_CONSTANT_AST) {
1093110931
jit_SET_EX_OPLINE(jit, opline);
1093210932
ref = ir_CALL_2(IR_I32, ir_CONST_FC_FUNC(zval_update_constant_ex),
1093310933
jit_ZVAL_ADDR(jit, res_addr),

0 commit comments

Comments
 (0)