Skip to content

Commit ee58282

Browse files
committed
Separate "cold" and common unspecialized code
1 parent a520974 commit ee58282

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
@@ -1313,11 +1313,14 @@ static zend_always_inline int zend_binary_op(zval *ret, zval *op1, zval *op2 OPL
13131313
return zend_binary_ops[opcode - ZEND_ADD](ret, op1, op2);
13141314
}
13151315

1316-
static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval *property, zval *value OPLINE_DC EXECUTE_DATA_DC)
1316+
static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval *property OPLINE_DC EXECUTE_DATA_DC)
13171317
{
1318+
zend_free_op free_op_data1;
1319+
zval *value;
13181320
zval *z;
13191321
zval rv, res;
13201322

1323+
value = get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, &free_op_data1);
13211324
if ((z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_R, &rv)) != NULL) {
13221325

13231326
if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {
@@ -1345,6 +1348,7 @@ static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval *
13451348
ZVAL_NULL(EX_VAR(opline->result.var));
13461349
}
13471350
}
1351+
FREE_OP(free_op_data1);
13481352
}
13491353

13501354
static zend_never_inline void zend_binary_assign_op_typed_ref(zend_reference *ref, zval *value OPLINE_DC EXECUTE_DATA_DC)
@@ -2005,6 +2009,24 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_new_element_for_s
20052009
zend_throw_error(NULL, "[] operator not supported for strings");
20062010
}
20072011

2012+
static ZEND_COLD void zend_binary_assign_op_dim_slow(zval *container, zval *dim OPLINE_DC EXECUTE_DATA_DC)
2013+
{
2014+
zend_free_op free_op_data1;
2015+
2016+
if (UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) {
2017+
if (opline->op2_type == IS_UNUSED) {
2018+
zend_use_new_element_for_string();
2019+
} else {
2020+
zend_check_string_offset(dim, BP_VAR_RW EXECUTE_DATA_CC);
2021+
zend_wrong_string_offset(EXECUTE_DATA_C);
2022+
}
2023+
} else if (EXPECTED(!Z_ISERROR_P(container))) {
2024+
zend_use_scalar_as_array();
2025+
}
2026+
get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, &free_op_data1);
2027+
FREE_OP(free_op_data1);
2028+
}
2029+
20082030
static zend_never_inline zend_uchar slow_index_convert(const zval *dim, zend_value *value EXECUTE_DATA_DC)
20092031
{
20102032
switch (Z_TYPE_P(dim)) {

Zend/zend_vm_def.h

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,7 @@ ZEND_VM_C_LABEL(assign_dim_op_new_array):
12531253
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
12541254
ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
12551255
}
1256+
FREE_OP(free_op_data1);
12561257
} else {
12571258
if (EXPECTED(Z_ISREF_P(container))) {
12581259
container = Z_REFVAL_P(container);
@@ -1264,42 +1265,27 @@ ZEND_VM_C_LABEL(assign_dim_op_new_array):
12641265
dim = GET_OP2_ZVAL_PTR(BP_VAR_R);
12651266

12661267
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
1267-
value = get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, &free_op_data1);
12681268
if (OP2_TYPE == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
12691269
dim++;
12701270
}
1271-
zend_binary_assign_op_obj_dim(container, dim, value OPLINE_CC EXECUTE_DATA_CC);
1271+
zend_binary_assign_op_obj_dim(container, dim OPLINE_CC EXECUTE_DATA_CC);
1272+
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
1273+
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
1274+
ZVAL_NULL(container);
1275+
ZVAL_UNDEFINED_OP1();
1276+
}
1277+
ZVAL_ARR(container, zend_new_array(8));
1278+
ZEND_VM_C_GOTO(assign_dim_op_new_array);
12721279
} else {
1273-
if (UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) {
1274-
if (OP2_TYPE == IS_UNUSED) {
1275-
zend_use_new_element_for_string();
1276-
} else {
1277-
zend_check_string_offset(dim, BP_VAR_RW EXECUTE_DATA_CC);
1278-
zend_wrong_string_offset(EXECUTE_DATA_C);
1279-
}
1280-
UNDEF_RESULT();
1281-
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
1282-
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
1283-
ZVAL_NULL(container);
1284-
ZVAL_UNDEFINED_OP1();
1285-
}
1286-
ZVAL_ARR(container, zend_new_array(8));
1287-
ZEND_VM_C_GOTO(assign_dim_op_new_array);
1288-
} else {
1289-
if (UNEXPECTED(OP1_TYPE != IS_VAR || EXPECTED(!Z_ISERROR_P(container)))) {
1290-
zend_use_scalar_as_array();
1291-
}
1280+
zend_binary_assign_op_dim_slow(container, dim OPLINE_CC EXECUTE_DATA_CC);
12921281
ZEND_VM_C_LABEL(assign_dim_op_ret_null):
1293-
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1294-
ZVAL_NULL(EX_VAR(opline->result.var));
1295-
}
1282+
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1283+
ZVAL_NULL(EX_VAR(opline->result.var));
12961284
}
1297-
value = get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, &free_op_data1);
12981285
}
12991286
}
13001287

13011288
FREE_OP2();
1302-
FREE_OP(free_op_data1);
13031289
FREE_OP1_VAR_PTR();
13041290
ZEND_VM_NEXT_OPCODE_EX(1, 2);
13051291
}

0 commit comments

Comments
 (0)