Skip to content

Commit 51442a4

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Separate "cold" and common unspecialized code
2 parents b40be87 + ee58282 commit 51442a4

File tree

3 files changed

+131
-235
lines changed

3 files changed

+131
-235
lines changed

Zend/zend_execute.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,11 +1337,14 @@ static zend_always_inline int zend_binary_op(zval *ret, zval *op1, zval *op2 OPL
13371337
return zend_binary_ops[opcode - ZEND_ADD](ret, op1, op2);
13381338
}
13391339

1340-
static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval *property, zval *value OPLINE_DC EXECUTE_DATA_DC)
1340+
static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval *property OPLINE_DC EXECUTE_DATA_DC)
13411341
{
1342+
zend_free_op free_op_data1;
1343+
zval *value;
13421344
zval *z;
13431345
zval rv, res;
13441346

1347+
value = get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, &free_op_data1);
13451348
if ((z = Z_OBJ_HT_P(object)->read_dimension(Z_OBJ_P(object), property, BP_VAR_R, &rv)) != NULL) {
13461349

13471350
if (zend_binary_op(&res, z, value OPLINE_CC) == SUCCESS) {
@@ -1360,6 +1363,7 @@ static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval *
13601363
ZVAL_NULL(EX_VAR(opline->result.var));
13611364
}
13621365
}
1366+
FREE_OP(free_op_data1);
13631367
}
13641368

13651369
static zend_never_inline void zend_binary_assign_op_typed_ref(zend_reference *ref, zval *value OPLINE_DC EXECUTE_DATA_DC)
@@ -1984,6 +1988,24 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_new_element_for_s
19841988
zend_throw_error(NULL, "[] operator not supported for strings");
19851989
}
19861990

1991+
static ZEND_COLD void zend_binary_assign_op_dim_slow(zval *container, zval *dim OPLINE_DC EXECUTE_DATA_DC)
1992+
{
1993+
zend_free_op free_op_data1;
1994+
1995+
if (UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) {
1996+
if (opline->op2_type == IS_UNUSED) {
1997+
zend_use_new_element_for_string();
1998+
} else {
1999+
zend_check_string_offset(dim, BP_VAR_RW EXECUTE_DATA_CC);
2000+
zend_wrong_string_offset(EXECUTE_DATA_C);
2001+
}
2002+
} else if (EXPECTED(!Z_ISERROR_P(container))) {
2003+
zend_use_scalar_as_array();
2004+
}
2005+
get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, &free_op_data1);
2006+
FREE_OP(free_op_data1);
2007+
}
2008+
19872009
static zend_never_inline zend_uchar slow_index_convert(const zval *dim, zend_value *value EXECUTE_DATA_DC)
19882010
{
19892011
switch (Z_TYPE_P(dim)) {

Zend/zend_vm_def.h

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,7 @@ ZEND_VM_C_LABEL(assign_dim_op_new_array):
12681268
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
12691269
ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
12701270
}
1271+
FREE_OP(free_op_data1);
12711272
} else {
12721273
if (EXPECTED(Z_ISREF_P(container))) {
12731274
container = Z_REFVAL_P(container);
@@ -1279,42 +1280,27 @@ ZEND_VM_C_LABEL(assign_dim_op_new_array):
12791280
dim = GET_OP2_ZVAL_PTR(BP_VAR_R);
12801281

12811282
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
1282-
value = get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, &free_op_data1);
12831283
if (OP2_TYPE == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
12841284
dim++;
12851285
}
1286-
zend_binary_assign_op_obj_dim(container, dim, value OPLINE_CC EXECUTE_DATA_CC);
1286+
zend_binary_assign_op_obj_dim(container, dim OPLINE_CC EXECUTE_DATA_CC);
1287+
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
1288+
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
1289+
ZVAL_NULL(container);
1290+
ZVAL_UNDEFINED_OP1();
1291+
}
1292+
ZVAL_ARR(container, zend_new_array(8));
1293+
ZEND_VM_C_GOTO(assign_dim_op_new_array);
12871294
} else {
1288-
if (UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) {
1289-
if (OP2_TYPE == IS_UNUSED) {
1290-
zend_use_new_element_for_string();
1291-
} else {
1292-
zend_check_string_offset(dim, BP_VAR_RW EXECUTE_DATA_CC);
1293-
zend_wrong_string_offset(EXECUTE_DATA_C);
1294-
}
1295-
UNDEF_RESULT();
1296-
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
1297-
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
1298-
ZVAL_NULL(container);
1299-
ZVAL_UNDEFINED_OP1();
1300-
}
1301-
ZVAL_ARR(container, zend_new_array(8));
1302-
ZEND_VM_C_GOTO(assign_dim_op_new_array);
1303-
} else {
1304-
if (UNEXPECTED(OP1_TYPE != IS_VAR || EXPECTED(!Z_ISERROR_P(container)))) {
1305-
zend_use_scalar_as_array();
1306-
}
1295+
zend_binary_assign_op_dim_slow(container, dim OPLINE_CC EXECUTE_DATA_CC);
13071296
ZEND_VM_C_LABEL(assign_dim_op_ret_null):
1308-
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1309-
ZVAL_NULL(EX_VAR(opline->result.var));
1310-
}
1297+
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1298+
ZVAL_NULL(EX_VAR(opline->result.var));
13111299
}
1312-
value = get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, &free_op_data1);
13131300
}
13141301
}
13151302

13161303
FREE_OP2();
1317-
FREE_OP(free_op_data1);
13181304
FREE_OP1_VAR_PTR();
13191305
ZEND_VM_NEXT_OPCODE_EX(1, 2);
13201306
}

0 commit comments

Comments
 (0)