com php-src: Remove dead allocations of non-escaping objects: ext/opcache/Optimizer/dce.c ext/opcache/tests/opt/dce_00 5.phpt
ext/opcache/tests/opt/sccp_010.phpt ex t/opcache/tests/opt/sccp_011.phpt ext/opcache/tests /opt/sccp_012.phpt

From: Date: Fri, 01 Sep 2017 07:32:20 +0000
Subject: com php-src: Remove dead allocations of non-escaping objects: ext/opcache/Optimizer/dce.c ext/opcache/tests/opt/dce_00 5.phpt
ext/opcache/tests/opt/sccp_010.phpt ex t/opcache/tests/opt/sccp_011.phpt ext/opcache/tests /opt/sccp_012.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-99222@lists.php.net to get a copy of this message
Commit: becb4d6d5902a1d2f753d503cbbad953765355e8 Author: Dmitry Stogov <dmitry@zend.com> Fri, 1 Sep 2017 10:32:20 +0300 Parents: 2c61e5dc38261544f3f9405836700cae08ebe6e4 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=becb4d6d5902a1d2f753d503cbbad953765355e8 Log: Remove dead allocations of non-escaping objects Changed paths: M ext/opcache/Optimizer/dce.c M ext/opcache/tests/opt/dce_005.phpt M ext/opcache/tests/opt/sccp_010.phpt M ext/opcache/tests/opt/sccp_011.phpt M ext/opcache/tests/opt/sccp_012.phpt Diff: diff --git a/ext/opcache/Optimizer/dce.c b/ext/opcache/Optimizer/dce.c index c43b4a8..feaee92 100644 --- a/ext/opcache/Optimizer/dce.c +++ b/ext/opcache/Optimizer/dce.c @@ -696,9 +696,17 @@ int dce_optimize_op_array(zend_op_array *op_array, zend_ssa *ssa, zend_bool reor } else if (may_have_side_effects(op_array, ssa, &op_array->opcodes[i], &ssa->ops[i], ctx.reorder_dtor_effects) || zend_may_throw(&op_array->opcodes[i], op_array, ssa) || (has_varargs && may_break_varargs(op_array, ssa, &ssa->ops[i]))) { - add_operands_to_worklists(&ctx, &op_array->opcodes[i], &ssa->ops[i], 0); - if (op_data >= 0) { - add_operands_to_worklists(&ctx, &op_array->opcodes[op_data], &ssa->ops[op_data], 0); + if (op_array->opcodes[i].opcode == ZEND_NEW + && op_array->opcodes[i+1].opcode == ZEND_DO_FCALL + && ssa->ops[i].result_def >= 0 + && ssa->vars[ssa->ops[i].result_def].escape_state == ESCAPE_STATE_NO_ESCAPE) { + zend_bitset_incl(ctx.instr_dead, i); + zend_bitset_incl(ctx.instr_dead, i+1); + } else { + add_operands_to_worklists(&ctx, &op_array->opcodes[i], &ssa->ops[i], 0); + if (op_data >= 0) { + add_operands_to_worklists(&ctx, &op_array->opcodes[op_data], &ssa->ops[op_data], 0); + } } } else { zend_bitset_incl(ctx.instr_dead, i); diff --git a/ext/opcache/tests/opt/dce_005.phpt b/ext/opcache/tests/opt/dce_005.phpt index 2fdf93b..cabd534 100644 --- a/ext/opcache/tests/opt/dce_005.phpt +++ b/ext/opcache/tests/opt/dce_005..phpt @@ -21,11 +21,8 @@ $_main: ; (lines=1, args=0, vars=0, tmps=0) ; %sdce_005.php:1-8 L0: RETURN int(1) -foo: ; (lines=5, args=1, vars=1, tmps=1) +foo: ; (lines=2, args=1, vars=1, tmps=1) ; (after optimizer) ; %sdce_005.php:4-7 L0: CV0($x) = RECV 1 -L1: V1 = NEW 0 string("A") -L2: DO_FCALL -L3: FREE V1 -L4: RETURN null +L1: RETURN null diff --git a/ext/opcache/tests/opt/sccp_010.phpt b/ext/opcache/tests/opt/sccp_010.phpt index 33cb883..7d0d533 100644 --- a/ext/opcache/tests/opt/sccp_010.phpt +++ b/ext/opcache/tests/opt/sccp_010.phpt @@ -28,12 +28,9 @@ $_main: ; (lines=1, args=0, vars=0, tmps=0) ; %ssccp_010.php:1-15 L0: RETURN int(1) -foo: ; (lines=6, args=0, vars=0, tmps=1) +foo: ; (lines=3, args=0, vars=0, tmps=1) ; (after optimizer) ; %ssccp_010.php:2-13 -L0: V0 = NEW 0 string("stdClass") -L1: DO_FCALL -L2: FREE V0 -L3: ECHO int(1) -L4: ECHO int(1) -L5: RETURN null +L0: ECHO int(1) +L1: ECHO int(1) +L2: RETURN null diff --git a/ext/opcache/tests/opt/sccp_011.phpt b/ext/opcache/tests/opt/sccp_011.phpt index 249bb8b..49288de 100644 --- a/ext/opcache/tests/opt/sccp_011.phpt +++ b/ext/opcache/tests/opt/sccp_011.phpt @@ -27,14 +27,11 @@ $_main: ; (lines=1, args=0, vars=0, tmps=0) ; %ssccp_011.php:1-14 L0: RETURN int(1) -foo: ; (lines=8, args=1, vars=1, tmps=1) +foo: ; (lines=5, args=1, vars=1, tmps=1) ; (after optimizer) ; %ssccp_011.php:2-12 L0: CV0($x) = RECV 1 -L1: V1 = NEW 0 string("stdClass") -L2: DO_FCALL -L3: FREE V1 -L4: JMPZ CV0($x) L6 -L5: JMP L6 -L6: ECHO int(0) -L7: RETURN null +L1: JMPZ CV0($x) L3 +L2: JMP L3 +L3: ECHO int(0) +L4: RETURN null diff --git a/ext/opcache/tests/opt/sccp_012.phpt b/ext/opcache/tests/opt/sccp_012.phpt index ae56057..41db449 100644 --- a/ext/opcache/tests/opt/sccp_012.phpt +++ b/ext/opcache/tests/opt/sccp_012.phpt @@ -30,12 +30,9 @@ $_main: ; (lines=1, args=0, vars=0, tmps=0) ; %ssccp_012.php:1-17 L0: RETURN int(1) -foo: ; (lines=6, args=0, vars=0, tmps=1) +foo: ; (lines=3, args=0, vars=0, tmps=1) ; (after optimizer) ; %ssccp_012.php:2-15 -L0: V0 = NEW 0 string("stdClass") -L1: DO_FCALL -L2: FREE V0 -L3: ECHO int(1) -L4: ECHO int(4) -L5: RETURN null +L0: ECHO int(1) +L1: ECHO int(4) +L2: RETURN null

« previous php.cvs (#99222) next »