diff options
author | Dmitry Stogov <dmitry@zend.com> | 2021-02-09 22:53:57 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2021-02-09 22:53:57 +0300 |
commit | 4b79dba93202ed5640dff317046ce2fdd42e1d82 (patch) | |
tree | c9d35bb7fba407405d14e1fb8c1dd1df3e0f8da7 /Zend/tests/anon/015.phpt | |
parent | 550aee0be3bf256fc1dec5409ad1262c96b23147 (diff) | |
download | php-git-4b79dba93202ed5640dff317046ce2fdd42e1d82.tar.gz |
Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.
PHP classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.
Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).
The patch shows 8% improvement on Symphony "Hello World" app.
Diffstat (limited to 'Zend/tests/anon/015.phpt')
-rw-r--r-- | Zend/tests/anon/015.phpt | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Zend/tests/anon/015.phpt b/Zend/tests/anon/015.phpt new file mode 100644 index 0000000000..324ebe880a --- /dev/null +++ b/Zend/tests/anon/015.phpt @@ -0,0 +1,33 @@ +--TEST-- +static variables in methods inherited from parent class +--FILE-- +<?php +class C { + function foo ($y = null) { + static $x = null; + if (!is_null($y)) { + $x = [$y]; + } + return $x; + } +} +$c = new C(); +$c->foo(42); +$d = new class extends C {}; +var_dump($d->foo()); +var_dump($d->foo(24)); +var_dump($c->foo()); +?> +--EXPECT-- +array(1) { + [0]=> + int(42) +} +array(1) { + [0]=> + int(24) +} +array(1) { + [0]=> + int(42) +} |