com php-src: Support for implicit array/object allocations: ext/opcache/Optimizer/escape_analysis.c ext/opcache/tests /opt/sccp_009.phpt

From: Date: Wed, 30 Aug 2017 14:41:45 +0000
Subject: com php-src: Support for implicit array/object allocations: ext/opcache/Optimizer/escape_analysis.c ext/opcache/tests /opt/sccp_009.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-99201@lists.php.net to get a copy of this message
Commit: d1d523ef5080f396fb70bb99b88cd9ee70954892 Author: Dmitry Stogov <dmitry@zend.com> Wed, 30 Aug 2017 17:41:45 +0300 Parents: 44064529a81ddf0f40b244cac0cd98f89c935ae0 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d1d523ef5080f396fb70bb99b88cd9ee70954892 Log: Support for implicit array/object allocations Changed paths: M ext/opcache/Optimizer/escape_analysis.c A ext/opcache/tests/opt/sccp_009.phpt Diff: diff --git a/ext/opcache/Optimizer/escape_analysis.c b/ext/opcache/Optimizer/escape_analysis.c index 8af9eb2..29da73c 100644 --- a/ext/opcache/Optimizer/escape_analysis.c +++ b/ext/opcache/Optimizer/escape_analysis.c @@ -22,6 +22,7 @@ #include "zend_bitset.h" #include "zend_cfg.h" #include "zend_ssa.h" +#include "zend_inference.h" #include "zend_dump.h" /* @@ -198,28 +199,13 @@ static int is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, in return 1; } break; -#if 0 - // TODO: implicit object/array allocation case ZEND_ASSIGN_DIM: case ZEND_ASSIGN_OBJ: - return 1; - case ZEND_ASSIGN_ADD: - case ZEND_ASSIGN_SUB: - case ZEND_ASSIGN_MUL: - case ZEND_ASSIGN_DIV: - case ZEND_ASSIGN_MOD: - case ZEND_ASSIGN_SL: - case ZEND_ASSIGN_SR: - case ZEND_ASSIGN_CONCAT: - case ZEND_ASSIGN_BW_OR: - case ZEND_ASSIGN_BW_AND: - case ZEND_ASSIGN_BW_XOR: - case ZEND_ASSIGN_POW: - if (opline->extended_value) { + if (OP1_INFO() & (MAY_BE_UNDEF | MAY_BE_NULL | MAY_BE_FALSE)) { + /* implicit object/array allocation */ return 1; } break; -#endif } } diff --git a/ext/opcache/tests/opt/sccp_009.phpt b/ext/opcache/tests/opt/sccp_009.phpt new file mode 100644 index 0000000..9da9a3b --- /dev/null +++ b/ext/opcache/tests/opt/sccp_009.phpt @@ -0,0 +1,29 @@ +--TEST-- +SCCP 009: Conditional Constant Propagation of non-escaping array elements +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.opt_debug_level=0x20000 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +function foo(int $x) { + $a[0] = $x; + $a[1] = 2; + echo $a[1]; +} +?> +--EXPECTF-- +$_main: ; (lines=1, args=0, vars=0, tmps=0) + ; (after optimizer) + ; %ssccp_009.php:1-8 +L0: RETURN int(1) + +foo: ; (lines=3, args=1, vars=1, tmps=1) + ; (after optimizer) + ; %ssccp_009.php:2-6 +L0: CV0($x) = RECV 1 +L1: ECHO int(2) +L2: RETURN null

« previous php.cvs (#99201) next »