Merge branch 'PHP-8.1'

* PHP-8.1:
  Combine ADDREF/DELREF
This commit is contained in:
Dmitry Stogov 2021-12-13 22:54:57 +03:00
commit 1959bbfc1b
3 changed files with 45 additions and 55 deletions

View File

@ -1417,7 +1417,6 @@ static zend_never_inline void zend_binary_assign_op_obj_dim(zend_object *obj, zv
zval *z;
zval rv, res;
GC_ADDREF(obj);
value = get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1);
if ((z = obj->handlers->read_dimension(obj, property, BP_VAR_R, &rv)) != NULL) {
@ -1438,9 +1437,6 @@ static zend_never_inline void zend_binary_assign_op_obj_dim(zend_object *obj, zv
}
}
FREE_OP((opline+1)->op1_type, (opline+1)->op1.var);
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
zend_objects_store_del(obj);
}
}
static zend_never_inline void zend_binary_assign_op_typed_ref(zend_reference *ref, zval *value OPLINE_DC EXECUTE_DATA_DC)

View File

@ -1145,27 +1145,6 @@ ZEND_VM_HANDLER(29, ZEND_ASSIGN_STATIC_PROP_OP, ANY, ANY, OP)
ZEND_VM_NEXT_OPCODE_EX(1, 2);
}
ZEND_VM_COLD_HELPER(zend_assign_dim_op_obj_undef_helper, ANY, ANY, zend_object *obj)
{
USE_OPLINE
zval *dim;
GC_ADDREF(obj);
dim = ZVAL_UNDEFINED_OP2();
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
zend_objects_store_del(obj);
FREE_OP_DATA();
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
ZVAL_NULL(EX_VAR(opline->result.var));
}
} else {
zend_binary_assign_op_obj_dim(obj, dim OPLINE_CC EXECUTE_DATA_CC);
}
FREE_OP2();
FREE_OP1();
ZEND_VM_NEXT_OPCODE_EX(1, 2);
}
ZEND_VM_HANDLER(27, ZEND_ASSIGN_DIM_OP, VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV, OP)
{
USE_OPLINE
@ -1226,13 +1205,17 @@ ZEND_VM_C_LABEL(assign_dim_op_new_array):
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
zend_object *obj = Z_OBJ_P(container);
GC_ADDREF(obj);
dim = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
if (OP2_TYPE == IS_CV && UNEXPECTED(Z_ISUNDEF_P(dim))) {
ZEND_VM_DISPATCH_TO_HELPER(zend_assign_dim_op_obj_undef_helper, obj, obj);
dim = ZVAL_UNDEFINED_OP2();
} else if (OP2_TYPE == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
dim++;
}
zend_binary_assign_op_obj_dim(obj, dim OPLINE_CC EXECUTE_DATA_CC);
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
zend_objects_store_del(obj);
}
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
HashTable *ht;
zend_uchar old_type;

View File

