Skip to content

Commit 99658f6

Browse files
committed
Improve zend_check_live_ranges()
1 parent be4c67a commit 99658f6

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

Zend/zend_compile.c

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,10 +1913,9 @@ static zend_always_inline int zend_is_def_range(zend_op *opline, zend_uchar type
19131913
}
19141914
/* }}} */
19151915

1916-
static void zend_check_live_ranges(zend_op *opline) /* {{{ */
1916+
static void zend_check_live_ranges_op1(zend_op *opline) /* {{{ */
19171917
{
1918-
if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) &&
1919-
!zend_is_def_range(opline - 1, opline->op1_type, opline->op1.var)) {
1918+
if (!zend_is_def_range(opline - 1, opline->op1_type, opline->op1.var)) {
19201919

19211920
if (opline->opcode == ZEND_OP_DATA) {
19221921
if (!zend_is_def_range(opline - 2, opline->op1_type, opline->op1.var)) {
@@ -1946,9 +1945,12 @@ static void zend_check_live_ranges(zend_op *opline) /* {{{ */
19461945
zend_find_live_range(opline, opline->op1_type, opline->op1.var);
19471946
}
19481947
}
1948+
}
1949+
/* }}} */
19491950

1950-
if ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) &&
1951-
!zend_is_def_range(opline - 1, opline->op2_type, opline->op2.var)) {
1951+
static void zend_check_live_ranges_op2(zend_op *opline) /* {{{ */
1952+
{
1953+
if (!zend_is_def_range(opline - 1, opline->op2_type, opline->op2.var)) {
19521954

19531955
if (opline->opcode == ZEND_OP_DATA) {
19541956
if (!zend_is_def_range(opline - 2, opline->op2_type, opline->op2.var)) {
@@ -1971,21 +1973,36 @@ static void zend_check_live_ranges(zend_op *opline) /* {{{ */
19711973
}
19721974
/* }}} */
19731975

1976+
static void zend_check_live_ranges(zend_op *opline) /* {{{ */
1977+
{
1978+
if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
1979+
zend_check_live_ranges_op1(opline);
1980+
}
1981+
if (opline->op2_type & (IS_VAR|IS_TMP_VAR)) {
1982+
zend_check_live_ranges_op2(opline);
1983+
}
1984+
}
1985+
/* }}} */
1986+
19741987
static zend_op *zend_emit_op(znode *result, zend_uchar opcode, znode *op1, znode *op2) /* {{{ */
19751988
{
19761989
zend_op *opline = get_next_op();
19771990
opline->opcode = opcode;
19781991

19791992
if (op1 != NULL) {
19801993
SET_NODE(opline->op1, op1);
1994+
if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
1995+
zend_check_live_ranges_op1(opline);
1996+
}
19811997
}
19821998

19831999
if (op2 != NULL) {
19842000
SET_NODE(opline->op2, op2);
2001+
if (opline->op2_type & (IS_VAR|IS_TMP_VAR)) {
2002+
zend_check_live_ranges_op2(opline);
2003+
}
19852004
}
19862005

1987-
zend_check_live_ranges(opline);
1988-
19892006
if (result) {
19902007
zend_make_var_result(result, opline);
19912008
}
@@ -2000,14 +2017,18 @@ static zend_op *zend_emit_op_tmp(znode *result, zend_uchar opcode, znode *op1, z
20002017

20012018
if (op1 != NULL) {
20022019
SET_NODE(opline->op1, op1);
2020+
if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
2021+
zend_check_live_ranges_op1(opline);
2022+
}
20032023
}
20042024

20052025
if (op2 != NULL) {
20062026
SET_NODE(opline->op2, op2);
2027+
if (opline->op2_type & (IS_VAR|IS_TMP_VAR)) {
2028+
zend_check_live_ranges_op2(opline);
2029+
}
20072030
}
20082031

2009-
zend_check_live_ranges(opline);
2010-
20112032
if (result) {
20122033
zend_make_tmp_result(result, opline);
20132034
}

0 commit comments

Comments
 (0)