Commit Graph

615 Commits

Author SHA1 Message Date
Ilija Tovilo
2e9cc9bc30
Allow optimizer to depend on preloaded symbols (#15021)
* Allow optimizer to depend on preloaded symbols

It is safe for the optimizer to rely on preloaded symbols. This can occur when
compiling non-preloaded files, referencing preloaded ones.

* Disable inline pass for observer test

* Move duplicated code into functions

* Add comment to specific optimization value

* Optimizer should only rely on preloaded symbols in the symbol table

* Fix skipif for windows
2024-08-02 17:35:27 +02:00
Ilija Tovilo
a0a8624346
Fix throw in IS_IDENTICAL in JIT (#15103)
We need to persist opline in case zend_is_identical() throws.
2024-07-25 13:18:47 +02:00
Bob Weinand
e406ec81f4 Merge branch 'PHP-8.3' 2024-07-22 18:32:04 +02:00
Bob Weinand
61b455b59c Merge branch 'PHP-8.2' into PHP-8.3 2024-07-22 18:30:10 +02:00
Bob Weinand
a18df90a8b Fix GH-13817: Segmentation fault for enabled observers after pass 4
Instead of fixing up temporaries count in between observer steps, just apply the additional temporary in the two affected observer steps.

Closes GH-14018.
2024-07-22 18:28:03 +02:00
Niels Dossche
442ae96444
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15028: Memory leak in ext/phar/stream.c
  Fix GH-15023: Memory leak in Zend/zend_ini.c
  Fix GH-15020: Memory leak in Zend/Optimizer/escape_analysis.c
2024-07-19 14:59:57 +02:00
Niels Dossche
f21947a7ae
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15028: Memory leak in ext/phar/stream.c
  Fix GH-15023: Memory leak in Zend/zend_ini.c
  Fix GH-15020: Memory leak in Zend/Optimizer/escape_analysis.c
2024-07-19 14:59:44 +02:00
Niels Dossche
03d73182d9
Fix GH-15020: Memory leak in Zend/Optimizer/escape_analysis.c
Closes GH-15022.
2024-07-19 14:56:28 +02:00
Ayesh Karunaratne
673b4e890c
ext/standard: change highlight_string()/print_r stub return type from string|bool to string|true (#14959)
* ext/standard: change `highlight_string()` return type from `string|bool` to `string|true`

* ext/standard: change `print_r` return type from `string|bool` to `string|true`
2024-07-15 23:20:32 +02:00
Ilija Tovilo
780a8280d2
[RFC] Property hooks (#13455)
RFC: https://wiki.php.net/rfc/property-hooks

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2024-07-14 11:55:03 +02:00
Niels Dossche
1a07bb9252
Fix GH-14873: PHP 8.4 min function fails on typed integer
The problem is that this line in the VM: `ZVAL_NULL(result);` changes the type
of arg1 as well, because after the DFA pass the result and input both use
CV0($result).
We should not contract assignments with CVs in frameless calls with
arguments.
An older attempt is found at GH-14876 that tried to modify the VM/JIT.

Closes GH-14903.
2024-07-13 00:29:09 +02:00
Benjamin Eberlei
72c874691b
RFC: Add #[\Deprecated] Attribute (#11293)
see https://wiki.php.net/rfc/deprecated_attribute

Co-authored-by: Tim Düsterhus <tim@tideways-gmbh.com>
Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
2024-07-02 09:44:25 +02:00
David Carlier
2bb8fbd0a8
ext/pgsql: add pg_jit server info.
since PostgreSQL 11, LLVM JIT feature had been brought thus reporting
the settings to the client connection.

Close GH-14566
2024-06-14 16:27:00 +01:00
Gina Peter Banyard
86a4fa3d02 Zend/Optimizer: Fix some [-Wsign-compare] warnings 2024-06-08 17:15:01 +01:00
Niels Dossche
a3b148e38d
Fix GH-14361: Deep recursion in zend_cfg.c causes segfault
Changes the CFG reachability algorithm to use iteration instead of
recursion.

Closes GH-14432.
2024-06-05 17:43:51 +02:00
Levi Morrison
c461b60060
refactor: change zend_is_true to return bool (#14301)
Previously this returned `int`. Many functions actually take advantage
of the fact this returns exactly 0 or 1. For instance,
`main/streams/xp_socket.c` does:

    sockopts |= STREAM_SOCKOP_IPV6_V6ONLY_ENABLED * zend_is_true(tmpzval);

And `Zend/zend_compile.c` does:

    child = &ast->child[2 - zend_is_true(zend_ast_get_zval(ast->child[0]))];

I changed a few places trivially from `int` to `bool`, but there are
still many places such as the object handlers which return `int` that
should eventually be `bool`.
2024-05-24 15:16:36 -06:00
Cristian Rodríguez
8e62e2b829
Mark multple functions as static (#13864)
* Mark many functions as static

Multiple functions are missing the static qualifier.

* remove unused struct sigactions

struct sigaction act, old_term, old_quit, old_int;
all unused.

* optimizer: minXOR and maxXOR are unused
2024-05-22 13:11:46 +02:00
Máté Kocsis
2097237da5
Migrate ext/dba resources to objects (#14239)
Related to https://wiki.php.net/rfc/resource_to_object_conversion and https://github.com/php/php-tasks/issues/6
2024-05-17 08:43:33 +02:00
Saki Takamachi
5359392717
[RFC] Add bcfloor, bcceil and bcround to BCMath (#13096)
Implementation for the "Adding bcround, bcfloor and bcceil to BCMath" RFC: https://wiki.php.net/rfc/adding_bcround_bcfloor_bcceil_to_bcmath

* Separated round mode into separate header file

Co-authored-by: Gina Peter Banyard <girgias@php.net>
2024-04-30 18:32:33 +01:00
Máté Kocsis
afd91fb9ac
Migrate ext/odbc resources to opaque objects (#12040)
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2024-04-28 15:45:56 +02:00
Ilija Tovilo
c2456e97f5
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fixed missed exception
2024-04-15 17:44:10 +02:00
Ilija Tovilo
a351121e85
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fixed missed exception
2024-04-15 17:44:03 +02:00
Dmitry Stogov
5f9b9c4e23
Fixed missed exception 2024-04-15 17:43:54 +02:00
Niels Dossche
eb1cdb5b72
Fix opline argument for getting the function info for range()
Short-lived regression from 00c6d538ab,
where in one of its commits (that was squashed) not all changes were
reverted correctly.
2024-04-01 22:42:18 +02:00
Niels Dossche
00c6d538ab
Fix GH-13834: Applying non-zero offset 36 to null pointer in zend_jit.c (#13846)
* Fix GH-13834: Applying non-zero offset 36 to null pointer in zend_jit.c

ssa_op can be NULL in function JIT. Doing pointer arithmetic on a NULL
pointer is undefined behaviour. Undefined behaviour can be dangerous
because the optimizer may assume then that the variable is not actually
NULL.

To solve this:
1. Add ADVANCE_SSA_OP() to safely add an offset to ssa_op in zend_jit.c
2. For inference, add an extra offset argument to the helper functions.

To reproduce this, use Clang (not GCC) on a test like
sapi/cli/tests/gh12363.phpt (or other tests also work).

* Remove -fno-sanitize=pointer-overflow flag from CI

* Fix NULL pointer offsets added to the stack_map

* Fix an offset add on a potentially NULL ssa->ops

* Fix NULL pointer arithmetic in zend_range_info()

* Address review comments
2024-04-01 13:37:15 +02:00
Peter Kokot
4bf64b53ef
Remove unused zend_dump_variables() (#13767) 2024-03-20 14:37:32 +01:00
Máté Kocsis
56cf09f23a
Improve optimizer support for class constants (#13438)
The following optimizations are added:

- Constant folding of final class constants
- Type inference of typed class constants
2024-03-18 07:30:44 +01:00
Jorg Adam Sowa
e630aacf79
Remove HAVE_INET_PTON (#13410) 2024-02-21 00:43:56 +00:00
Jorg Adam Sowa
e7b1f2a95b
Change long2ip return type (#13395) 2024-02-16 17:11:18 +01:00
David CARLIER
aa1eaacc41
zend_ssa minor struct changes. (#13387)
_zend_ssa_pid::has_range_constraint being the only bool, the bitfield would not bring
any benefit.
2024-02-14 07:41:52 +00:00
Ilija Tovilo
cd66fcc68b
Add request_parse_body() function
RFC: https://wiki.php.net/rfc/rfc1867-non-post

This function allows populating the $_POST and $_FILES globals for non-post
requests. This avoids manual parsing of RFC1867 requests.

Fixes #55815
Closes GH-11472
2024-02-08 12:08:07 +01:00
Derick Rethans
a4d64b2605
Removed ext/oci8 and ext/pdo_oci (#13327)
* Removed ext/oci8 and ext/pdo_oci

They now live in their own repositories:

https://github.com/php/pecl-database-oci8
https://github.com/php/pecl-database-pdo_oci

As per: https://wiki.php.net/rfc/unbundle_imap_pspell_oci8
2024-02-07 15:34:39 +00:00
Ilija Tovilo
97e6c54336
Fix RC inference narrowing for ASSIGN_OBJ
Fixes oss-fuzz #66519
Closes GH-13345
2024-02-07 13:03:14 +01:00
Ilija Tovilo
631bc81607
Implement stackless internal function calls
Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes GH-12461
2024-02-06 17:42:28 +01:00
Ilija Tovilo
f91833d297
Fix RC inference for DECLARE_LAMBDA_FUNCTION
It doesn't seem like the VM can return RCn. However, the JIT fails without it.
I'll need to look into this more closely.
2024-02-05 12:19:18 +01:00
Ilija Tovilo
79e8f20e56
Add type inference for various missing opcodes
Closes GH-13304
2024-02-05 11:48:48 +01:00
David CARLIER
b8f10decb3
ZEND_ELEMENT_COUNT usage reduction. (#13324)
clang 18 is going to be released and in the meantime the counted_by
attribute usage had been constrained to true flexible arrays,
typical cases such as type name[1] ZEND_ELEMENT_COUNT(size) no longer
build.
2024-02-04 19:09:15 +00:00
Ilija Tovilo
77bc863e50
Improve ZEND_FETCH_CLASS_STATIC static inference for final classes
Same as 95f7335.
2024-02-01 15:56:39 +01:00
Ilija Tovilo
95f7335251
Improve static inference in final class (#13298)
static may be treated like self if the class is final.
2024-02-01 11:49:08 +01:00
Ilija Tovilo
668edf2cae
Improve ASSIGN_OBJ RC inference
ASSIGN_OBJ may only modify RC if it implements __set.

Closes GH-13237
2024-01-31 23:24:12 +01:00
Ilija Tovilo
b06311cb3d
Improve ZEND_NEW RC inference
ZEND_NEW returns RC1 if the instanciated class has no constructor.

Closes GH-13239
2024-01-30 16:31:29 +01:00
Ilija Tovilo
8d082958fe
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix create_object checks
2024-01-30 16:14:08 +01:00
Ilija Tovilo
3a5edcca47
Fix create_object checks
Since PHP 8.3, object handlers may be changed by setting
ce->default_object_handlers, rather than in ce->create_object. Some checks need
to be extended to check for the default handlers.

Closes GH-13272
2024-01-30 16:13:51 +01:00
Ilija Tovilo
34e2dc5697
Improve is_instanceof inference (#13238)
When a class is final, it may be treated as !is_instanceof.
2024-01-29 12:48:55 +01:00
Ilija Tovilo
6f6289caca
Avoid new SSA var for ASSIGN_OBJ_REF without RC inference
Previously, this variable was necessary because of auto-vivification on
UNDEF/null/false. It's now only used for RC inference, as auto-vivification has
been removed.

This implicitly solves an inference problem for $obj->bar &= $obj; where we get
a new variable for both literal references to $obj, with the first one getting
the RCn flag, and the second one getting the MAY_BE_REFERENCE flag. Thus, the
first variable will be missing the reference type, causing a false-positive type
inference warning.

If we want to verify RC inference at some point we'll need a better solution.

Closes GH-13233
2024-01-24 11:30:49 +01:00
Ilija Tovilo
ffc250d245
Add runtime type inference verification
Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes GH-12930
2024-01-19 09:29:14 +01:00
Ilija Tovilo
07d2fcc9fc
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix range inference since "proper-range-semantics" RFC
2024-01-17 15:42:40 +01:00
Ilija Tovilo
42cbace1ad
Fix range inference since "proper-range-semantics" RFC
* Arrays returned from range are never empty
* When step is a double value representable by a long, it is coerced implicitly.
  As such, passing a double step no longer guarantees that the result is a
  non-int array.

Closes GH-13166
2024-01-17 15:42:17 +01:00
Dmitry Stogov
055c8861cc Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix zend_may_throw() for FETCH_DIM_IS and ISSET_ISEMPTY_DIM_OBJ
2024-01-17 00:32:31 +03:00
Dmitry Stogov
b046143529 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix zend_may_throw() for FETCH_DIM_IS and ISSET_ISEMPTY_DIM_OBJ
2024-01-17 00:32:14 +03:00