Skip to content

Commit 055b632

Browse files
committed
Fixed return operand type (Use IS_TMP_VAR instead of IS_VAR in the same way as it was before AST patch)
1 parent 7cbbb37 commit 055b632

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

Zend/zend_compile.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3970,12 +3970,17 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc TSRMLS_DC) {
39703970
if (zend_is_variable(arg)) {
39713971
if (zend_is_call(arg)) {
39723972
zend_compile_var(&arg_node, arg, BP_VAR_R TSRMLS_CC);
3973-
opcode = ZEND_SEND_VAR_NO_REF;
3974-
flags |= ZEND_ARG_SEND_FUNCTION;
3975-
if (fbc && ARG_SHOULD_BE_SENT_BY_REF(fbc, arg_num)) {
3976-
flags |= ZEND_ARG_SEND_BY_REF;
3977-
if (ARG_MAY_BE_SENT_BY_REF(fbc, arg_num)) {
3978-
flags |= ZEND_ARG_SEND_SILENT;
3973+
if (arg_node.op_type & (IS_CONST|IS_TMP_VAR)) {
3974+
/* Function call was converted into builtin instruction */
3975+
opcode = ZEND_SEND_VAL;
3976+
} else {
3977+
opcode = ZEND_SEND_VAR_NO_REF;
3978+
flags |= ZEND_ARG_SEND_FUNCTION;
3979+
if (fbc && ARG_SHOULD_BE_SENT_BY_REF(fbc, arg_num)) {
3980+
flags |= ZEND_ARG_SEND_BY_REF;
3981+
if (ARG_MAY_BE_SENT_BY_REF(fbc, arg_num)) {
3982+
flags |= ZEND_ARG_SEND_SILENT;
3983+
}
39793984
}
39803985
}
39813986
} else if (fbc) {
@@ -4108,7 +4113,7 @@ int zend_compile_func_strlen(znode *result, zend_ast_list *args TSRMLS_DC) {
41084113
}
41094114

41104115
zend_compile_expr(&arg_node, args->child[0] TSRMLS_CC);
4111-
zend_emit_op(result, ZEND_STRLEN, &arg_node, NULL TSRMLS_CC);
4116+
zend_emit_op_tmp(result, ZEND_STRLEN, &arg_node, NULL TSRMLS_CC);
41124117
return SUCCESS;
41134118
}
41144119

@@ -4121,7 +4126,7 @@ int zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t typ
41214126
}
41224127

41234128
zend_compile_expr(&arg_node, args->child[0] TSRMLS_CC);
4124-
opline = zend_emit_op(result, ZEND_TYPE_CHECK, &arg_node, NULL TSRMLS_CC);
4129+
opline = zend_emit_op_tmp(result, ZEND_TYPE_CHECK, &arg_node, NULL TSRMLS_CC);
41254130
opline->extended_value = type;
41264131
return SUCCESS;
41274132
}
@@ -4140,7 +4145,7 @@ int zend_compile_func_defined(znode *result, zend_ast_list *args TSRMLS_DC) {
41404145
return FAILURE;
41414146
}
41424147

4143-
opline = zend_emit_op(result, ZEND_DEFINED, NULL, NULL TSRMLS_CC);
4148+
opline = zend_emit_op_tmp(result, ZEND_DEFINED, NULL, NULL TSRMLS_CC);
41444149
opline->op1_type = IS_CONST;
41454150
LITERAL_STR(opline->op1, name);
41464151
zend_alloc_cache_slot(opline->op1.constant TSRMLS_CC);
@@ -6857,7 +6862,7 @@ void zend_compile_isset_or_empty(znode *result, zend_ast *ast TSRMLS_DC) {
68576862
EMPTY_SWITCH_DEFAULT_CASE()
68586863
}
68596864

6860-
opline->result_type = IS_TMP_VAR;
6865+
result->op_type = opline->result_type = IS_TMP_VAR;
68616866
opline->extended_value |= ast->kind == ZEND_AST_ISSET ? ZEND_ISSET : ZEND_ISEMPTY;
68626867
}
68636868

ext/opcache/Optimizer/pass1_5.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
472472
zval t;
473473

474474
ZVAL_LONG(&t, Z_STRLEN(ZEND_OP1_LITERAL(opline)));
475-
replace_var_by_const(op_array, opline + 1, ZEND_RESULT(opline).var, &t TSRMLS_CC);
475+
replace_tmp_by_const(op_array, opline + 1, ZEND_RESULT(opline).var, &t TSRMLS_CC);
476476
literal_dtor(&ZEND_OP1_LITERAL(opline));
477477
MAKE_NOP(opline);
478478
}
@@ -485,7 +485,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
485485
break;
486486
}
487487
ZVAL_TRUE(&c);
488-
replace_var_by_const(op_array, opline, tv, &c TSRMLS_CC);
488+
replace_tmp_by_const(op_array, opline, tv, &c TSRMLS_CC);
489489
literal_dtor(&ZEND_OP1_LITERAL(opline));
490490
MAKE_NOP(opline);
491491
}

0 commit comments

Comments
 (0)