com php-src: Fixed copy semantics in escape analysis: ext/opcache/Optimizer/dfa_pass.c ext/opcache/Optimizer/es cape_analysis.c
ext/opcache/tests/opt/sccp_017. phpt ext/opcache/tests/opt/sccp_019.phpt

From: Date: Mon, 11 Sep 2017 17:59:40 +0000
Subject: com php-src: Fixed copy semantics in escape analysis: ext/opcache/Optimizer/dfa_pass.c ext/opcache/Optimizer/es cape_analysis.c
ext/opcache/tests/opt/sccp_017. phpt ext/opcache/tests/opt/sccp_019.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-99355@lists.php.net to get a copy of this message
Commit: 63b93b4a744dba1c9eba0ad0fe34fa9237381226 Author: Dmitry Stogov <dmitry@zend.com> Mon, 11 Sep 2017 20:59:40 +0300 Parents: 87897efe4c44c18b30f772d2305b3adeb0aee9bb Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=63b93b4a744dba1c9eba0ad0fe34fa9237381226 Log: Fixed copy semantics in escape analysis Changed paths: M ext/opcache/Optimizer/dfa_pass.c M ext/opcache/Optimizer/escape_analysis.c M ext/opcache/tests/opt/sccp_017.phpt A ext/opcache/tests/opt/sccp_019.phpt Diff: diff --git a/ext/opcache/Optimizer/dfa_pass.c b/ext/opcache/Optimizer/dfa_pass.c index e014afe..d4b9a6a 100644 --- a/ext/opcache/Optimizer/dfa_pass.c +++ b/ext/opcache/Optimizer/dfa_pass.c @@ -107,15 +107,15 @@ int zend_dfa_analyze_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx, return FAILURE; } - if (zend_ssa_escape_analysis(ctx->script, op_array, ssa) != SUCCESS) { + if (zend_ssa_find_sccs(op_array, ssa) != SUCCESS){ return FAILURE; } - if (zend_ssa_find_sccs(op_array, ssa) != SUCCESS){ + if (zend_ssa_inference(&ctx->arena, op_array, ctx->script, ssa) != SUCCESS) { return FAILURE; } - if (zend_ssa_inference(&ctx->arena, op_array, ctx->script, ssa) != SUCCESS) { + if (zend_ssa_escape_analysis(ctx->script, op_array, ssa) != SUCCESS) { return FAILURE; } diff --git a/ext/opcache/Optimizer/escape_analysis.c b/ext/opcache/Optimizer/escape_analysis.c index 99e3d26..db70bbc 100644 --- a/ext/opcache/Optimizer/escape_analysis.c +++ b/ext/opcache/Optimizer/escape_analysis.c @@ -182,13 +182,21 @@ static int is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, in !(ce->ce_flags & ZEND_ACC_INHERITED)) { return 1; } - } + } break; case ZEND_QM_ASSIGN: if (opline->op1_type == IS_CONST && Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, ssa->rt_constants)) == IS_ARRAY) { return 1; } + if (opline->op1_type == IS_CV && (OP1_INFO() & MAY_BE_ARRAY)) { + return 1; + } + break; + case ZEND_ASSIGN: + if (opline->op1_type == IS_CV && (OP1_INFO() & MAY_BE_ARRAY)) { + return 1; + } break; } } else if (op->op1_def == var) { @@ -198,6 +206,9 @@ static int is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, in && Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op2, ssa->rt_constants)) == IS_ARRAY) { return 1; } + if (opline->op2_type == IS_CV && (OP2_INFO() & MAY_BE_ARRAY)) { + return 1; + } break; case ZEND_ASSIGN_DIM: case ZEND_ASSIGN_OBJ: diff --git a/ext/opcache/tests/opt/sccp_017.phpt b/ext/opcache/tests/opt/sccp_017.phpt index 4aa7f96..a8cbcae 100644 --- a/ext/opcache/tests/opt/sccp_017.phpt +++ b/ext/opcache/tests/opt/sccp_017.phpt @@ -9,10 +9,10 @@ opcache.opt_debug_level=0x20000 <?php require_once('skipif.inc'); ?> --FILE-- <?php -function foo() { - $a = []; - $b = $a; +function foo(int $x) { $a[0] = 5; + $a[1] = $x; + $b = $a; $b[0] = 42; return $a[0]; } @@ -23,7 +23,8 @@ $_main: ; (lines=1, args=0, vars=0, tmps=0) ; %ssccp_017.php:1-10 L0: RETURN int(1) -foo: ; (lines=1, args=0, vars=0, tmps=0) +foo: ; (lines=2, args=1, vars=1, tmps=0) ; (after optimizer) ; %ssccp_017.php:2-8 -L0: RETURN int(5) +L0: CV0($x) = RECV 1 +L1: RETURN int(5) diff --git a/ext/opcache/tests/opt/sccp_019.phpt b/ext/opcache/tests/opt/sccp_019.phpt new file mode 100644 index 0000000..80d4123 --- /dev/null +++ b/ext/opcache/tests/opt/sccp_019.phpt @@ -0,0 +1,29 @@ +--TEST-- +SCCP 019: Array assignemnt +--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] = 5; + $a[1] = $x; + $b = $a; + return $b[0]; +} +?> +--EXPECTF-- +$_main: ; (lines=1, args=0, vars=0, tmps=0) + ; (after optimizer) + ; %ssccp_019.php:1-9 +L0: RETURN int(1) + +foo: ; (lines=2, args=1, vars=1, tmps=0) + ; (after optimizer) + ; %ssccp_019.php:2-7 +L0: CV0($x) = RECV 1 +L1: RETURN int(5)

« previous php.cvs (#99355) next »