Commit Graph

93 Commits

Author SHA1 Message Date
Bob Weinand
345f46ff29 Fix weakmap API test
Apparently under some targets the address can evaluate to an address with the most significant bit set. (displays as negative number)
2021-10-21 19:31:37 +02:00
Bob Weinand
471102edcd Add ZEND_API for weakmap functionality via zend_weakrefs_hash_add/del
Closes GH-7600.
2021-10-21 13:34:22 +02:00
Nikita Popov
5d702e33a2 Use wildcard for error message
This differs depending on build type.
2021-09-13 22:46:26 +02:00
Bob Weinand
12b0f1b7cc Fix #81435 Observer current_observed_frame may point to an old (overwritten) frame
Ensure current_observed_frame always points to an actually observed frame.
This solution has a caveat of being O(stack size), with the worst case occurring if there are a lot of frames between the current and previous observed frames.
An O(1) solution would require keeping track of the previous observed frame, which would require some additional frame attached metadata, which is best not attempted in an already released version.
2021-09-13 15:58:58 +02:00
Dmitry Stogov
38ebb55c7c Fixed bug #80847 (CData structs with fields of type struct can't be passed as C function argument) 2021-03-17 09:55:20 +03:00
Máté Kocsis
45fa7596dc
Add missing classes to stubs 2021-02-09 22:38:06 +01:00
Tyson Andre
5e06dad411 Properly render 2+ namespaces functions in build/gen_stub.php
Affects ZEND_NS_FE

Add test cases of the global function

Backported to php 8.0 from GH-6664
2021-02-06 14:17:14 -05:00
Nikita Popov
cab1ea46e7 XFAIL observer_error_05.phpt test 2021-02-01 10:24:00 +01:00
Sammy Kaye Powers
17142eab22 Observe fake closures
Closes GH-6607.
2021-01-28 10:03:41 +01:00
Dmitry Stogov
094e1a8b2d Skip dummy frames allocated on CPU stack of zend_call_function().
(Usage of "current_observed_frame" varible looks unsafe to me).
2021-01-26 18:41:26 +03:00
Nikita Popov
f3415758d1 Fix observer tests on Windows
Use %e instead of a hardcoded forward slash.
2021-01-19 15:27:14 +01:00
Nikita Popov
dd7d829896 Disable opcache optimizations during some observer tests
Opcache inlines functions that only return a constant. Disable
optimizations to prevent differences in tests where such functions
are used (or rewrite the test to not depend on it).
2021-01-19 10:02:08 +01:00
Dmitry Stogov
d5a82e2c4e Disable JIT with incompatible third-party extensions 2020-11-30 13:58:34 +03:00
Sammy Kaye Powers
58d41b8c4f Provide unused retvals to observers
Make sure that the return value is available to observers, even if
it is not used by the caller.

Closes GH-6422.
2020-11-17 10:28:47 +01:00
Sammy Kaye Powers
0425a6697a
Fire open observer end handlers after a zend_bailout
Closes GH-6377
2020-11-16 15:12:57 -08:00
Dmitry Stogov
855d8fa68f [Observer] Save opline before calling begin/end handlers 2020-11-11 13:06:55 +03:00
Christoph M. Becker
72d9d9b88f Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug79177.phpt wrt. JIT
2020-10-30 15:49:48 +01:00
Christoph M. Becker
0427dcb913 Fix bug79177.phpt wrt. JIT
JIT ignores that the `zend_write` callback is overwritten, so we define
our own callback and caller.

We also fix the "inconsistent DLL binding" warnings on Windows, by
introducing `PHP_ZEND_TEST_API`.

Closes GH-6391.
2020-10-30 15:47:18 +01:00
Sammy Kaye Powers
4a6932c076
Add missing observer tests
Closes GH-6378
2020-10-26 15:15:17 -07:00
Nikita Popov
c96d884d91 Avoid namespaced class symbol clashes in gen_stub
Add the namespace prefix (using underscores) to both the arginfo
name and the method declaration name.
2020-10-07 12:13:52 +02:00
Nikita Popov
9c710b1d11 Support "static" type in gen_stub 2020-10-07 11:34:14 +02:00
Nikita Popov
dfa6d1c22e Support specifying linkage for generate-function-entries
The linkage can be specified as the argument to the
@generate-function-entries tag. Test this on zend_test.
2020-10-02 17:21:16 +02:00
Sammy Kaye Powers
e42abeafec
Pass zend_execute_data instead of zend_function to fcall init
The motivation for this change is to prevent extensions from having to check executor globals for the current execute_data during function call init. A previous implementation of the observer API initialized the function call from runtime cache initialization before execute_data was allocated which is why zend_function was passed in.

But now that the observer API is implemented via opcode specialization, it makes sense to pass in the execute_data. This also keeps the API a bit more consistent for existing extensions that already hook zend_execute_ex.

Closes GH-6209
2020-09-25 11:46:15 -07:00
Nikita Popov
c5401854fc Run tidy
This should fix most of the remaining issues with tabs and spaces
being mixed in tests.
2020-09-18 14:28:32 +02:00
Dmitry Stogov
d5d31ea3b3 Cleanup observer API and add JIT support 2020-09-18 12:55:58 +03:00
Máté Kocsis
c98d47696f
Consolidate new union type ZPP macro names
They will now follow the canonical order of types. Older macros are
left intact due to maintaining BC.

