Commit Graph

2002 Commits

Author SHA1 Message Date
Christoph M. Becker
91e6f2621c
Add sanitity checks regarding num_args and arg_info (GH-16538)
`num_args > 0` implies that `arg_info != NULL`.  We explicitly assert
that during compilation and execution to make it easier for developers
to not miss this[1].

[1] <https://github.com/php/php-src/issues/16266>
2024-10-25 15:52:53 +02:00
Ilija Tovilo
16d25da76b
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix op2 caching for static properties
  Split expression
2024-10-14 13:46:04 +02:00
Ilija Tovilo
67318e91bc
Fix op2 caching for static properties
op2.num may contain other flags, like ZEND_FETCH_CLASS_EXCEPTION. These
currently circumvent caching. Once the property is cached, these flags have no
influence on the result, so it doesn't seem like this was done on purpose.

Closes GH-16380
2024-10-14 13:45:06 +02:00
Ilija Tovilo
60562175ed
Split expression 2024-10-14 13:43:48 +02:00
Dmitry Stogov
33b4bdc448
JIT for INIT_STATIC_METHOD_CALL (#16206)
* JIT for INIT_STATIC_METHOD_CALL

* Fixed typo

* Fix missing LOAD

* Separate zend_get_known_class()
2024-10-07 15:28:23 +03:00
Christoph M. Becker
e3bcbb26b6
Merge branch 'PHP-8.4'
* PHP-8.4:
  Declare zend_call_stack_size_error() as ZEND_API
2024-10-03 22:47:26 +02:00
Christoph M. Becker
6f7f32c330
Declare zend_call_stack_size_error() as ZEND_API
This is necessary at least on Windows to be able to actually call the
function from a different module (in this case php8phpdbg.dll could not
be build).

Closes GH-16204.
2024-10-03 22:46:53 +02:00
Arnaud Le Blanc
2d8a93cbb6
Merge branch 'PHP-8.4'
* PHP-8.4:
  [ci skip] NEWS for GH-16055
  Support stack limit in phpdbg SAPI
2024-10-03 15:25:57 +02:00
Arnaud Le Blanc
443aa29dbe
Support stack limit in phpdbg SAPI
Fixes GH-16041
Closes GH-16055
2024-10-03 15:22:51 +02:00
Dmitry Stogov
3f913c123a
Implement JIT for ZEND_FETCH_STATIC_PROP_* and improve interpretation (#16157)
* Implement JIT for ZEND_FETCH_STATIC_PROP_* and improve interpretation

* Revert incorrect change

* Use FASTCALL calling convention

* Use EMPTY_SWITCH_DEFAULT_CASE

* Move the loading of the property info into zend_jit_uninit_static_prop()
2024-10-02 21:02:33 +03:00
Arnaud Le Blanc
c65e042c0b
Fix zend_get_property_info_for_slot() for lazy objects (#15855)
zend_get_property_info_for_slot(obj, slot) assumes that 'slot' belongs to 'obj', but that may not be the case for lazy proxies.

Fortunately, the property info is often already available in path when it is needed.

For other cases, I make zend_get_property_info_for_slot() aware of lazy objects, and add zend_get_property_info_for_slot_self() for cases where the 'slot' is known to belong to the object itself.

Fixes oss-fuzz #71446
2024-09-16 16:58:12 +02:00
Levi Morrison
6435bb5ae1
Interrupt while internal frame is on the stack (#14627)
* Check VM interrupt while internal frame is on top

* Use tab instead of spaces

* fix frame used in interrupt and refactor

* remove unused failures for zend_jit_check_timeout

* Fix JIT support

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>

* Fix the missing store to vm_interrupt

* Rename new functions

* Special case zend_interrupt_function in JIT code

* refactor to use ZEND_VM_SET_OPCODE_NO_INTERRUPT

* Split atomic exchange into load + store

It is difficult to determine performance of atomics sometimes. In this
case, the separate load+store is still correct, and a load does not
cause a modification, and might be faster for some platforms than an
exchange. A load+store is slower than an exchange, but we're fine
trading the penalty to the slow path and keeping the happy path faster.

---------

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
2024-09-05 00:35:55 +02:00
Ilija Tovilo
daeb3295b2
Improve readonly avis error (GH-15618)
We don't track whether protected(set) is implicit, so for now always point out
when the property is readonly in the error message.
2024-08-29 13:19:31 +02:00
Arnaud Le Blanc
bf96980104
Merge branch 'PHP-8.3'
* PHP-8.3:
  [ci skip] NEWS for GH-15330
  [ci skip] NEWS for GH-15330
  Do not scan generator frames more than once (#15330)
2024-08-28 17:45:49 +02:00
Arnaud Le Blanc
f551a719dc
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] NEWS for GH-15330
  Do not scan generator frames more than once (#15330)
2024-08-28 17:44:41 +02:00
Arnaud Le Blanc
cd25500766
Do not scan generator frames more than once (#15330) 2024-08-28 17:43:17 +02:00
Ilija Tovilo
8df557ac42
[RFC] Asymmetric visibility v2 (GH-15063)
Co-authored-by: Larry Garfield <larry@garfieldtech.com>
2024-08-27 02:04:48 +02:00
Arnaud Le Blanc
c02c1d4474
Change YIELD/YIELD_FROM to do not increment opline (#15328)
YIELD and YIELD_FROM increment opline before returning, but in most places
we need the opline to point to the YIELD and YIELD_FROM.

Here I change YIELD / YIELD_FROM to not increment opline. This simplifies the
code and fixes GH-15275 in a better way.

Closes GH-15328
2024-08-10 16:09:47 +02:00
Arnaud Le Blanc
b43dd10bbb
Merge branch 'PHP-8.3'
* PHP-8.3:
  [ci skip] NEWS for GH-15275
  [ci skip] NEWS for GH-15275
  Fix crash during GC of suspended generator delegate (#15275)
2024-08-10 16:08:19 +02:00
Arnaud Le Blanc
ba9f65bacd
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] NEWS for GH-15275
  Fix crash during GC of suspended generator delegate (#15275)
2024-08-10 15:48:43 +02:00
Arnaud Le Blanc
c767fec2d0
Fix crash during GC of suspended generator delegate (#15275) 2024-08-10 15:46:31 +02:00
Ilija Tovilo
46ee0fb304
Disallow indirect modification on readonly properties within __clone() (#15012)
Indirect modification isn't allowed in __construct() because it allows
references to leak, so it doesn't make much sense to allow it in __clone().
2024-08-09 11:56:16 +02:00
Ilija Tovilo
fdbe910b3b
Fix indirect readonly error messages (#14979)
$obj->ro[] = 42;, passByRef($obj->ro); and the likes should emit an indirect
modification error message. This message already existed but was used
inconsistently.
2024-07-16 23:24:07 +02:00
Ilija Tovilo
a26ec58fa1
De-duplicate readonly property modification error message (#14972) 2024-07-16 16:29:40 +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
Arnaud Le Blanc
0bd260218b
Fix stack limit on ASAN/MSAN (#14771)
Increase the reserved stack size in ASAN builds, as instrumentation use more stack.
Increase the max allowed stack size in some tests, and enable these tests under ASAN.
Use __builtin_frame_address(0), instead of some stack variable, when we need a stack address, as ASAN may store local variables outside of the real stack.
2024-07-03 19:23:34 +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
58a6e5551e
Merge branch 'PHP-8.3' 2024-06-29 15:52:52 +01:00
David Carlier
1b71a9e01f
Merge branch 'PHP-8.2' into PHP-8.3 2024-06-29 15:52:28 +01:00
David Carlier
c03196a5be
Fix GH-14712: segfault on invalid object.
If the extension does not allow to get a property pointer (like PDORow
object), we fallback
to the read property cb anyway.
2024-06-29 15:51:57 +01:00
Bob Weinand
6a2c5318f9
Optimize observers (#13649)
Inline the lookup whether a function is observed at all.
This strategy is also used for FRAMELESS calls. If the frameless call is observed, we instead allocate a call frame and push the arguments, to call the the function afterwards.
Doing so is still a performance benefit as opposed to executing individual INIT_FCALL+SEND_VAL ops. Thus, even if the frameless call turns out to be observed, the call overhead is slightly lower than before.
If the internal function is not observed at all, the unavoidable overhead is fetching the FLF zend_function pointer and the run-time cache needs to be inspected.

As part of this work, it turned out to be most viable to put the result operand on the ZEND_OP_DATA instead of ZEND_FRAMELESS_ICALL_3, allowing seamless interoperability with the DO_ICALL opcode.
This is a bit unusual in comparison to all other ZEND_OP_DATA usages, but seems to not pose problems overall.

There is also a small issue resolved: trampolines would always use the ZEND_CALL_TRAMPOLINE_SPEC_OBSERVER function due to zend_observer_fcall_op_array_extension being set to -1 too late.
2024-06-15 14:42:27 +02:00
Ilija Tovilo
998bce117c
Show enum cases in errors
Closes GH-14496
2024-06-10 22:58:25 +02:00
Ilija Tovilo
8160869e3d
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix missing handling of CALLABLE_CONVERT in cleanup_unfinished_calls()
2024-04-19 20:06:27 +02:00
Ilija Tovilo
4393198bbd
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix missing handling of CALLABLE_CONVERT in cleanup_unfinished_calls()
2024-04-19 20:06:15 +02:00
Ilija Tovilo
b3e26c3036
Fix missing handling of CALLABLE_CONVERT in cleanup_unfinished_calls()
Fixes GH-14003
2024-04-19 20:04:51 +02:00
Máté Kocsis
f2e199e878
Implement "support doc comments for internal classes and functions" (#13266)
Fixes #13130
2024-02-25 08:41:31 +01:00
Michael Voříšek
87edeed3b9
Remove UNEXPECTED from typed prop checks
Closes GH-13143
2024-02-12 11:35:43 +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
Niels Dossche
fe064d7f12 Fix GH-13142: Undefined variable name is shortened when contains \0
Uses the new %S formatter and introduces the necessary changes and
helpers.
2024-01-20 23:49:13 +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
Máté Kocsis
d84ed03a68 Improve error messages related to void/never return types of methods 2024-01-14 16:04:23 +01:00
Arnaud Le Blanc
3c3aba11be Merge branch 'PHP-8.3'
* PHP-8.3:
  WS
  Clarify the stack limit exception message
  Fix GH-12643: Stack limit tests failing on ppc64le
2023-12-10 13:27:13 +01:00
Arnaud Le Blanc
6aa70b577d WS 2023-12-10 13:24:49 +01:00
Arnaud Le Blanc
b1516d95e0 Clarify the stack limit exception message
Make it clearer why the size is not exactly zend.max_allowed_stack_size
2023-12-10 13:20:21 +01:00
Dmitry Stogov
25de668621 Merge branch 'PHP-8.3'
* PHP-8.3:
  Align error messages between normal VM and JIT for RW when using object as array (#12799)
2023-11-28 00:40:57 +03:00
Dmitry Stogov
f4b473ca71 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Align error messages between normal VM and JIT for RW when using object as array (#12799)
2023-11-28 00:40:48 +03:00
Gina Peter Banyard
e94ab0461c
Align error messages between normal VM and JIT for RW when using object as array (#12799) 2023-11-28 00:37:21 +03:00
Ilija Tovilo
692cea5cbc
Use zend_error_noreturn for E_ERROR consistently
To be clear, these already don't return. zend_error_noreturn just hints at this
fact through the ZEND_NORETURN attribute.

Closes GH-12204
2023-09-14 11:44:55 +02:00
David CARLIER
2778b5d25f
zend vm savee registers support for riscv 64. (#11773)
x8 being already reserved, we can only pull x18 to x27.
2023-07-24 08:25:45 +01:00
Máté Kocsis
c322da0606
Fix misleading pass by reference error message (#10639) 2023-07-18 15:02:38 +02:00