Skip to content

Commit eb6c74c

Browse files
committed
Move value for ARRAY_SET_PLACEHOLDER to op2, and op2.num to extended_value
1 parent 34534cf commit eb6c74c

File tree

9 files changed

+214
-210
lines changed

9 files changed

+214
-210
lines changed

Zend/Optimizer/escape_analysis.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static bool is_escape_use(zend_op_array *op_array, zend_ssa *ssa, int use, int v
317317
}
318318
ZEND_FALLTHROUGH;
319319
case ZEND_ARRAY_SET_PLACEHOLDER:
320-
if (OP1_INFO() & MAY_BE_OBJECT) {
320+
if (OP2_INFO() & MAY_BE_OBJECT) {
321321
/* object aliasing */
322322
return 1;
323323
}
@@ -495,11 +495,14 @@ zend_result zend_ssa_escape_analysis(const zend_script *script, zend_op_array *o
495495
(op-1)->op1_use >= 0) {
496496
enclosing_root = ees[(op-1)->op1_use];
497497
} else if ((opline->opcode == ZEND_INIT_ARRAY ||
498-
opline->opcode == ZEND_ADD_ARRAY_ELEMENT ||
499-
opline->opcode == ZEND_ARRAY_SET_PLACEHOLDER) &&
498+
opline->opcode == ZEND_ADD_ARRAY_ELEMENT) &&
500499
op->op1_use == i &&
501500
op->result_def >= 0) {
502501
enclosing_root = ees[op->result_def];
502+
} else if (opline->opcode == ZEND_ARRAY_SET_PLACEHOLDER
503+
&& op->op2_use == i
504+
&& op->result_def >= 0) {
505+
enclosing_root = ees[op->result_def];
503506
} else {
504507
continue;
505508
}

Zend/Optimizer/sccp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
11901190
zval *result = &ctx->values[ssa_op->result_use];
11911191

11921192
SKIP_IF_TOP(result);
1193-
SKIP_IF_TOP(op1);
1193+
SKIP_IF_TOP(op2);
11941194

11951195
#if 1
11961196
/* FIXME: See below. */
@@ -1204,12 +1204,12 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
12041204

12051205
/* FIXME: Avoid dup-ing the array in every step. */
12061206
zend_array *array = zend_array_dup(Z_ARRVAL_P(result));
1207-
zval *element = (zval*)((uintptr_t)array->arData + opline->op2.num);
1207+
zval *element = (zval*)((uintptr_t)array->arData + opline->extended_value);
12081208

12091209
zval tmp;
12101210
ZVAL_ARR(&tmp, array);
12111211