@ -799,27 +799,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_STATIC_PROP_OP_SPEC_HAN
ZEND_VM_NEXT_OPCODE_EX(1, 2);
}
static zend_never_inline ZEND_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_assign_dim_op_obj_undef_helper_SPEC(zend_object *obj ZEND_OPCODE_HANDLER_ARGS_DC)
{
USE_OPLINE
zval *dim;
GC_ADDREF(obj);
dim = ZVAL_UNDEFINED_OP2();
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
zend_objects_store_del(obj);
FREE_OP((opline+1)->op1_type, (opline+1)->op1.var);
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
ZVAL_NULL(EX_VAR(opline->result.var));
}
} else {
zend_binary_assign_op_obj_dim(obj, dim OPLINE_CC EXECUTE_DATA_CC);
}
FREE_OP(opline->op2_type, opline->op2.var);
FREE_OP(opline->op1_type, opline->op1.var);
ZEND_VM_NEXT_OPCODE_EX(1, 2);
}
static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_PRE_INC_STATIC_PROP_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
@ -22535,13 +22514,17 @@ assign_dim_op_new_array:
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
zend_object *obj = Z_OBJ_P(container);
GC_ADDREF(obj);
dim = RT_CONSTANT(opline, opline->op2);
if (IS_CONST == IS_CV && UNEXPECTED(Z_ISUNDEF_P(dim))) {
ZEND_VM_TAIL_CALL(zend_assign_dim_op_obj_undef_helper_SPEC(obj ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC));
dim = ZVAL_UNDEFINED_OP2();
} else if (IS_CONST == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
dim++;
}
zend_binary_assign_op_obj_dim(obj, dim OPLINE_CC EXECUTE_DATA_CC);
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
zend_objects_store_del(obj);
}
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
HashTable *ht;
zend_uchar old_type;
@ -25186,13 +25169,17 @@ assign_dim_op_new_array:
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
zend_object *obj = Z_OBJ_P(container);
GC_ADDREF(obj);
dim = _get_zval_ptr_var(opline->op2.var EXECUTE_DATA_CC);
if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_ISUNDEF_P(dim))) {
ZEND_VM_TAIL_CALL(zend_assign_dim_op_obj_undef_helper_SPEC(obj ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC));
dim = ZVAL_UNDEFINED_OP2();
} else if ((IS_TMP_VAR|IS_VAR) == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
dim++;
}
zend_binary_assign_op_obj_dim(obj, dim OPLINE_CC EXECUTE_DATA_CC);
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
zend_objects_store_del(obj);
}
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
HashTable *ht;
zend_uchar old_type;
@ -27475,13 +27462,17 @@ assign_dim_op_new_array:
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
zend_object *obj = Z_OBJ_P(container);
GC_ADDREF(obj);
dim = NULL;
if (IS_UNUSED == IS_CV && UNEXPECTED(Z_ISUNDEF_P(dim))) {
ZEND_VM_TAIL_CALL(zend_assign_dim_op_obj_undef_helper_SPEC(obj ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC));
dim = ZVAL_UNDEFINED_OP2();
} else if (IS_UNUSED == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
dim++;
}
zend_binary_assign_op_obj_dim(obj, dim OPLINE_CC EXECUTE_DATA_CC);
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
zend_objects_store_del(obj);
}
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
HashTable *ht;
zend_uchar old_type;
@ -29312,13 +29303,17 @@ assign_dim_op_new_array:
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
zend_object *obj = Z_OBJ_P(container);
GC_ADDREF(obj);
dim = EX_VAR(opline->op2.var);
if (IS_CV == IS_CV && UNEXPECTED(Z_ISUNDEF_P(dim))) {
ZEND_VM_TAIL_CALL(zend_assign_dim_op_obj_undef_helper_SPEC(obj ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC));
dim = ZVAL_UNDEFINED_OP2();
} else if (IS_CV == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
dim++;
}
zend_binary_assign_op_obj_dim(obj, dim OPLINE_CC EXECUTE_DATA_CC);
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
zend_objects_store_del(obj);
}
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
HashTable *ht;
zend_uchar old_type;
@ -40077,13 +40072,17 @@ assign_dim_op_new_array:
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
zend_object *obj = Z_OBJ_P(container);
GC_ADDREF(obj);
dim = RT_CONSTANT(opline, opline->op2);
if (IS_CONST == IS_CV && UNEXPECTED(Z_ISUNDEF_P(dim))) {
ZEND_VM_TAIL_CALL(zend_assign_dim_op_obj_undef_helper_SPEC(obj ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC));
dim = ZVAL_UNDEFINED_OP2();
} else if (IS_CONST == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
dim++;
}
zend_binary_assign_op_obj_dim(obj, dim OPLINE_CC EXECUTE_DATA_CC);
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
zend_objects_store_del(obj);
}
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
HashTable *ht;
zend_uchar old_type;
@ -43816,13 +43815,17 @@ assign_dim_op_new_array:
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
zend_object *obj = Z_OBJ_P(container);
GC_ADDREF(obj);
dim = _get_zval_ptr_var(opline->op2.var EXECUTE_DATA_CC);
if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_ISUNDEF_P(dim))) {
ZEND_VM_TAIL_CALL(zend_assign_dim_op_obj_undef_helper_SPEC(obj ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC));
dim = ZVAL_UNDEFINED_OP2();
} else if ((IS_TMP_VAR|IS_VAR) == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
dim++;
}
zend_binary_assign_op_obj_dim(obj, dim OPLINE_CC EXECUTE_DATA_CC);
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
zend_objects_store_del(obj);
}
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
HashTable *ht;
zend_uchar old_type;
@ -46690,13 +46693,17 @@ assign_dim_op_new_array:
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
zend_object *obj = Z_OBJ_P(container);
GC_ADDREF(obj);
dim = NULL;
if (IS_UNUSED == IS_CV && UNEXPECTED(Z_ISUNDEF_P(dim))) {
ZEND_VM_TAIL_CALL(zend_assign_dim_op_obj_undef_helper_SPEC(obj ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC));
dim = ZVAL_UNDEFINED_OP2();
} else if (IS_UNUSED == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
dim++;
}
zend_binary_assign_op_obj_dim(obj, dim OPLINE_CC EXECUTE_DATA_CC);
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
zend_objects_store_del(obj);
}
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
HashTable *ht;
zend_uchar old_type;
@ -49059,13 +49066,17 @@ assign_dim_op_new_array:
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
zend_object *obj = Z_OBJ_P(container);
GC_ADDREF(obj);
dim = EX_VAR(opline->op2.var);
if (IS_CV == IS_CV && UNEXPECTED(Z_ISUNDEF_P(dim))) {
ZEND_VM_TAIL_CALL(zend_assign_dim_op_obj_undef_helper_SPEC(obj ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC));
dim = ZVAL_UNDEFINED_OP2();
} else if (IS_CV == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
dim++;
}
zend_binary_assign_op_obj_dim(obj, dim OPLINE_CC EXECUTE_DATA_CC);
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
zend_objects_store_del(obj);
}
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
HashTable *ht;
zend_uchar old_type;