1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Zend/Optimizer: change copy parameter type from int to bool in zend_optimizer_get_persistent_constant

This commit is contained in:
Gina Peter Banyard
2025-10-03 12:40:41 +01:00
parent e99df67869
commit 337fbd65f8
4 changed files with 7 additions and 7 deletions

View File

@@ -30,7 +30,7 @@
#include "zend_dump.h"
/* Checks if a constant (like "true") may be replaced by its value */
bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int copy)
bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, bool copy)
{
zend_constant *c = zend_hash_find_ptr(EG(zend_constants), name);
if (c) {
@@ -371,7 +371,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
}
} else if(flen == sizeof("constant")-1 && zend_binary_strcasecmp(fname, flen, "constant", sizeof("constant")-1) == 0) {
zval c;
if (zend_optimizer_get_persistent_constant(Z_STR_P(arg), &c, 1 ELS_CC)) {
if (zend_optimizer_get_persistent_constant(Z_STR_P(arg), &c, true ELS_CC)) {
literal_dtor(arg);
MAKE_NOP(sv);
MAKE_NOP(fcall);

View File

@@ -149,7 +149,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
if (opline->op2_type == IS_CONST &&
Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) {
/* substitute persistent constants */
if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP2_LITERAL(opline)), &result, 1)) {
if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP2_LITERAL(opline)), &result, true)) {
if (!ctx->constants || !zend_optimizer_get_collected_constant(ctx->constants, &ZEND_OP2_LITERAL(opline), &result)) {
break;
}
@@ -171,7 +171,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
if (Z_TYPE_P(c) == IS_CONSTANT_AST) {
zend_ast *ast = Z_ASTVAL_P(c);
if (ast->kind != ZEND_AST_CONSTANT
|| !zend_optimizer_get_persistent_constant(zend_ast_get_constant_name(ast), &result, 1)
|| !zend_optimizer_get_persistent_constant(zend_ast_get_constant_name(ast), &result, true)
|| Z_TYPE(result) == IS_CONSTANT_AST) {
break;
}
@@ -271,7 +271,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
}
break;
case ZEND_DEFINED:
if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(opline)), &result, 0)) {
if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(opline)), &result, false)) {
break;
}
ZVAL_TRUE(&result);

View File

@@ -145,7 +145,7 @@ zend_result zend_optimizer_eval_special_func_call(
return FAILURE;
}
if (zend_string_equals_literal(name, "constant")) {
return zend_optimizer_get_persistent_constant(arg, result, 1) ? SUCCESS : FAILURE;
return zend_optimizer_get_persistent_constant(arg, result, true) ? SUCCESS : FAILURE;
}
if (zend_string_equals_literal(name, "dirname")) {
if (!IS_ABSOLUTE_PATH(ZSTR_VAL(arg), ZSTR_LEN(arg))) {

View File

@@ -80,7 +80,7 @@ static inline bool zend_optimizer_is_loop_var_free(const zend_op *opline) {
void zend_optimizer_convert_to_free_op1(const zend_op_array *op_array, zend_op *opline);
uint32_t zend_optimizer_add_literal(zend_op_array *op_array, const zval *zv);
bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int copy);
bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, bool copy);
void zend_optimizer_collect_constant(zend_optimizer_ctx *ctx, const zval *name, zval* value);
bool zend_optimizer_get_collected_constant(const HashTable *constants, const zval *name, zval* value);
zend_result zend_optimizer_eval_binary_op(zval *result, uint8_t opcode, zval *op1, zval *op2);