1212-
if (IS_BOT(op1)) {
1212+
if (IS_BOT(op2)) {
12131213
#if 1
12141214
/* FIXME: Handle partial arrays. Deleting hashes is problematic
12151215
* because it changes the offsets for the placeholders. */
@@ -1232,8 +1232,8 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
12321232
MAKE_PARTIAL_ARRAY(&tmp);
12331233
#endif
12341234
} else {
1235-
ZVAL_COPY(element, op1);
1236-
if (IS_PARTIAL_ARRAY(op1)) {
1235+
ZVAL_COPY(element, op2);
1236+
if (IS_PARTIAL_ARRAY(op2)) {
12371237
MAKE_PARTIAL_ARRAY(&tmp);
12381238
}
12391239
}

Zend/Optimizer/zend_inference.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3460,7 +3460,7 @@ static zend_always_inline zend_result _zend_update_type_info(
34603460
break;
34613461
}
34623462
case ZEND_ARRAY_SET_PLACEHOLDER: {
3463-
// FIXME: op1 RC inference
3463+
// FIXME: op2 RC inference
34643464
uint32_t tmp = RES_USE_INFO();
34653465
if ((tmp & MAY_BE_ARRAY_OF_ANY) == MAY_BE_ARRAY_OF_ANY) {
34663466
ZEND_ASSERT(ssa_op->result_use != -1);
@@ -3473,7 +3473,7 @@ static zend_always_inline zend_result _zend_update_type_info(
34733473
}
34743474
}
34753475
uint32_t dim_type = ((tmp & MAY_BE_ARRAY_KEY_LONG) ? MAY_BE_LONG : 0) | ((tmp & MAY_BE_ARRAY_KEY_STRING) ? MAY_BE_STRING : 0);
3476-
tmp |= assign_dim_array_result_type(tmp, dim_type, t1, IS_CONST);
3476+
tmp |= assign_dim_array_result_type(tmp, dim_type, t2, IS_CONST);
34773477
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
34783478
break;
34793479
}

Zend/zend_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10813,8 +10813,8 @@ static void zend_compile_array(znode *result, zend_ast *ast) /* {{{ */
1081310813
continue;
1081410814
}
1081510815

10816-
opline = zend_emit_op(NULL, ZEND_ARRAY_SET_PLACEHOLDER, &value_node, NULL);
10817-
opline->op2.num = (uintptr_t) element - (HT_IS_PACKED(template) ? (uintptr_t) template->arPacked : (uintptr_t) template->arData);
10816+
opline = zend_emit_op(NULL, ZEND_ARRAY_SET_PLACEHOLDER, NULL, &value_node);
10817+
opline->extended_value = (uintptr_t) element - (HT_IS_PACKED(template) ? (uintptr_t) template->arPacked : (uintptr_t) template->arData);
1081810818
SET_NODE(opline->result, result);
1081910819
} else if (opnum_init == -1) {
1082010820
opnum_init = get_next_op_number();

Zend/zend_variables.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ static const zend_rc_dtor_func_t zend_rc_dtor_func[] = {
4848
[IS_OBJECT] = (zend_rc_dtor_func_t)zend_objects_store_del,
4949
[IS_RESOURCE] = (zend_rc_dtor_func_t)zend_list_free,
5050
[IS_REFERENCE] = (zend_rc_dtor_func_t)zend_reference_destroy,
51-
[IS_CONSTANT_AST] = (zend_rc_dtor_func_t)zend_ast_ref_destroy
51+
[IS_CONSTANT_AST] = (zend_rc_dtor_func_t)zend_ast_ref_destroy,
52+
[_IS_ERROR] = (zend_rc_dtor_func_t)zend_empty_destroy,
5253
};
5354

5455
ZEND_API void ZEND_FASTCALL rc_dtor_func(zend_refcounted *p)

Zend/zend_vm_def.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6243,24 +6243,24 @@ ZEND_VM_C_LABEL(num_index):
62436243
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
62446244
}
62456245

6246-
ZEND_VM_HANDLER(211, ZEND_ARRAY_SET_PLACEHOLDER, CONST|TMP|VAR|CV, UNUSED|NUM)
6246+
ZEND_VM_HANDLER(211, ZEND_ARRAY_SET_PLACEHOLDER, UNUSED, CONST|TMP|VAR|CV, NUM)
62476247
{
62486248
USE_OPLINE
62496249
zval *expr_ptr, new_expr, *element;
62506250
zend_array *array;
62516251

62526252
SAVE_OPLINE();
62536253

6254-
expr_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
6254+
expr_ptr = GET_OP2_ZVAL_PTR(BP_VAR_R);
62556255

6256-
if (OP1_TYPE == IS_TMP_VAR) {
6256+
if (OP2_TYPE == IS_TMP_VAR) {
62576257
/* pass */
6258-
} else if (OP1_TYPE == IS_CONST) {
6258+
} else if (OP2_TYPE == IS_CONST) {
62596259
Z_TRY_ADDREF_P(expr_ptr);
6260-
} else if (OP1_TYPE == IS_CV) {
6260+
} else if (OP2_TYPE == IS_CV) {
62616261
ZVAL_DEREF(expr_ptr);
62626262
Z_TRY_ADDREF_P(expr_ptr);
6263-
} else /* if (OP1_TYPE == IS_VAR) */ {
6263+
} else /* if (OP2_TYPE == IS_VAR) */ {
62646264
if (UNEXPECTED(Z_ISREF_P(expr_ptr))) {
62656265
zend_refcounted *ref = Z_COUNTED_P(expr_ptr);
62666266

@@ -6276,7 +6276,7 @@ ZEND_VM_HANDLER(211, ZEND_ARRAY_SET_PLACEHOLDER, CONST|TMP|VAR|CV, UNUSED|NUM)
62766276
}
62776277

62786278
array = Z_ARRVAL_P(EX_VAR(opline->result.var));
6279-
element = (zval*)((uintptr_t)array->arData + opline->op2.num);
6279+
element = (zval*)((uintptr_t)array->arData + opline->extended_value);
62806280
ZVAL_COPY_VALUE(element, expr_ptr);
62816281

62826282
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();

0 commit comments

Comments
 (0)