Closes GH-6112
2020-09-11 11:00:18 +02:00
Levi Morrison
94fd52dd09 Add Z_PARAM_ITERABLE and co 2020-09-03 07:03:12 -06:00
Benjamin Eberlei
8b37c1e993 Change Attribute Syntax from @@ to #[] 2020-09-02 20:26:50 +02:00
Levi Morrison
66c3e900e2 Add zend_observer API
Closes GH-5857.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
Co-authored-by: Sammy Powers <sammyk@datadoghq.com>
2020-09-01 09:59:59 -06:00
Máté Kocsis
0d330e1a02
Add a few missing parameter types in stubs
Related to GH-5627
2020-07-30 14:26:45 +02:00
Theodore Brown
470d1696d9 Implement Shorter Attribute Syntax
RFC: https://wiki.php.net/rfc/shorter_attribute_syntax

Closes GH-5796.

Co-authored-by: Martin Schröder <m.schroeder2007@gmail.com>
2020-07-28 15:28:57 +02:00
Nikita Popov
df2749da70 Tweak zend_test arginfo/zpp 2020-07-21 15:33:01 +02:00
Nikita Popov
6744ead1c9 Parse parameters in zend_test_void_return() 2020-07-17 15:43:40 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Máté Kocsis
b18b2c8fe5
Add string or object ZPP macros
Closes GH-5788
2020-07-06 12:42:02 +02:00
Martin Schröder
053ef28b8d Implement Attribute Amendments.
RFC: https://wiki.php.net/rfc/attribute_amendments

Support for attribute grouping is left out, because the short
attribute syntax RFC will likely make it obsolete.

Closes GH-5751.
2020-06-29 10:45:51 +02:00
Nikita Popov
c9b9f525a9 Include stub hash in generated arginfo files
The hash is used to check whether the arginfo file needs to be
regenerated. PHP-Parser will only be downloaded if this is actually
necessary.

This ensures that release artifacts will never try to regenerate
stubs and thus fetch PHP-Parser, as long as you do not modify any
files.

Closes GH-5739.
2020-06-24 09:55:19 +02:00
Christoph M. Becker
5a04796f76 Fix MSVC level 1 (severe) warnings
We fix (hopefully) all instances of:

* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4005>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4024>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4028>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4047>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4087>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4090>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4273>
* <https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4312>

`zend_llist_add_element()` and `zend_llist_prepend_element()` now
explicitly expect a *const* pointer.

We use the macro `ZEND_VOIDP()` instead of a `(void*)` cast to suppress
C4090; this should prevent accidential removal of the cast by
clarifying the intention, and makes it easier to remove the casts if
the issue[1] will be resolved sometime.

[1] <https://developercommunity.visualstudio.com/content/problem/390711/c-compiler-incorrect-propagation-of-const-qualifie.html>
2020-06-05 11:17:05 +02:00
Benjamin Eberlei
a7908c2d11 Add Attributes
Co-authored-by: Martin Schröder <m.schroeder2007@gmail.com>
2020-06-04 18:19:49 +02:00
Máté Kocsis
b3718430de
Annotate internal functions with the mixed type
Closes GH-5618
2020-05-25 17:30:57 +02:00
Christoph M. Becker
38ecfe0245 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79532: sizeof off_t can be wrong
2020-04-29 10:43:35 +02:00
Christoph M. Becker
67f9b0b754 Fix #79532: sizeof off_t can be wrong
We have to actually determine the proper `SIZEOF_OFF_T`.
Interestingly, it is `4` on Windows x64.

We also have to prevent the redefinition in pg_config.h.  The clean
solution would likely be to not include pg_config.h at all, but that's
out of scope for BC reasons for now.
2020-04-29 10:40:59 +02:00
Máté Kocsis
3fe49d81f8
Generate method entries from stubs for a couple of extensions
Closes GH-5368
2020-04-11 13:28:53 +02:00
Máté Kocsis
3709e74b5e
Store default parameter values of internal functions in arg info
Closes GH-5353. From now on, PHP will have reflection information
about default values of parameters of internal functions.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-04-08 18:37:51 +02:00
Máté Kocsis
610815c0ce
Improve gen_stub.php
Closes GH-5350
Add support for generating deprecated function entries, as well as forward declaration
of function aliases.
2020-04-04 23:52:33 +02:00
Nikita Popov
02a685ead3 Fix stub for zend_terminate_string() 2020-04-03 18:21:40 +02:00
Nikita Popov
2bcc4ab8f4 Verify that all stubs have a return type 2020-04-03 17:59:30 +02:00
Nikita Popov
d2c92d7fd3 Stubs: Store information per-class
We'll need this if we want to generate method entries.
2020-04-03 16:20:47 +02:00
Nikita Popov
631c6e7f78 Add missing zend_test stubs 2020-02-25 11:18:15 +01:00
Nikita Popov
e99d5d3923 Add stubs for zend_test 2020-02-13 16:51:34 +01:00