Skip to content

sync #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 159 commits into from
Dec 24, 2021
Merged

sync #13

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
aa72802
Fix refcount inferemce ($a += $a returns old array with RCN)
dstogov Dec 6, 2021
4ed10f3
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 6, 2021
ebb7b17
Merge branch 'PHP-8.1'
dstogov Dec 6, 2021
5459ed4
Fix use after free because of data clobbering by user error handler
dstogov Dec 6, 2021
fe1f613
Merge branch 'PHP-8.1'
dstogov Dec 6, 2021
c29f6ba
JIT: Fix incorrect elimination of type store
dstogov Dec 6, 2021
b4ccc52
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 6, 2021
faa18bb
Merge branch 'PHP-8.1'
dstogov Dec 6, 2021
7b629af
Fixed incorrect DCE of a constructor call
dstogov Dec 6, 2021
572c09d
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 6, 2021
8a5c604
Merge branch 'PHP-8.1'
dstogov Dec 6, 2021
daf79e2
Fix #75917: SplFileObject::seek broken with CSV flags
Nov 30, 2021
6f32510
Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 6, 2021
fd2a6d2
Merge branch 'PHP-8.1'
cmb69 Dec 6, 2021
cf377ee
Don't convert assign op operand types in opcache
nikic Dec 6, 2021
09e991f
Merge branch 'PHP-8.1'
nikic Dec 6, 2021
08f1d47
Separate "cold" code
dstogov Dec 7, 2021
90e5eed
Merge branch 'PHP-8.1'
dstogov Dec 7, 2021
efb901e
Skip bug_36798.phpt for PDO_DBLIB
cmb69 Dec 7, 2021
7d4fdf1
Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 7, 2021
9c6b843
Merge branch 'PHP-8.1'
cmb69 Dec 7, 2021
7e08018
Fix crush after compilation of nullsafe operator introduced in 307e47…
dstogov Dec 9, 2021
91734fc
Merge branch 'PHP-8.1'
dstogov Dec 9, 2021
da68458
ZEND_INIT_FCALL is only produced when function exists at compile time…
Girgias Dec 9, 2021
0ac3d78
Fix incorrect JMP optimization
dstogov Dec 9, 2021
363434b
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 9, 2021
abcf683
Merge branch 'PHP-8.1'
dstogov Dec 9, 2021
5675ebe
Fix #81585: cached_chunks are not counted to real_size on shutdown
cmb69 Dec 9, 2021
2362722
Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 10, 2021
4013ebe
Merge branch 'PHP-8.1'
cmb69 Dec 10, 2021
6f42c07
Remove range inference for booleans.
dstogov Dec 10, 2021
cfcee97
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 10, 2021
bdcef24
Merge branch 'PHP-8.1'
dstogov Dec 10, 2021
25bb229
Allocate less memory for EG(errors) when recording errors for opcache…
TysonAndre Dec 10, 2021
7daf012
Fix GH-7748: gethostbyaddr outputs binary string
cmb69 Dec 10, 2021
6606cc0
Merge branch 'PHP-8.1'
cmb69 Dec 10, 2021
ac91b83
Add oci_set_prefetch_lob()
cjbj Nov 28, 2021
701e5fe
Merge branch 'lobpf1'
cjbj Dec 11, 2021
e7f3bc9
Fix pcntl_forkx condition in stub (#7755)
devnexen Dec 11, 2021
93f6af6
It's past time to drop linking support for Oracle Client 10g
cjbj Dec 12, 2021
98175fc
Fix openssl_x509_checkpurpose_basic.phpt
cmb69 Dec 12, 2021
2c2b0ab
Merge branch 'PHP-7.4' into PHP-8.0
cmb69 Dec 12, 2021
f19250a
Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 12, 2021
973c4d4
Merge branch 'PHP-8.1'
cmb69 Dec 12, 2021
778513f
Fix error message allocation of PDO PgSQL
ranvis Dec 5, 2021
926dee1
Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 12, 2021
3acf632
Merge branch 'PHP-8.1'
cmb69 Dec 12, 2021
0b3a937
Fix GH-7759: Incorrect return types for hash() and hash_hmac()
cmb69 Dec 11, 2021
a708db9
Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 12, 2021
fe2c13c
Merge branch 'PHP-8.1'
cmb69 Dec 12, 2021
6d5f2ba
macOS 10.14 runners are no longer available via Azure Pipeline
cmb69 Dec 12, 2021
9998082
[ci skip] Merge branch 'PHP-7.4' into PHP-8.0
cmb69 Dec 12, 2021
577358b
[ci skip] Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 12, 2021
443a420
[ci skip] Merge branch 'PHP-8.1'
cmb69 Dec 12, 2021
206c521
Fix GH-7757: Multi-inherited final constant causes fatal error
cmb69 Dec 12, 2021
dd6b1b7
Merge branch 'PHP-8.1'
cmb69 Dec 12, 2021
c435e67
Fix GH-7765: php_oci_cleanup_global_handles segfaults at second call
cmb69 Dec 12, 2021
c35be03
Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 12, 2021
900c94f
Merge branch 'PHP-8.1'
cmb69 Dec 12, 2021
1d54097
Fix oci8 Oracle Client paths on Windows
cmb69 Dec 12, 2021
e79dbe1
JIT: Fix crash during compilation of function with incompletely const…
dstogov Dec 13, 2021
1f03deb
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 13, 2021
3e13f16
Merge branch 'PHP-8.1'
dstogov Dec 13, 2021
230de77
Fix incorrect optimization that leads to memory leak
dstogov Dec 13, 2021
f8f0a65
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 13, 2021
2337c05
Merge branch 'PHP-8.1'
dstogov Dec 13, 2021
cbc0b1a
Fix array clobering by user error handler
dstogov Dec 13, 2021
7607582
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 13, 2021
d9926a1
Merge branch 'PHP-8.1'
dstogov Dec 13, 2021
fe320e8
Tracing JIT: Fix reference counting
dstogov Dec 13, 2021
0314f40
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 13, 2021
fe4beb3
Merge branch 'PHP-8.1'
dstogov Dec 13, 2021
c787f42
Combine ADDREF/DELREF
dstogov Dec 13, 2021
1e56b64
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 13, 2021
1959bbf
Merge branch 'PHP-8.1'
dstogov Dec 13, 2021
cd8e6f5
Preloading: don't remove INCLUDE_OE_EVAL nstructions with used result
dstogov Dec 14, 2021
1a6863c
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 14, 2021
d339e5f
Merge branch 'PHP-8.1'
dstogov Dec 14, 2021
b16fc35
Move common code into helper
dstogov Dec 14, 2021
623b3fc
Merge branch 'PHP-8.1'
dstogov Dec 14, 2021
f583c4d
Use 64-bit multiplication on 64-bit systems
dstogov Dec 14, 2021
75b2973
Fix array clobbering by user error handler
dstogov Dec 15, 2021
faa143c
Merge branch 'PHP-8.1'
dstogov Dec 15, 2021
8eee0d6
Make strtolower() and strtoupper() do ASCII case conversion (#7506)
tstarling Dec 15, 2021
49380b5
Fix #81679: Tracing JIT crashes on reattaching
cmb69 Dec 15, 2021
5910e1d
Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 15, 2021
78ef25b
Merge branch 'PHP-8.1'
cmb69 Dec 15, 2021
38460c2
Implement php_handle_avif() using libavifinfo
y-guyon Dec 15, 2021
30a3280
Oracle Client 10g is no longer supported
cmb69 Dec 12, 2021
3a3eeb4
Fixed build in separate directory
dstogov Dec 16, 2021
79fac32
Don't call zend_attach/detach_symbol_table() for op_arrays without lo…
dstogov Dec 16, 2021
67bb792
Don't execute INCLUDE for empty op_arrays.
dstogov Dec 16, 2021
192ea91
Avoid useless symbol table reattaching on retutn from an included op_…
dstogov Dec 16, 2021
6630603
JIT: Fix incorrect type store elimination
dstogov Dec 17, 2021
88cb659
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 17, 2021
9a65fd0
Merge branch 'PHP-8.1'
dstogov Dec 17, 2021
2745cd9
Fix array clobbering by user error handler
dstogov Dec 17, 2021
98c4a42
Merge branch 'PHP-8.1'
dstogov Dec 17, 2021
a5f7821
Fix typos in opcache code comments, tests (#7794)
TysonAndre Dec 19, 2021
9a59417
[skip ci] Document how to quickly check if jit .dasc files transpile,…
TysonAndre Dec 19, 2021
3587e13
Fix FILTER_FLAG_NO_RES_RANGE flag
tongyifan Dec 19, 2021
a000af6
Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 19, 2021
2f7cd46
Merge branch 'PHP-8.1'
cmb69 Dec 19, 2021
1481d66
[ci skip] Fix "The Mysterious PHP RFC Process" link.
Dec 17, 2021
3859bff
[ci skip] Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 19, 2021
107b311
[ci skip] Merge branch 'PHP-8.1'
cmb69 Dec 19, 2021
29696dd
Add triage label when removing feedback label
nikic Dec 19, 2021
f18bb24
Fix type inference for INIT_ARRAY with invalid index
dstogov Dec 20, 2021
c8d10a8
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 20, 2021
6b60dc2
Merge branch 'PHP-8.1'
dstogov Dec 20, 2021
7c674e1
JIT: Fix register clobbering
dstogov Dec 20, 2021
3e84217
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 20, 2021
5c1fc01
Merge branch 'PHP-8.1'
dstogov Dec 20, 2021
e004e84
Fix incorrect optimization of ASSIGN_OP that may lead to memory leak
dstogov Dec 20, 2021
ca3f7b0
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 20, 2021
e4cf3f7
Merge branch 'PHP-8.1'
dstogov Dec 20, 2021
069bbf3
Fix zend_fibers.c build with ZEND_FIBER_UCONTEXT
psumbera Dec 14, 2021
04b9049
Merge branch 'PHP-8.1'
cmb69 Dec 20, 2021
3414ae6
sockets: add SO_INCOMING_CPU constant
devnexen Dec 10, 2021
32e2d97
Allow internal functions to declare if they support compile-time eval…
TysonAndre Dec 20, 2021
d4920f4
Move ctype test out from Zend and into ctype extension
Girgias Dec 20, 2021
f07c193
mb_convert_encoding will not auto-detect input string as UUEncode, Ba…
alexdowad Dec 5, 2021
edc6b75
Merge branch 'PHP-8.1'
alexdowad Dec 20, 2021
6d5922b
JIT: Fix incorrect JIT prologur size for CLANG/x86 build
dstogov Dec 20, 2021
4ffed6d
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 20, 2021
7d37acc
Merge branch 'PHP-8.1'
dstogov Dec 20, 2021
cb10ac1
Fixed compilation warning
dstogov Dec 20, 2021
01dc872
Merge branch 'PHP-8.0' into PHP-8.1
dstogov Dec 20, 2021
9b968ff
Merge branch 'PHP-8.1'
dstogov Dec 20, 2021
aa35499
Use new param API in ext/pcntl (#7751)
arnaud-lb Dec 21, 2021
1a4d2dd
zend alloc USE_ZEND_ALLOC_HUGE_PAGES option support on solaris based …
devnexen Dec 21, 2021
62bcb31
zend gdb detection fix on FreeBSD.
devnexen Dec 11, 2021
3ee2422
Merge branch 'PHP-8.0' into PHP-8.1
krakjoe Dec 21, 2021
898da7b
Merge branch 'PHP-8.1'
krakjoe Dec 21, 2021
ebace1d
pcntl add ECAPMODE from FreeBSD (#7716)
devnexen Dec 21, 2021
51647eb
socket: ancillary credentials build fix for non linux systems.
devnexen Nov 21, 2021
00113b9
Merge branch 'PHP-8.0' into PHP-8.1
krakjoe Dec 21, 2021
fae4344
Merge branch 'PHP-8.1'
krakjoe Dec 21, 2021
80b0227
socket cmsg credential test fixes, "backporting" from the FreeBSD PR.
devnexen Dec 11, 2021
938a81c
Merge branch 'PHP-8.0' into PHP-8.1
krakjoe Dec 21, 2021
0b5d371
Merge branch 'PHP-8.1'
krakjoe Dec 21, 2021
3c73225
New internal interface for fast text conversion in mbstring
alexdowad Jul 21, 2021
5d6bc25
Reset Bucket->key of deleted HastTable elemets to NULL.
dstogov Dec 22, 2021
713dcb2
Fix the value param of SimpleXMLElement::addAttribute()
kocsismate Dec 22, 2021
97cdf62
Merge branch 'PHP-8.1'
kocsismate Dec 22, 2021
c5f4ee5
$context parameter of get_headers() is nullable
cmb69 Dec 22, 2021
ccd7d41
Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 23, 2021
5ddf191
Merge branch 'PHP-8.1'
cmb69 Dec 23, 2021
096a01c
[ci skip] Update the min curl version in the sync-constants.php script
stof Dec 21, 2021
d37c496
[ci skip] Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 23, 2021
9534673
[ci skip] Merge branch 'PHP-8.1'
cmb69 Dec 23, 2021
e72b2f3
Azure CI: remove duplicates and add required libs
7snovic Dec 23, 2021
eebe910
Don't test hidden files that happen to end in .phpt
cscott Dec 23, 2021
3f0bb67
Avoid void* arithmetic in sockets/multicast.c on NetBSD
devnexen Dec 23, 2021
9d2dc1e
Merge branch 'PHP-8.0' into PHP-8.1
cmb69 Dec 23, 2021
3c3257b
Merge branch 'PHP-8.1'
cmb69 Dec 23, 2021
aab5296
micro-optimization
dstogov Dec 23, 2021
0ed39ed
Fix GH-7809: Cloning a faked SplFileInfo object may segfault
cmb69 Dec 22, 2021
8683d17
Merge branch 'PHP-8.1'
cmb69 Dec 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/remove-needs-feedback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ jobs:
- uses: actions-ecosystem/action-remove-labels@v1
with:
labels: "Status: Needs Feedback"
- uses: actions-ecosystem/action-add-labels@v1
with:
labels: "Status: Needs Triage"
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ repository. Mailing list subscription is explained on the
[mailing lists page](https://www.php.net/mailing-lists.php).

You may also want to read
[The Mysterious PHP RFC Process](https://blogs.oracle.com/opal/entry/the_mysterious_php_rfc_process)
[The Mysterious PHP RFC Process](https://blogs.oracle.com/opal/post/the-mysterious-php-rfc-process-and-how-you-can-change-the-web)
for additional notes on the best way to approach submitting an RFC.

## Writing tests
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ PHP NEWS

- OCI8:
. Added oci8.prefetch_lob_size directive to tune LOB query performance
. Support for building against Oracle Client libraries 10.1 and 10.2 has been
dropped. Oracle Client libraries 11.2 or newer are now required.

- Standard:
. net_get_interfaces() also reports wireless network interfaces on Windows.
(Yurun)
. Finished AVIF support in getimagesize(). (Yannis Guyon)

- Zip:
. add ZipArchive::clearError() method
Expand Down
3 changes: 2 additions & 1 deletion README.REDIST.BINS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
15. ext/phar/zip.c portion extracted from libzip
16. libbcmath (ext/bcmath) see ext/bcmath/libbcmath/LICENSE
17. ext/mbstring/ucgendat portions based on the ucgendat.c from the OpenLDAP
18. avifinfo (ext/standard/libavifinfo) see ext/standard/libavifinfo/LICENSE


3. pcre2lib (ext/pcre)
Expand Down Expand Up @@ -591,7 +592,7 @@ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


16. ext/mbstring/ucgendat portions based on the ucgendat.c from the OpenLDAP
17. ext/mbstring/ucgendat portions based on the ucgendat.c from the OpenLDAP

The OpenLDAP Public License
Version 2.8, 17 August 2003
Expand Down
31 changes: 28 additions & 3 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ PHP 8.2 UPGRADE NOTES
1. Backward Incompatible Changes
========================================

- Standard:
. strtolower() and strtoupper() are no longer locale-sensitive. They now
perform ASCII case conversion, as if the locale were "C". Use
mb_strtolower() if you want localized case conversion. Similarly, stristr,
stripos, strripos, lcfirst, ucfirst, ucwords, str_ireplace,
array_change_key_case and sorting with SORT_FLAG_CASE use ASCII case
conversion.

========================================
2. New Features
========================================
Expand All @@ -28,9 +36,10 @@ PHP 8.2 UPGRADE NOTES
HTTP method in curl_getinfo() return value.

- OCI8:
. Added an oci8.prefetch_lob_size directive to tune LOB query performance
by reducing the number of round-trips between PHP and Oracle Database when
fetching LOBS. This is usable with Oracle Database 12.2 or later.
. Added an oci8.prefetch_lob_size directive and oci_set_prefetch_lob()
function to tune LOB query performance by reducing the number of
round-trips between PHP and Oracle Database when fetching LOBS. This is
usable with Oracle Database 12.2 or later.

- PCRE:
. Added support for the "n" (NO_AUTO_CAPTURE) modifier, which makes simple
Expand Down Expand Up @@ -117,6 +126,14 @@ PHP 8.2 UPGRADE NOTES
9. Other Changes to Extensions
========================================

- OCI8:
. The minimum Oracle Client library version required is now 11.2.

- Standard:
. getimagesize() now reports the actual image dimensions, bits and channels
of AVIF images. Previously, the dimensions have been reported as 0x0, and
bits and channels have not been reported at all.

- Zip:
. extension updated to 1.20.0 with new methods:
ZipArchive::clearError, getStreamName and getStreamIndex
Expand All @@ -128,6 +145,9 @@ PHP 8.2 UPGRADE NOTES
- COM_DOTNET:
. LOCALE_NEUTRAL

- Sockets:
. SO_INCOMING_CPU

========================================
11. Changes to INI File Handling
========================================
Expand All @@ -140,6 +160,11 @@ PHP 8.2 UPGRADE NOTES
. Windows specific error messages are no longer localized, but instead in
English to better match PHP error messages.

- OCI8:
. Since building against Oracle Client 10g is no longer supported anyway,
the configuration option --with-oci8 has been dropped. --with-oci8-11g,
--with-oci8-12c and --with-oci8-19 are still supported.

========================================
13. Other Changes
========================================
Expand Down
13 changes: 13 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ PHP 8.2 INTERNALS UPGRADE NOTES

3. Module changes

4. OpCode changes

========================
1. Internal API changes
========================
Expand All @@ -24,3 +26,14 @@ PHP 8.2 INTERNALS UPGRADE NOTES
3. Module changes
========================

========================
4. OpCode changes
========================

* The ZEND_INIT_FCALL opcode now asserts that the function exists in the symbol
table as the function's existence is checked at compile time.
For extensions modifying the function symbol table, setting
CG(compiler_options) |= ZEND_COMPILE_IGNORE_USER_FUNCTIONS | ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS;
will produce ZEND_INIT_FCALL_BY_NAME opcodes instead which check for the
existence of the function at runtime.

5 changes: 4 additions & 1 deletion Zend/Optimizer/dce.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,10 @@ int dce_optimize_op_array(zend_op_array *op_array, zend_ssa *ssa, bool reorder_d
while ((i = zend_bitset_pop_first(ctx.instr_worklist, ctx.instr_worklist_len)) >= 0) {
zend_bitset_excl(ctx.instr_dead, i);
add_operands_to_worklists(&ctx, &op_array->opcodes[i], &ssa->ops[i], ssa, 1);
if (i < op_array->last && op_array->opcodes[i+1].opcode == ZEND_OP_DATA) {
if (i < op_array->last
&& (op_array->opcodes[i+1].opcode == ZEND_OP_DATA
|| (op_array->opcodes[i].opcode == ZEND_NEW
&& op_array->opcodes[i+1].opcode == ZEND_DO_FCALL))) {
zend_bitset_excl(ctx.instr_dead, i+1);
add_operands_to_worklists(&ctx, &op_array->opcodes[i+1], &ssa->ops[i+1], ssa, 1);
}
Expand Down
25 changes: 18 additions & 7 deletions Zend/Optimizer/dfa_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static inline bool can_elide_return_type_check(
}

static bool opline_supports_assign_contraction(
zend_ssa *ssa, zend_op *opline, int src_var, uint32_t cv_var) {
zend_op_array *op_array, zend_ssa *ssa, zend_op *opline, int src_var, uint32_t cv_var) {
if (opline->opcode == ZEND_NEW) {
/* see Zend/tests/generators/aborted_yield_during_new.phpt */
return 0;
Expand Down Expand Up @@ -342,6 +342,13 @@ static bool opline_supports_assign_contraction(
return opline->op1_type != IS_CV || opline->op1.var != cv_var;
}

if (opline->opcode == ZEND_ASSIGN_OP
&& opline->op1_type == IS_CV
&& opline->op1.var == cv_var
&& zend_may_throw(opline, &ssa->ops[ssa->vars[src_var].definition], op_array, ssa)) {
return 0;
}

return 1;
}

Expand Down Expand Up @@ -716,9 +723,13 @@ static int zend_dfa_optimize_jmps(zend_op_array *op_array, zend_ssa *ssa)
uint32_t op_num;
zend_op *opline;
zend_ssa_op *ssa_op;
bool can_follow = 1;

while (next_block_num < ssa->cfg.blocks_count
&& !(ssa->cfg.blocks[next_block_num].flags & ZEND_BB_REACHABLE)) {
if (ssa->cfg.blocks[next_block_num].flags & ZEND_BB_UNREACHABLE_FREE) {
can_follow = 0;
}
next_block_num++;
}

Expand All @@ -730,7 +741,7 @@ static int zend_dfa_optimize_jmps(zend_op_array *op_array, zend_ssa *ssa)
switch (opline->opcode) {
case ZEND_JMP:
optimize_jmp:
if (block->successors[0] == next_block_num) {
if (block->successors[0] == next_block_num && can_follow) {
MAKE_NOP(opline);
removed_ops++;
goto optimize_nop;
Expand All @@ -751,7 +762,7 @@ static int zend_dfa_optimize_jmps(zend_op_array *op_array, zend_ssa *ssa)
goto optimize_jmp;
}
} else {
if (block->successors[0] == next_block_num) {
if (block->successors[0] == next_block_num && can_follow) {
take_successor_0(ssa, block_num, block);
if (opline->op1_type == IS_CV && (OP1_INFO() & MAY_BE_UNDEF)) {
opline->opcode = ZEND_CHECK_VAR;
Expand Down Expand Up @@ -782,7 +793,7 @@ static int zend_dfa_optimize_jmps(zend_op_array *op_array, zend_ssa *ssa)
goto optimize_nop;
}
} else if (block->successors_count == 2) {
if (block->successors[0] == next_block_num) {
if (block->successors[0] == next_block_num && can_follow) {
take_successor_0(ssa, block_num, block);
if (opline->op1_type == IS_CV && (OP1_INFO() & MAY_BE_UNDEF)) {
opline->opcode = ZEND_CHECK_VAR;
Expand Down Expand Up @@ -816,7 +827,7 @@ static int zend_dfa_optimize_jmps(zend_op_array *op_array, zend_ssa *ssa)
} else if (block->successors_count == 2) {
if (block->successors[0] == block->successors[1]) {
take_successor_0(ssa, block_num, block);
if (block->successors[0] == next_block_num) {
if (block->successors[0] == next_block_num && can_follow) {
if (opline->op1_type == IS_CV && (OP1_INFO() & MAY_BE_UNDEF)) {
opline->opcode = ZEND_CHECK_VAR;
opline->op2.num = 0;
Expand Down Expand Up @@ -1327,7 +1338,7 @@ void zend_dfa_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx
&& !ssa->vars[src_var].phi_use_chain
&& !ssa->vars[src_var].sym_use_chain
&& opline_supports_assign_contraction(
ssa, &op_array->opcodes[ssa->vars[src_var].definition],
op_array, ssa, &op_array->opcodes[ssa->vars[src_var].definition],
src_var, opline->result.var)
&& !variable_defined_or_used_in_range(ssa, EX_VAR_TO_NUM(opline->result.var),
ssa->vars[src_var].definition+1, op_1)
Expand Down Expand Up @@ -1486,7 +1497,7 @@ void zend_dfa_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx
&& !ssa->vars[src_var].phi_use_chain
&& !ssa->vars[src_var].sym_use_chain
&& opline_supports_assign_contraction(
ssa, &op_array->opcodes[ssa->vars[src_var].definition],
op_array, ssa, &op_array->opcodes[ssa->vars[src_var].definition],
src_var, opline->op1.var)
&& !variable_defined_or_used_in_range(ssa, EX_VAR_TO_NUM(opline->op1.var),
ssa->vars[src_var].definition+1, op_1)
Expand Down
30 changes: 3 additions & 27 deletions Zend/Optimizer/pass1.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,33 +103,9 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
break;

case ZEND_ASSIGN_OP:
if (opline->op2_type == IS_CONST) {
if (opline->extended_value == ZEND_ADD
|| opline->extended_value == ZEND_SUB
|| opline->extended_value == ZEND_MUL
|| opline->extended_value == ZEND_DIV
|| opline->extended_value == ZEND_POW) {
if (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) {
/* don't optimize if it should produce a runtime numeric string error */
if (is_numeric_string(Z_STRVAL(ZEND_OP2_LITERAL(opline)), Z_STRLEN(ZEND_OP2_LITERAL(opline)), NULL, NULL, 0)) {
convert_scalar_to_number(&ZEND_OP2_LITERAL(opline));
}
}
} else if (opline->extended_value == ZEND_MOD
|| opline->extended_value == ZEND_SL
|| opline->extended_value == ZEND_SR) {
zval *op2 = &ZEND_OP2_LITERAL(opline);
if (Z_TYPE_P(op2) != IS_LONG) {
if (!zend_is_op_long_compatible(op2)) {
break;
}
convert_to_long(op2);
}
} else if (opline->extended_value == ZEND_CONCAT) {
if (Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_STRING) {
convert_to_string(&ZEND_OP2_LITERAL(opline));
}
}
if (opline->extended_value == ZEND_CONCAT && opline->op2_type == IS_CONST
&& Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_STRING) {
convert_to_string(&ZEND_OP2_LITERAL(opline));
}
break;

Expand Down
71 changes: 22 additions & 49 deletions Zend/Optimizer/sccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -799,59 +799,21 @@ static inline zend_result ct_eval_array_key_exists(zval *result, zval *op1, zval
return SUCCESS;
}

static bool can_ct_eval_func_call(zend_string *name, uint32_t num_args, zval **args) {
/* Functions in this list must always produce the same result for the same arguments,
static bool can_ct_eval_func_call(zend_function *func, zend_string *name, uint32_t num_args, zval **args) {
/* Precondition: func->type == ZEND_INTERNAL_FUNCTION, this is a global function */
/* Functions setting ZEND_ACC_COMPILE_TIME_EVAL (@compile-time-eval) must always produce the same result for the same arguments,
* and have no dependence on global state (such as locales). It is okay if they throw
* or warn on invalid arguments, as we detect this and will discard the evaluation result. */
if (false
|| zend_string_equals_literal(name, "array_diff")
|| zend_string_equals_literal(name, "array_diff_assoc")
|| zend_string_equals_literal(name, "array_diff_key")
|| zend_string_equals_literal(name, "array_flip")
|| zend_string_equals_literal(name, "array_is_list")
|| zend_string_equals_literal(name, "array_key_exists")
|| zend_string_equals_literal(name, "array_keys")
|| zend_string_equals_literal(name, "array_merge")
|| zend_string_equals_literal(name, "array_merge_recursive")
|| zend_string_equals_literal(name, "array_replace")
|| zend_string_equals_literal(name, "array_replace_recursive")
|| zend_string_equals_literal(name, "array_unique")
|| zend_string_equals_literal(name, "array_values")
|| zend_string_equals_literal(name, "base64_decode")
|| zend_string_equals_literal(name, "base64_encode")
if (func->common.fn_flags & ZEND_ACC_COMPILE_TIME_EVAL) {
/* This has @compile-time-eval in stub info and uses a macro such as ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE */
return true;
}
#ifndef ZEND_WIN32
/* On Windows this function may be code page dependent. */
|| zend_string_equals_literal(name, "dirname")
#endif
|| zend_string_equals_literal(name, "explode")
|| zend_string_equals_literal(name, "imagetypes")
|| zend_string_equals_literal(name, "in_array")
|| zend_string_equals_literal(name, "implode")
|| zend_string_equals_literal(name, "ltrim")
|| zend_string_equals_literal(name, "php_sapi_name")
|| zend_string_equals_literal(name, "php_uname")
|| zend_string_equals_literal(name, "phpversion")
|| zend_string_equals_literal(name, "pow")
|| zend_string_equals_literal(name, "preg_quote")
|| zend_string_equals_literal(name, "rawurldecode")
|| zend_string_equals_literal(name, "rawurlencode")
|| zend_string_equals_literal(name, "rtrim")
|| zend_string_equals_literal(name, "serialize")
|| zend_string_equals_literal(name, "str_contains")
|| zend_string_equals_literal(name, "str_ends_with")
|| zend_string_equals_literal(name, "str_replace")
|| zend_string_equals_literal(name, "str_split")
|| zend_string_equals_literal(name, "str_starts_with")
|| zend_string_equals_literal(name, "strpos")
|| zend_string_equals_literal(name, "strstr")
|| zend_string_equals_literal(name, "substr")
|| zend_string_equals_literal(name, "trim")
|| zend_string_equals_literal(name, "urldecode")
|| zend_string_equals_literal(name, "urlencode")
|| zend_string_equals_literal(name, "version_compare")
) {
/* On Windows this function may be code page dependent. */
if (zend_string_equals_literal(name, "dirname")) {
return true;
}
#endif

if (num_args == 2) {
if (zend_string_equals_literal(name, "str_repeat")) {
Expand Down Expand Up @@ -918,7 +880,7 @@ static inline zend_result ct_eval_func_call(
}
}

if (!can_ct_eval_func_call(name, num_args, args)) {
if (!can_ct_eval_func_call(func, name, num_args, args)) {
return FAILURE;
}

Expand Down Expand Up @@ -2244,6 +2206,17 @@ static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var,
zend_ssa_remove_result_def(ssa, ssa_op);
if (opline->opcode == ZEND_DO_ICALL) {
removed_ops = remove_call(ctx, opline, ssa_op);
} else if (opline->opcode == ZEND_TYPE_CHECK
&& (opline->op1_type & (IS_VAR|IS_TMP_VAR))
&& (!value_known(&ctx->values[ssa_op->op1_use])
|| IS_PARTIAL_ARRAY(&ctx->values[ssa_op->op1_use])
|| IS_PARTIAL_OBJECT(&ctx->values[ssa_op->op1_use]))) {
/* For TYPE_CHECK we may compute the result value without knowing the
* operand, based on type inference information. Make sure the operand is
* freed and leave further cleanup to DCE. */
opline->opcode = ZEND_FREE;
opline->result_type = IS_UNUSED;
removed_ops++;
} else {
zend_ssa_remove_instr(ssa, opline, ssa_op);
removed_ops++;
Expand Down
4 changes: 2 additions & 2 deletions Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ static const func_info_t func_infos[] = {
F1("gmp_sqrtrem", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT),
F1("gmp_rootrem", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT),
F1("gmp_gcdext", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_OBJECT),
F1("hash", MAY_BE_STRING|MAY_BE_FALSE),
F1("hash", MAY_BE_STRING),
F1("hash_file", MAY_BE_STRING|MAY_BE_FALSE),
F1("hash_hmac", MAY_BE_STRING|MAY_BE_FALSE),
F1("hash_hmac", MAY_BE_STRING),
F1("hash_hmac_file", MAY_BE_STRING|MAY_BE_FALSE),
F1("hash_init", MAY_BE_OBJECT),
F1("hash_final", MAY_BE_STRING),
Expand Down
Loading