Skip to content

Commit 8bb2970

Browse files
committed
Refactored API for constant array element propagation
1 parent 76db01d commit 8bb2970

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

Zend/zend_ast.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,7 @@ ZEND_API int zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *sc
432432
} else {
433433
zval tmp;
434434

435-
if (ast->attr == ZEND_DIM_IS) {
436-
zend_fetch_dimension_by_zval_is(&tmp, &op1, &op2, IS_CONST);
437-
} else {
438-
zend_fetch_dimension_by_zval(&tmp, &op1, &op2);
439-
}
435+
zend_fetch_dimension_const(&tmp, &op1, &op2, (ast->attr == ZEND_DIM_IS) ? BP_VAR_IS : BP_VAR_R);
440436

441437
if (UNEXPECTED(Z_ISREF(tmp))) {
442438
ZVAL_DUP(result, Z_REFVAL(tmp));

Zend/zend_execute.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,17 +1827,15 @@ static zend_never_inline void zend_fetch_dimension_address_read_LIST(zval *resul
18271827
zend_fetch_dimension_address_read(result, container, dim, IS_TMP_VAR, BP_VAR_R, 0, 0);
18281828
}
18291829

1830-
ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *dim)
1830+
ZEND_API void zend_fetch_dimension_const(zval *result, zval *container, zval *dim, int type)
18311831
{
1832-
zend_fetch_dimension_address_read_R(result, container, dim, IS_TMP_VAR);
1833-
}
1834-
1835-
ZEND_API void zend_fetch_dimension_by_zval_is(zval *result, zval *container, zval *dim, int dim_type)
1836-
{
1837-
zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_IS, 1, 0);
1832+
if (type == BP_VAR_IS) {
1833+
zend_fetch_dimension_address_read_IS(result, container, dim, IS_CONST);
1834+
} else {
1835+
zend_fetch_dimension_address_read_R(result, container, dim, IS_CONST);
1836+
}
18381837
}
18391838

1840-
18411839
static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, uint32_t prop_op_type, void **cache_slot, int type)
18421840
{
18431841
if (container_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {

Zend/zend_execute.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_t
298298
ZEND_API zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *key, int fetch_type);
299299
void zend_verify_abstract_class(zend_class_entry *ce);
300300

301-
ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *dim);
302-
ZEND_API void zend_fetch_dimension_by_zval_is(zval *result, zval *container, zval *dim, int dim_type);
301+
ZEND_API void zend_fetch_dimension_const(zval *result, zval *container, zval *dim, int type);
303302

304303
ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, uint32_t var);
305304

0 commit comments

Comments
 (0)