Skip to content

Commit d63a4ff

Browse files
committed
Replace ZEND_DEREF with ZEND_QM_ASSIGN
The op1=IS_VAR spec was pretty much identical, and there are most likely already better optimizations for QM_ASSIGN in place.
1 parent 545d56f commit d63a4ff

File tree

8 files changed

+568
-643
lines changed

8 files changed

+568
-643
lines changed

Zend/Optimizer/dce.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ static inline bool may_have_side_effects(
125125
case ZEND_FUNC_GET_ARGS:
126126
case ZEND_ARRAY_KEY_EXISTS:
127127
case ZEND_COPY_TMP:
128-
case ZEND_DEREF:
129128
/* No side effects */
130129
return false;
131130
case ZEND_FREE:

Zend/Optimizer/zend_inference.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5033,7 +5033,6 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
50335033
case ZEND_COPY_TMP:
50345034
case ZEND_JMP_NULL:
50355035
case ZEND_JMP_FRAMELESS:
5036-
case ZEND_DEREF:
50375036
return 0;
50385037
case ZEND_IS_IDENTICAL:
50395038
case ZEND_IS_NOT_IDENTICAL:

Zend/zend_compile.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,7 +3407,8 @@ static void zend_compile_list_assign(
34073407

34083408
if (result) {
34093409
if ((type == BP_VAR_R || type == BP_VAR_IS) && expr_node->op_type == IS_VAR) {
3410-
zend_emit_op_tmp(result, ZEND_DEREF, expr_node, NULL);
3410+
/* Deref. */
3411+
zend_emit_op_tmp(result, ZEND_QM_ASSIGN, expr_node, NULL);
34113412
} else {
34123413
*result = *expr_node;
34133414
}
@@ -3650,8 +3651,9 @@ static void zend_compile_assign_ref(znode *result, zend_ast *ast, uint32_t type)
36503651
}
36513652

36523653
if (result && (type == BP_VAR_R || type == BP_VAR_IS)) {
3654+
/* Deref. */
36533655
znode tmp_result = *result;
3654-
zend_emit_op_tmp(result, ZEND_DEREF, &tmp_result, NULL);
3656+
zend_emit_op_tmp(result, ZEND_QM_ASSIGN, &tmp_result, NULL);
36553657
}
36563658
}
36573659
/* }}} */
@@ -10729,7 +10731,7 @@ static void zend_compile_conditional(znode *result, zend_ast *ast) /* {{{ */
1072910731

1073010732
zend_compile_expr(&false_node, false_ast);
1073110733

10732-
opline_qm_assign2 = zend_emit_op(NULL, ZEND_QM_ASSIGN, &false_node, NULL);
10734+
opline_qm_assign2 = zend_emit_op_tmp(NULL, ZEND_QM_ASSIGN, &false_node, NULL);
1073310735
SET_NODE(opline_qm_assign2->result, result);
1073410736

1073510737
zend_update_jump_target_to_next(opnum_jmp);

Zend/zend_vm_def.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10006,27 +10006,6 @@ ZEND_VM_HANDLER(209, ZEND_INIT_PARENT_PROPERTY_HOOK_CALL, CONST, UNUSED|NUM, NUM
1000610006
ZEND_VM_NEXT_OPCODE();
1000710007
}
1000810008

10009-
ZEND_VM_HANDLER(211, ZEND_DEREF, VAR, UNUSED)
10010-
{
10011-
USE_OPLINE
10012-
10013-
zval *value = GET_OP1_ZVAL_PTR(BP_VAR_R);
10014-
10015-
if (Z_TYPE_P(value) == IS_REFERENCE) {
10016-
zend_reference *ref = Z_REF_P(value);
10017-
ZVAL_COPY_VALUE(EX_VAR(opline->result.var), &ref->val);
10018-
if (GC_DELREF(ref) == 0) {
10019-
efree_size(ref, sizeof(zend_reference));
10020-
} else {
10021-
Z_TRY_ADDREF_P(EX_VAR(opline->result.var));
10022-
}
10023-
} else {
10024-
ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
10025-
}
10026-
10027-
ZEND_VM_NEXT_OPCODE();
10028-
}
10029-
1003010009
ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_JMP, (OP_JMP_ADDR(op, op->op1) > op), ZEND_JMP_FORWARD, JMP_ADDR, ANY)
1003110010
{
1003210011
USE_OPLINE

0 commit comments

Comments
 (0)