1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 18:53:33 +02:00

Partial revert of 30156d588c

This commit is contained in:
Dmitry Stogov
2018-07-02 20:54:44 +03:00
parent 30156d588c
commit 57af94c8b9
6 changed files with 139 additions and 85 deletions
+1
View File
@@ -2672,6 +2672,7 @@ static zend_op *zend_delayed_compile_dim(znode *result, zend_ast *ast, uint32_t
dim_node.op_type = IS_UNUSED;
} else {
zend_compile_expr(&dim_node, dim_ast);
zend_handle_numeric_op(&dim_node);
}
opline = zend_delayed_emit_op(result, ZEND_FETCH_DIM_R, &var_node, &dim_node);
+4 -2
View File
@@ -1731,8 +1731,10 @@ num_undef:
}
} else if (EXPECTED(Z_TYPE_P(dim) == IS_STRING)) {
offset_key = Z_STR_P(dim);
if (ZEND_HANDLE_NUMERIC(offset_key, hval)) {
goto num_index;
if (dim_type != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(offset_key, hval)) {
goto num_index;
}
}
str_index:
retval = zend_hash_find_ex(ht, offset_key, dim_type == IS_CONST);
+8 -4
View File
@@ -5538,8 +5538,10 @@ ZEND_VM_C_LABEL(unset_dim_array):
ZEND_VM_C_LABEL(offset_again):
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
key = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(key, hval)) {
ZEND_VM_C_GOTO(num_index_dim);
if (OP2_TYPE != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(key, hval)) {
ZEND_VM_C_GOTO(num_index_dim);
}
}
ZEND_VM_C_LABEL(str_index_dim):
if (ht == &EG(symbol_table)) {
@@ -6284,8 +6286,10 @@ ZEND_VM_C_LABEL(isset_dim_obj_array):
ZEND_VM_C_LABEL(isset_again):
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
str = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(str, hval)) {
ZEND_VM_C_GOTO(num_index_prop);
if (OP2_TYPE != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(str, hval)) {
ZEND_VM_C_GOTO(num_index_prop);
}
}
value = zend_hash_find_ex_ind(ht, str, OP2_TYPE == IS_CONST);
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
+60 -30
View File
@@ -5738,8 +5738,10 @@ isset_dim_obj_array:
isset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
str = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
if (IS_CONST != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
}
}
value = zend_hash_find_ex_ind(ht, str, IS_CONST == IS_CONST);
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
@@ -7630,8 +7632,10 @@ isset_dim_obj_array:
isset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
str = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
if ((IS_TMP_VAR|IS_VAR) != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
}
}
value = zend_hash_find_ex_ind(ht, str, (IS_TMP_VAR|IS_VAR) == IS_CONST);
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
@@ -10712,8 +10716,10 @@ isset_dim_obj_array:
isset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
str = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
if (IS_CV != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
}
}
value = zend_hash_find_ex_ind(ht, str, IS_CV == IS_CONST);
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
@@ -14248,8 +14254,10 @@ isset_dim_obj_array:
isset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
str = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
if (IS_CONST != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
}
}
value = zend_hash_find_ex_ind(ht, str, IS_CONST == IS_CONST);
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
@@ -15708,8 +15716,10 @@ isset_dim_obj_array:
isset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
str = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
if ((IS_TMP_VAR|IS_VAR) != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
}
}
value = zend_hash_find_ex_ind(ht, str, (IS_TMP_VAR|IS_VAR) == IS_CONST);
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
@@ -17572,8 +17582,10 @@ isset_dim_obj_array:
isset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
str = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
if (IS_CV != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
}
}
value = zend_hash_find_ex_ind(ht, str, IS_CV == IS_CONST);
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
@@ -23833,8 +23845,10 @@ unset_dim_array:
offset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
key = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(key, hval)) {
goto num_index_dim;
if (IS_CONST != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(key, hval)) {
goto num_index_dim;
}
}
str_index_dim:
if (ht == &EG(symbol_table)) {
@@ -25976,8 +25990,10 @@ unset_dim_array:
offset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
key = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(key, hval)) {
goto num_index_dim;
if ((IS_TMP_VAR|IS_VAR) != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(key, hval)) {
goto num_index_dim;
}
}
str_index_dim:
if (ht == &EG(symbol_table)) {
@@ -29778,8 +29794,10 @@ unset_dim_array:
offset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
key = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(key, hval)) {
goto num_index_dim;
if (IS_CV != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(key, hval)) {
goto num_index_dim;
}
}
str_index_dim:
if (ht == &EG(symbol_table)) {
@@ -40829,8 +40847,10 @@ unset_dim_array:
offset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
key = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(key, hval)) {
goto num_index_dim;
if (IS_CONST != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(key, hval)) {
goto num_index_dim;
}
}
str_index_dim:
if (ht == &EG(symbol_table)) {
@@ -41030,8 +41050,10 @@ isset_dim_obj_array:
isset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
str = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
if (IS_CONST != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
}
}
value = zend_hash_find_ex_ind(ht, str, IS_CONST == IS_CONST);
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
@@ -44445,8 +44467,10 @@ unset_dim_array:
offset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
key = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(key, hval)) {
goto num_index_dim;
if ((IS_TMP_VAR|IS_VAR) != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(key, hval)) {
goto num_index_dim;
}
}
str_index_dim:
if (ht == &EG(symbol_table)) {
@@ -44572,8 +44596,10 @@ isset_dim_obj_array:
isset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
str = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
if ((IS_TMP_VAR|IS_VAR) != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
}
}
value = zend_hash_find_ex_ind(ht, str, (IS_TMP_VAR|IS_VAR) == IS_CONST);
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
@@ -50058,8 +50084,10 @@ unset_dim_array:
offset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
key = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(key, hval)) {
goto num_index_dim;
if (IS_CV != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(key, hval)) {
goto num_index_dim;
}
}
str_index_dim:
if (ht == &EG(symbol_table)) {
@@ -50183,8 +50211,10 @@ isset_dim_obj_array:
isset_again:
if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
str = Z_STR_P(offset);
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
if (IS_CV != IS_CONST) {
if (ZEND_HANDLE_NUMERIC(str, hval)) {
goto num_index_prop;
}
}
value = zend_hash_find_ex_ind(ht, str, IS_CV == IS_CONST);
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
+54 -49
View File
@@ -169,10 +169,6 @@ static inline zend_bool sub_will_overflow(zend_long a, zend_long b) {
}
#endif
#define DIM_OP_FOR_CONST_NUM_CHECK \
(opline->op2_type == IS_CONST ? CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants) : NULL)
static void zend_ssa_check_scc_var(const zend_op_array *op_array, zend_ssa *ssa, int var, int *index, int *dfs, int *root, zend_worklist_stack *stack) /* {{{ */
{
#ifdef SYM_RANGE
@@ -2089,43 +2085,8 @@ uint32_t zend_array_element_type(uint32_t t1, int write, int insert)
return tmp;
}
static inline uint32_t get_dim_array_key_type(uint32_t dim_type, zend_uchar dim_op_type, zval *dim_op)
{
uint32_t tmp = 0;
if (dim_op_type == IS_UNUSED) {
tmp |= MAY_BE_ARRAY_KEY_LONG;
} else {
if (dim_type & (MAY_BE_LONG|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_RESOURCE|MAY_BE_DOUBLE)) {
tmp |= MAY_BE_ARRAY_KEY_LONG;
}
if (dim_type & MAY_BE_STRING) {
if (dim_op_type != IS_CONST) {
tmp |= MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_KEY_LONG;
} else {
zend_ulong hval;
if (ZEND_HANDLE_NUMERIC(Z_STR_P(dim_op), hval)) {
tmp |= MAY_BE_ARRAY_KEY_LONG;
} else {
tmp |= MAY_BE_ARRAY_KEY_STRING;
}
}
}
if (dim_type & (MAY_BE_UNDEF|MAY_BE_NULL)) {
tmp |= MAY_BE_ARRAY_KEY_STRING;
}
}
return tmp;
}
static uint32_t assign_dim_result_type(
uint32_t arr_type,
uint32_t dim_type,
uint32_t value_type,
zend_uchar dim_op_type,
zval *dim_op
) {
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, zend_uchar dim_op_type) {
uint32_t tmp = arr_type & ~(MAY_BE_RC1|MAY_BE_RCN);
if (arr_type & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {
@@ -2143,7 +2104,23 @@ static uint32_t assign_dim_result_type(
if (value_type & MAY_BE_UNDEF) {
tmp |= MAY_BE_ARRAY_OF_NULL;
}
tmp |= get_dim_array_key_type(dim_type, dim_op_type, dim_op);
if (dim_op_type == IS_UNUSED) {
tmp |= MAY_BE_ARRAY_KEY_LONG;
} else {
if (dim_type & (MAY_BE_LONG|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_RESOURCE|MAY_BE_DOUBLE)) {
tmp |= MAY_BE_ARRAY_KEY_LONG;
}
if (dim_type & MAY_BE_STRING) {
tmp |= MAY_BE_ARRAY_KEY_STRING;
if (dim_op_type != IS_CONST) {
// FIXME: numeric string
tmp |= MAY_BE_ARRAY_KEY_LONG;
}
}
if (dim_type & (MAY_BE_UNDEF|MAY_BE_NULL)) {
tmp |= MAY_BE_ARRAY_KEY_STRING;
}
}
}
return tmp;
}
@@ -2519,8 +2496,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
if (opline->extended_value == ZEND_ASSIGN_DIM) {
if (opline->op1_type == IS_CV) {
orig = assign_dim_result_type(orig, OP2_INFO(), tmp, opline->op2_type, DIM_OP_FOR_CONST_NUM_CHECK);
orig = assign_dim_result_type(orig, OP2_INFO(), tmp, opline->op2_type);
UPDATE_SSA_TYPE(orig, ssa_ops[i].op1_def);
COPY_SSA_OBJ_TYPE(ssa_ops[i].op1_use, ssa_ops[i].op1_def);
}
@@ -2682,8 +2658,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
break;
case ZEND_ASSIGN_DIM:
if (opline->op1_type == IS_CV) {
tmp = assign_dim_result_type(t1, t2, OP1_DATA_INFO(), opline->op2_type, DIM_OP_FOR_CONST_NUM_CHECK);
tmp = assign_dim_result_type(t1, t2, OP1_DATA_INFO(), opline->op2_type);
UPDATE_SSA_TYPE(tmp, ssa_ops[i].op1_def);
COPY_SSA_OBJ_TYPE(ssa_ops[i].op1_use, ssa_ops[i].op1_def);
}
@@ -3082,8 +3057,23 @@ static int zend_update_type_info(const zend_op_array *op_array,
if (ssa_ops[i].result_use >= 0) {
tmp |= ssa_var_info[ssa_ops[i].result_use].type;
}
tmp |= get_dim_array_key_type(t2, opline->op2_type, DIM_OP_FOR_CONST_NUM_CHECK);
if (opline->op2_type == IS_UNUSED) {
tmp |= MAY_BE_ARRAY_KEY_LONG;
} else {
if (t2 & (MAY_BE_LONG|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_DOUBLE)) {
tmp |= MAY_BE_ARRAY_KEY_LONG;
}
if (t2 & (MAY_BE_STRING)) {
tmp |= MAY_BE_ARRAY_KEY_STRING;
if (opline->op2_type != IS_CONST) {
// FIXME: numeric string
tmp |= MAY_BE_ARRAY_KEY_LONG;
}
}
if (t2 & (MAY_BE_UNDEF | MAY_BE_NULL)) {
tmp |= MAY_BE_ARRAY_KEY_STRING;
}
}
UPDATE_SSA_TYPE(tmp, ssa_ops[i].result_def);
}
break;
@@ -3196,8 +3186,23 @@ static int zend_update_type_info(const zend_op_array *op_array,
if (t1 & (MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
tmp |= t1 & (MAY_BE_RC1|MAY_BE_RCN);
}
tmp |= get_dim_array_key_type(t2, opline->op2_type, DIM_OP_FOR_CONST_NUM_CHECK);
if (opline->op2_type == IS_UNUSED) {
tmp |= MAY_BE_ARRAY_KEY_LONG;
} else {
if (t2 & (MAY_BE_LONG|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_RESOURCE|MAY_BE_DOUBLE)) {
tmp |= MAY_BE_ARRAY_KEY_LONG;
}
if (t2 & MAY_BE_STRING) {
tmp |= MAY_BE_ARRAY_KEY_STRING;
if (opline->op2_type != IS_CONST) {
// FIXME: numeric string
tmp |= MAY_BE_ARRAY_KEY_LONG;
}
}
if (t2 & (MAY_BE_UNDEF | MAY_BE_NULL)) {
tmp |= MAY_BE_ARRAY_KEY_STRING;
}
}
} else if (opline->opcode == ZEND_FETCH_DIM_UNSET) {
if (t1 & MAY_BE_ARRAY) {
tmp |= MAY_BE_RC1;
+12
View File
@@ -518,7 +518,19 @@ int zend_optimizer_update_op2_const(zend_op_array *op_array,
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
}
break;
case ZEND_ISSET_ISEMPTY_DIM_OBJ:
case ZEND_ADD_ARRAY_ELEMENT:
case ZEND_INIT_ARRAY:
case ZEND_ASSIGN_DIM:
case ZEND_UNSET_DIM:
case ZEND_FETCH_DIM_R:
case ZEND_FETCH_DIM_W:
case ZEND_FETCH_DIM_RW:
case ZEND_FETCH_DIM_IS:
case ZEND_FETCH_DIM_FUNC_ARG:
case ZEND_FETCH_DIM_UNSET:
case ZEND_FETCH_LIST_R:
case ZEND_FETCH_LIST_W:
if (Z_TYPE_P(val) == IS_STRING) {
zend_ulong index;
if (ZEND_HANDLE_NUMERIC(Z_STR_P(val), index)) {