com php-src: Added few Optimizer tests: ext/opcache/tests/opt/d ce_001.phpt ext/opcache/tests/opt/dce_002 .phpt ext/opcache/tests/opt/dce_003.phpt
ext/op cache/tests/opt/dce_004.phpt ext/opcache/tests/opt/ dce_005.phpt ext/opcache/tests/opt/dce_006 .phpt

From: Date: Tue, 29 Aug 2017 09:11:34 +0000
Subject: com php-src: Added few Optimizer tests: ext/opcache/tests/opt/d ce_001.phpt ext/opcache/tests/opt/dce_002 .phpt ext/opcache/tests/opt/dce_003.phpt
ext/op cache/tests/opt/dce_004.phpt ext/opcache/tests/opt/ dce_005.phpt ext/opcache/tests/opt/dce_006 .phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-99185@lists.php.net to get a copy of this message
Commit: f1fd08c8f1b1e8e560630f0ac9b77ef48f984776 Author: Dmitry Stogov <dmitry@zend.com> Tue, 29 Aug 2017 12:11:34 +0300 Parents: 3b8f9d933fb5cef5bbe3d7878767e8d489cd368d Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f1fd08c8f1b1e8e560630f0ac9b77ef48f984776 Log: Added few Optimizer tests Changed paths: A ext/opcache/tests/opt/dce_001.phpt A ext/opcache/tests/opt/dce_002.phpt A ext/opcache/tests/opt/dce_003.phpt A ext/opcache/tests/opt/dce_004.phpt A ext/opcache/tests/opt/dce_005.phpt A ext/opcache/tests/opt/dce_006.phpt Diff: diff --git a/ext/opcache/tests/opt/dce_001.phpt b/ext/opcache/tests/opt/dce_001.phpt new file mode 100644 index 0000000..97011f0 --- /dev/null +++ b/ext/opcache/tests/opt/dce_001.phpt @@ -0,0 +1,31 @@ +--TEST-- +DCE 001: Remove dead computation after constants propagation +--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(string $s1, string $s2, string $s3, string $s4) { + $x = ($s1 . $s2) . ($s3 . $s4); + $x = 0; + return $x; +} +?> +--EXPECTF-- +$_main: ; (lines=1, args=0, vars=0, tmps=0) + ; (after optimizer) + ; %sdce_001.php:1-8 +L0: RETURN int(1) + +foo: ; (lines=5, args=4, vars=4, tmps=3) + ; (after optimizer) + ; %sdce_001.php:2-6 +L0: CV0($s1) = RECV 1 +L1: CV1($s2) = RECV 2 +L2: CV2($s3) = RECV 3 +L3: CV3($s4) = RECV 4 +L4: RETURN int(0) diff --git a/ext/opcache/tests/opt/dce_002.phpt b/ext/opcache/tests/opt/dce_002.phpt new file mode 100644 index 0000000..5fb9f47 --- /dev/null +++ b/ext/opcache/tests/opt/dce_002.phpt @@ -0,0 +1,34 @@ +--TEST-- +DCE 002: func_get_args() disables deletion of assignments to parameter variables +--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 $a) { + $a = 10; + $b = 20; + $x = func_get_args(); + $a = 30; + $b = 40; + return $x; +} +?> +--EXPECTF-- +$_main: ; (lines=1, args=0, vars=0, tmps=0) + ; (after optimizer) + ; %sdce_002.php:1-11 +L0: RETURN int(1) + +foo: ; (lines=5, args=1, vars=2, tmps=1) + ; (after optimizer) + ; %sdce_002.php:2-9 +L0: CV0($a) = RECV 1 +L1: CV0($a) = QM_ASSIGN int(10) +L2: CV1($x) = FUNC_GET_ARGS +L3: CV0($a) = QM_ASSIGN int(30) +L4: RETURN CV1($x) diff --git a/ext/opcache/tests/opt/dce_003..phpt b/ext/opcache/tests/opt/dce_003.phpt new file mode 100644 index 0000000..815bf42 --- /dev/null +++ b/ext/opcache/tests/opt/dce_003.phpt @@ -0,0 +1,28 @@ +--TEST-- +DCE 003: Assignment elimination (without FREE) +--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($a) { + $b = $a += 3; + return $a; +} +?> +--EXPECTF-- +$_main: ; (lines=1, args=0, vars=0, tmps=0) + ; (after optimizer) + ; %sdce_003.php:1-7 +L0: RETURN int(1) + +foo: ; (lines=3, args=1, vars=1, tmps=1) + ; (after optimizer) + ; %sdce_003.php:2-5 +L0: CV0($a) = RECV 1 +L1: ASSIGN_ADD CV0($a) int(3) +L2: RETURN CV0($a) diff --git a/ext/opcache/tests/opt/dce_004.phpt b/ext/opcache/tests/opt/dce_004.phpt new file mode 100644 index 0000000..e386c5e --- /dev/null +++ b/ext/opcache/tests/opt/dce_004.phpt @@ -0,0 +1,30 @@ +--TEST-- +DCE 004: Elimination of assignment to escaping arrays +--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, int $y) { + $a = [$x]; + $a[1] = $y; + $a = $y; + return $a; +} +--EXPECTF-- +$_main: ; (lines=1, args=0, vars=0, tmps=0) + ; (after optimizer) + ; %sdce_004.php:1-8 +L0: RETURN int(1) + +foo: ; (lines=4, args=2, vars=3, tmps=1) + ; (after optimizer) + ; %sdce_004.php:2-7 +L0: CV0($x) = RECV 1 +L1: CV1($y) = RECV 2 +L2: CV2($a) = QM_ASSIGN CV1($y) +L3: RETURN CV2($a) diff --git a/ext/opcache/tests/opt/dce_005.phpt b/ext/opcache/tests/opt/dce_005.phpt new file mode 100644 index 0000000..f0fc294 --- /dev/null +++ b/ext/opcache/tests/opt/dce_005.phpt @@ -0,0 +1,31 @@ +--TEST-- +DCE 005: Elimination of assignment to escaping objects (can't remove NEW yet) +--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 +class A { +} +function foo(int $x) { + $a = new A; + $a->foo = $x; +} +--EXPECTF-- +$_main: ; (lines=1, args=0, vars=0, tmps=0) + ; (after optimizer) + ; %sdce_005.php:1-8 +L0: RETURN int(1) + +foo: ; (lines=5, 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 diff --git a/ext/opcache/tests/opt/dce_006.phpt b/ext/opcache/tests/opt/dce_006.phpt new file mode 100644 index 0000000..582b6e5 --- /dev/null +++ b/ext/opcache/tests/opt/dce_006.phpt @@ -0,0 +1,39 @@ +--TEST-- +DCE 006: Objects with destructors don't escape +--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 +class A { + function __destruct() {} +} +function foo(int $x) { + $a = new A; + $a->foo = $x; +} +--EXPECTF-- +$_main: ; (lines=1, args=0, vars=0, tmps=0) + ; (after optimizer) + ; %sdce_006.php:1-9 +L0: RETURN int(1) + +foo: ; (lines=7, args=1, vars=2, tmps=1) + ; (after optimizer) + ; %sdce_006.php:5-8 +L0: CV0($x) = RECV 1 +L1: V2 = NEW 0 string("A") +L2: DO_FCALL +L3: CV1($a) = QM_ASSIGN V2 +L4: ASSIGN_OBJ CV1($a) string("foo") +L5: OP_DATA CV0($x) +L6: RETURN null + +A::__destruct: ; (lines=1, args=0, vars=0, tmps=0) + ; (after optimizer) + ; %sdce_006.php:3-3 +L0: RETURN null

« previous php.cvs (#99185) next »