Commit Graph

768 Commits

Author SHA1 Message Date
Bob Weinand
cf1d21edbd Add a couple clarifying comments 2023-01-22 21:24:54 +01:00
Bob Weinand
1fbe855971 Honor constant expressions instead of just taking the last constant encountered in stubs
As an example:
should be translated to:
ZVAL_LONG(&attribute_Attribute_class_test_arg0, ZEND_ATTRIBUTE_TARGET_FUNCTION | ZEND_ATTRIBUTE_TARGET_METHOD);
2023-01-22 21:24:54 +01:00
Max Kellermann
7473b86f10
build/php.m4: remove test for integer types (#10304)
These are mandatory in C99, so it's a pointless waste of time to check
for them.

(Actually, the fixed-size integer types are not mandatory, but if they
are really not available on some theoretical system, PHP's fallbacks
won't work either, so nothing is gained from this check.)
2023-01-13 11:51:15 +00:00
Máté Kocsis
c90c944126
Merge branch 'PHP-8.2'
* PHP-8.2:
  Better document constructors
  Do not display non-existent constructors
  Do not list private constructors as inherited
2023-01-01 10:49:39 +01:00
Máté Kocsis
7b08fe9f2d Do not list private constructors as inherited 2023-01-01 10:47:16 +01:00
Máté Kocsis
38e138798d Do not display non-existent constructors 2023-01-01 10:47:16 +01:00
Máté Kocsis
eebf3bc0ba Better document constructors
Until https://github.com/php/php-src/pull/10098 default constructors were sometimes documented, sometimes omitted. The above PR made adding documentation for constructor of all non-abstract classes required. However, this is not desired when such a class inherits a constructor from its parent. The current PR fixes the behavior the following way:
- documents inherited constructors (along with destructors)
- makes it possible to generate/replace the methodsynopsis of implicit default constructors which don't have a stub counterpart
2023-01-01 10:47:16 +01:00
Arnaud Le Blanc
a11c8a3039
Limit stack size (#9104) 2022-12-16 17:44:26 +01:00
Máté Kocsis
dc54e04ed4
Merge branch 'PHP-8.2'
* PHP-8.2:
  Only include the default constructor for non-abstract class synopses
2022-12-16 17:03:22 +01:00
Máté Kocsis
d832125b8e
Only include the default constructor for non-abstract class synopses 2022-12-16 17:02:35 +01:00
Máté Kocsis
8afc55870e
Merge branch 'PHP-8.2'
* PHP-8.2:
  Replace another root XML element format to the "canonical" one
  Remove the superfluous closing parentheses from class synopsis page includes
  Always include the constructor on the class manual pages
  Backport methodsynopsis role attributes changes from master
2022-12-16 13:21:39 +01:00
Máté Kocsis
6aa5e58414 Backport methodsynopsis role attributes changes from master
Commits 93605f286d and d6651426f4
2022-12-16 13:18:12 +01:00
Máté Kocsis
0fc60fab72 Always include the constructor on the class manual pages 2022-12-16 13:18:12 +01:00
Máté Kocsis
b4df038cee Remove the superfluous closing parentheses from class synopsis page includes 2022-12-16 13:18:12 +01:00
Máté Kocsis
60cf9fbee0 Replace another root XML element format to the "canonical" one 2022-12-16 13:18:12 +01:00
Máté Kocsis
d6651426f4
Escape the role attribute of namespaced classes (#9952) 2022-11-15 18:13:29 +01:00
Máté Kocsis
93605f286d
Make the usage of the role attribute more clear (#9901)
Currently, the role attribute is mainly used to differentiate OO and procedural "aliases" when they are documented on the same page (e.g. https://www.php.net/manual/en/datetime.diff.php). However, these function-method counterparts are not always aliases in fact according to the stubs (#9491). That's why sometimes the usage of the role attribute is ambiguous, thus syncing the manual with the stubs results in false positive diffs.

This change fixes the problem by a very obtrusive way: by changing the value of all role="oop" attributes to the actual class name, like role="DateTime", and by getting rid of all role="procedural" attributes as they became unnecessary. This way, class synopsis pages can clearly reference methods, and skip functions. Additionally, gen_stub.php will be able to generate the correct methodsynopsis role even though a single page describes multiple methods, like `DateTime/DateTimeImmutable/DateTimeInterface::diff()`.
2022-11-10 08:35:46 +01:00
Máté Kocsis
a14e125baf
Merge branch 'PHP-8.2'
* PHP-8.2:
  Do not display the value of UNKNOWN constants in the manual (#9843)
2022-10-30 14:58:58 +01:00
Máté Kocsis
721e604a69
Do not display the value of UNKNOWN constants in the manual (#9843) 2022-10-30 14:58:16 +01:00
Máté Kocsis
aba11b670c
Merge branch 'PHP-8.2'
* PHP-8.2:
  Generate constant declarations with the CONST_CS flag for PHP 7.x
2022-10-10 11:13:00 +02:00
Máté Kocsis
69ef3247fd
Generate constant declarations with the CONST_CS flag for PHP 7.x 2022-10-10 11:12:20 +02:00
Máté Kocsis
c153ec877f
Merge branch 'PHP-8.2'
* PHP-8.2:
  Improve string class constant code generation
2022-09-26 23:13:31 +02:00
Máté Kocsis
e4f2376919
Improve string class constant code generation (#9577)
Using strlen() will make sure that non-constant values can also be used.
2022-09-26 23:12:34 +02:00
Máté Kocsis
ab6d449b3a
Merge branch 'PHP-8.2'
* PHP-8.2:
  Use PHP 7.4 syntax in gen_stub.php
2022-09-11 07:51:52 +02:00
Máté Kocsis
8b632749d7
Use PHP 7.4 syntax in gen_stub.php 2022-09-11 07:51:28 +02:00
Máté Kocsis
b2234a0f26
Merge branch 'PHP-8.2'
* PHP-8.2:
  Require PHP 7.4 at least for running the build system
2022-09-10 18:33:50 +02:00
Máté Kocsis
4af695e908
Require PHP 7.4 at least for running the build system (#9519) 2022-09-10 18:31:43 +02:00
Nikita Popov
36fdc6fdc0 Check that all preprocessor conditions are terminated 2022-09-10 18:17:51 +02:00
Máté Kocsis
6904019f13
Merge branch 'PHP-8.2'
* PHP-8.2:
  Validate if the refpurpose and the description is in sync (#9510)
2022-09-09 11:55:09 +02:00
Máté Kocsis
e0422979f6
Validate if the refpurpose and the description is in sync (#9510) 2022-09-09 11:54:38 +02:00
Ilija Tovilo
ecc3fc180f
Use PDEATHSIG to kill cli-server workers if parent exists
Closes GH-9476
2022-09-08 10:48:20 +02:00
Máté Kocsis
ce058273ba
Add support for validation of missing method synopses (#9491) 2022-09-07 17:40:36 +02:00
Máté Kocsis
05aa3b3e0a
Upgrade PHP parser to 4.15.1
It contains some useful fixes
2022-09-06 14:09:47 +02:00
Máté Kocsis
c547fc183c
Add support for validation of missing class synopses (#9472) 2022-09-05 14:21:15 +02:00
Andreas Braun
f7d42f646b
Update gen_stub to avoid compile errors on duplicate function names
Closes GH-9406
2022-08-30 11:33:45 +02:00
Máté Kocsis
b4ec3e9bc0
Do not generate CONST_CS when registering constants (#9439) 2022-08-28 08:27:19 +02:00
Remi Collet
aa702c5459
add compat stuff for function attributes 2022-08-18 13:46:55 +02:00
Máté Kocsis
98b858e756
Fix GH-9183 Get rid of unnecessary PHPDoc param and return type checks (#9203) 2022-07-30 15:37:53 +02:00
Máté Kocsis
b56492be9c
Do not add inherited interface methods to the class synopsis page
These are not displayed currently in the manual so gen_stub.php should be adapted to this behavior.
2022-07-28 15:14:00 +02:00
Andreas Braun
3c016467c7
Escape \U and \u in generated stubs
This fixes an issue where a namespaced class beginning with "U" or "u"
would yield an invalid arginfo file due to the occurrence of a unicode
escape sequence, causing a compile error.

Co-authored-by: Guilliam Xavier <guilliamxavier@users.noreply.github.com>

Closes GH-9154.
2022-07-28 14:30:11 +02:00
Michael Voříšek
b0c0a2cfb4
Use -1 "precision" in gen_stub.php
Closes GH-8734.
2022-07-23 12:09:37 +02:00
George Peter Banyard
4457dba1fb
Add support for stubs to declare intersection type class properties (#8751) 2022-07-22 13:04:49 +01:00
Ilija Tovilo
41a5b46e7d
Fix RC debug of stub attribute (#9082) 2022-07-21 15:06:04 +02:00
Máté Kocsis
e328c68305
Rename @cname to @cvalue in stubs (#9043)
@cname currently refers to the constant name in C. However, it is not always a (constant) name, but sometimes a function invocation, so naming it as @cvalue would be more appropriate.
2022-07-19 15:11:42 +02:00
Remi Collet
af72d6e5d9
no need for attributes on legacy 2022-07-18 12:44:29 +02:00
Remi Collet
ee1d6188cf
cleanup unused 2022-07-18 12:40:28 +02:00
Remi Collet
55a88f36b6
add SensitiveParameter as known string and use it in arginfo 2022-07-18 11:43:33 +02:00
Remi Collet
6e24c16c4a
add compatibility for tentative-return-type 2022-07-12 15:22:49 +02:00
Máté Kocsis
227a8576d2
Fix parameter order in gen_stub.php 2022-07-12 13:08:08 +02:00
Tim Düsterhus
342e18f105
Support the actual #[\SensitiveParameter] attribute in stubs (#8836) 2022-07-12 12:43:44 +02:00
Máté Kocsis
0bddbab084
Make the ABI compatibility of generated arginfo files configurable (#8931) 2022-07-12 10:27:53 +02:00
Remi Collet
b45cd10238
Fix GH-8842 don't set sensitive param in legacy arginfo 2022-07-06 08:40:10 +02:00
Bob Weinand
9f29e2d7e9 Allow for arbitrary (class) attributes in stubs
This can be easily extended to other types of attributes.

Closes #8839.
2022-07-05 18:23:05 +02:00
Tim Düsterhus
ff472ce6fc
Support the #[\AllowDynamicProperties] attribute in stubs (#8776)
* Support the `#[\AllowDynamicProperties]` attribute in stubs

* Use `#[\AllowDynamicProperties]` attribute in stubs

* Disallow applying both `@strict-properties` and `#[\AllowDynamicProperties]`
2022-06-21 09:28:57 +02:00
Yurun
5cf2659fa5
Replace the use of ZVAL_BOOL() with ZVAL_TRUE() or ZVAL_FALSE() where the value is fixed (#8815) 2022-06-20 13:34:44 +01:00
Máté Kocsis
49d3dde211
Declare true return types (#8759) 2022-06-18 22:06:50 +02:00
Pierrick Charron
1bcd8d394a
Update gen_stub to support #if around classes 2022-06-13 16:34:12 -04:00
Pierrick Charron
6fd2b39397
Indent with TAB in .h files generated by gen_stub 2022-06-13 08:55:54 -04:00
George Peter Banyard
b40ae80804
Convert iterable into an internal alias for Traversable|array (#7309)
This does a compile time transformation of ``iterable`` into ``Traversable|array`` which simplifies some of the LSP variance handling.

The arginfo generation script from stubs is updated to produce a union type when it encounters the type ``iterable``
Extension functions which do not regenerate the arginfo, or write them manually are still supported by mimicking the compile time transformation while registering the function.

Type Reflection is preserved for single ``iterable`` (and ``?iterable``) to produce a ReflectionNamedType with name ``iterable``, however usage of ``iterable`` in union types will be converted to ``array|Traversable``
2022-06-07 13:35:34 +01:00
Máté Kocsis
b2ed625de1
A few cleanup changes for gen_stub.php 2022-06-06 07:43:56 +02:00
Máté Kocsis
debd38f851 Add support for sensitive parameters in stubs 2022-06-04 18:15:05 +02:00
David Carlier
0b6f58d907 Merge branch 'PHP-8.1' 2022-06-03 08:05:13 +01:00
David Carlier
7f70911cbe Merge branch 'PHP-8.0' into PHP-8.1 2022-06-03 08:04:58 +01:00
David Carlier
0a47fdf538 Revert "Fix detection of unknown gcc function attributes"
This reverts commit 813d942bac.
2022-06-03 08:04:07 +01:00
David Carlier
e17fd1f2d9 Merge branch 'PHP-8.1' 2022-06-02 21:11:43 +01:00
David Carlier
ba5efbdf17 Merge branch 'PHP-8.0' into PHP-8.1 2022-06-02 21:11:22 +01:00
Athos Ribeiro
813d942bac Fix detection of unknown gcc function attributes
As described in autoconf-archive upstream [1], from where
`build/ax_gcc_func_attribute.m4` is forked, the old unknown func attr
detection method would throw a false negative anytime an unrelated
warning was raised.

This results in `ax_cv_have_func_attribute_target` being set to `no`
whenever certain compiler Warning flags are switched on. Namely, having
`-Wall` on, which is a default CFLAG for some linux distributions, will
result in

```
warning: ‘bar’ declared ‘static’ but never defined [-Wunused-function]
```

when evaluating support for the `target` function attribute.

With that configuration value set to `no`, the compiled php binaries
will not support x86_64 v3 instructions such as avx2 and sse2, which
should speed up specific tasks ran by PHP.

This issue was originally reported in Ubuntu [2].

[1] http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=commitdiff;h=df0894ad1a8195df67a52108b931e07d708cec9a
[2] https://bugs.launchpad.net/ubuntu/+source/php8.1/+bug/1882279
Closes GH-8483.
2022-06-02 21:09:09 +01:00
Máté Kocsis
a420ee6c34
Update PHP-Parser to 4.14
It supports readonly classes
2022-06-01 16:09:57 +02:00
Máté Kocsis
b7b5ad7169
Make ini_set invocation compatible with PHP 8.0 2022-05-31 08:52:35 +02:00
Máté Kocsis
14da1cb909
Add support for class constants in stubs (#7434) 2022-05-22 22:27:23 +02:00
Máté Kocsis
7850c10389
Add support for readonly classes (#7305)
RFC: https://wiki.php.net/rfc/readonly_classes
2022-05-16 20:40:23 +02:00
Arnaud Le Blanc
0a5a761104 Merge branch 'PHP-8.1' 2022-05-06 15:29:21 +02:00
Arnaud Le Blanc
f07a08df5c
Fix unregistering ini entries of dynamically loaded extension (#8435)
Fixes GH-8185
2022-05-06 15:25:44 +02:00
Ilija Tovilo
9a90bd7054
Deprecate ${} string interpolation
https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
2022-05-05 10:14:56 +02:00
Michael Voříšek
36de002cc6
Verify generated files are up to date in CI
Closes GH-8295
2022-04-21 23:25:47 +02:00
Máté Kocsis
c345b6ee72
Remove unused variable from gen_stub.php 2022-04-13 09:24:08 +02:00
George Peter Banyard
7710f9946b Fix generation of arginfo if type is just null 2022-04-11 16:58:13 +01:00
George Peter Banyard
c12da039b5 Add null and false support to gen_stubs 2022-04-11 14:04:37 +01:00
Steven Wang
c4a9d1e668
Makefile: Clean up .gcda files in prof-gen.
The .gcda files generated by "$(MAKE) PROF_FLAGS=-fprofile-generate all"
should be removed. Otherwise, the profile data in them would be combined
with the profile data of user's workload.Then, they would be used by
"make prof-use" later.

Closes GH-8284.
2022-04-11 14:30:35 +02:00
Levi Morrison
c68591fa16
Use AS_ECHO([]) instead of obsolete $as_echo (#8321) 2022-04-07 21:49:24 +01:00
Anatol Belski
dd81dd9264
build: Extend m4 to support C++20
Signed-off-by: Anatol Belski <ab@php.net>
2022-03-20 00:30:15 +01:00
istiak101
bf2867bc72
Fix FSF address & update year to 2022
FSF mailing address was changed long time ago. This patch updates that address. Also updated year from 2021 to 2022.

Closes GH-8009.
2022-03-19 18:25:29 +01:00
Victor Kislov
6a2c501626
Adjust PHP_SETUP_LIBXML description to mention what it doesnt use action-not-found
Closes GH-8088.
2022-03-08 13:00:23 +01:00
Derick Rethans
0e65e433a9 Merge branch 'PHP-8.1' 2022-02-15 13:28:07 +00:00
Tyson Andre
0fab520ded
Fix zend_register_internal_class_ex alias generation (#8091)
This wouldn't work for creating aliases in a namespace.

It would create the class alias "MyNS_ClassName" instead of
"MyNS\\ClassName"
2022-02-14 17:58:26 -05:00
Remi Collet
05023a281d
Merge branch 'PHP-8.1'
* PHP-8.1:
  [ci skip] news
  Fix GH-8059 use $PHP_EXECUTABLE when $PHP not set
2022-02-08 13:54:58 +01:00
Remi Collet
3b463749f5
Fix GH-8059 use $PHP_EXECUTABLE when $PHP not set 2022-02-08 13:53:29 +01:00
Tyson Andre
b27d2fffbc
Update php-parser to 4.13.2 in build/gen_stub.php (#7989)
v4.13.2 fixes a deprecation notice in php 8.2 for namespacedName
2022-01-22 12:34:50 -05:00
Máté Kocsis
266667c234
Merge branch 'PHP-8.1'
* PHP-8.1:
  Add support for custom property links
2022-01-07 08:29:22 +01:00
Máté Kocsis
62e4ac9439
Add support for custom property links
Closes GH-7892
2022-01-07 08:28:26 +01:00
Máté Kocsis
b9e8d93a5c
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix class synopsis generation
2022-01-06 18:32:43 +01:00
Máté Kocsis
0462719999
Fix class synopsis generation
Closes GH-7891
2022-01-06 18:31:21 +01:00
Tyson Andre
32e2d97a26
Allow internal functions to declare if they support compile-time evaluation, add functions. (#7780)
https://wiki.php.net/rfc/strtolower-ascii means that these functions no longer
depend on the current locale in php 8.2. Before that, this was unsafe to
evaluate at compile time.

Followup to GH-7506

Add strcmp/strcasecmp/strtolower/strtoupper functions

Add bin2hex/hex2bin and related functions

Update test of garbage collection using strtolower to use something else to create a refcounted string
2021-12-20 09:27:06 -05:00
Nikita Popov
335b940664 Merge branch 'PHP-8.1'
* PHP-8.1:
  fix #81656: GCC-11 silently ignores -R
2021-12-05 21:06:59 +01:00
Nikita Popov
53ae2b17f3 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  fix #81656: GCC-11 silently ignores -R
2021-12-05 21:06:50 +01:00
Michael Wallner
1f38c003d2 fix #81656: GCC-11 silently ignores -R
Closes GH-7688.
2021-12-05 21:06:28 +01:00
Dmitry Stogov
cddb65b54e Merge branch 'PHP-8.1'
* PHP-8.1:
  Fixed bug #81634 (ZEND_ENABLE_STATIC_TSRMLS_CACHE produces extensionswith the STATIC_TLS flag)
2021-11-24 20:45:09 +03:00
Dmitry Stogov
72f8dbb312 Fixed bug #81634 (ZEND_ENABLE_STATIC_TSRMLS_CACHE produces extensionswith the STATIC_TLS flag) 2021-11-24 20:43:30 +03:00
Máté Kocsis
d608319529
Merge branch 'PHP-8.1'
* PHP-8.1:
  Add more specific array return type hints for various extensions - part 2
  Add the --generate-optimizer-info option to the help of gen_stub.php
2021-11-17 10:57:01 +01:00
Máté Kocsis
baac970817
Add the --generate-optimizer-info option to the help of gen_stub.php 2021-11-17 10:56:27 +01:00
Nikita Popov
d362caed2c Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix generation of property with class union type
  Replace SKIPIF with EXTENSIONS
2021-11-15 11:05:52 +01:00
Nikita Popov
68ca3879d7 Fix generation of property with class union type
The generated type was missing the UNION bit. Add a ZEND_TYPE_INIT_UNION
macro to hide the implementation details.
2021-11-15 11:04:48 +01:00
Nikita Popov
0eb603e3bb Merge branch 'PHP-8.1'
* PHP-8.1:
  Update PHP-Parser version in gen_stub
2021-11-03 12:41:38 +01:00
Nikita Popov
dd0ec7a554 Update PHP-Parser version in gen_stub
This should address the octal issue encountered in #7610.
2021-11-03 12:41:26 +01:00
Remi Collet
484bf2581c
Merge branch 'PHP-8.1'
* PHP-8.1:
  remove closing bracket in bad place
2021-10-15 16:47:13 +02:00
Remi Collet
371a268a0a
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  remove closing bracket in bad place
2021-10-15 16:46:58 +02:00
Remi Collet
9f98bc58c7
remove closing bracket in bad place 2021-10-15 16:46:35 +02:00
Derick Rethans
68e159dd60 Merge branch 'PHP-8.1' 2021-10-07 17:03:40 +01:00
Derick Rethans
544aebb102 Merge branch 'PHP-8.0' into PHP-8.1 2021-10-07 17:03:32 +01:00
Derick Rethans
7426b2277d Merge branch 'PHP-7.4' into PHP-8.0 2021-10-07 17:03:12 +01:00
Derick Rethans
89dfe49321 Bump config.guess/config.sub in all supported branches to support Apple Silicon 2021-10-07 17:02:39 +01:00
Derick Rethans
5f6e7dff61 Merge branch 'PHP-8.1' 2021-10-07 17:00:30 +01:00
Derick Rethans
ec75116744 Merge branch 'PHP-8.0' into PHP-8.1 2021-10-07 17:00:21 +01:00
Derick Rethans
8e61a3e3ac Merge branch 'PHP-7.4' into PHP-8.0 2021-10-07 16:59:47 +01:00
Derick Rethans
cd0c32e7fb Bump config.guess/config.sub in all supported branches to support Apple Silicon 2021-10-07 16:59:00 +01:00
Máté Kocsis
0b524a56f5
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix a few more classsynopsis generation issues
2021-09-22 23:10:37 +02:00
Máté Kocsis
8168d312f9
Fix a few more classsynopsis generation issues
Closes GH-7480
2021-09-22 23:09:43 +02:00
Máté Kocsis
524a116cf7
Merge branch 'PHP-8.1'
* PHP-8.1:
  Change gen-stub.php to gen_stub.php in help text
2021-09-12 17:10:38 +02:00
Máté Kocsis
ea9f943d33
Change gen-stub.php to gen_stub.php in help text 2021-09-12 17:09:56 +02:00
Máté Kocsis
038b4b6b45
Merge branch 'PHP-8.1' 2021-09-12 16:32:10 +02:00
Máté Kocsis
73063db5c8
Fix documentation generation when legacy arginfo is generated
When legacy arginfo is generated, all the type info gets lost. Since this task is performed before any other additional functionalities of gen_stub.php (e.g. verification, method synopsis and class synopsis generation), these fail as they would require the missing type information.

The issue is fixed by deep cloning the file info objects (albeit only their affected properties), so that we use those for legacy arginfo generation, leaving the original ones untouched.
2021-09-12 11:42:22 +02:00
Máté Kocsis
ad471fb22d
Merge branch 'PHP-8.1'
* PHP-8.1:
  Remove extra space before param default values
  Fix class synopsis generation for interfaces
2021-09-08 12:25:13 +02:00
Máté Kocsis
4c9892d1e3
Fix class synopsis generation for interfaces
We have to generate <ooclass> elements for interfaces (rather than <oointerface>) in a number of places: directly inside the <classsynopsis> element and in the extends list.
2021-09-08 12:23:00 +02:00
Máté Kocsis
2aa9108691
Merge branch 'PHP-8.1'
* PHP-8.1:
  Improve class synopsis root element generation
2021-09-08 10:41:09 +02:00
Máté Kocsis
f588764292
Improve class synopsis root element generation
Besides classrefs, we also have exceptionrefs. Also, the 4th capture group replacement used to be unintentionally duplicated.
2021-09-08 10:40:14 +02:00
codinghuang
3021ce6e58 Clean ext/opcache/minilua 2021-09-03 12:22:23 +02:00
Máté Kocsis
4483ecf5a9
Properly escape the default value of string properties and enum cases 2021-09-02 16:53:31 +02:00
Máté Kocsis
edf2947a5d
Remove unused variable from property generation code 2021-08-31 14:44:41 +02:00
Máté Kocsis
39ede67e17
Fix typo in method name in gen_stub.php 2021-08-31 14:43:11 +02:00
Nikita Popov
32d48212ea Support generating internal enum decl from stubs 2021-08-31 14:19:37 +02:00
Go Kudo
eaac77f4e7
Fix nested namespaced typed property in gen_stub.php (#7418)
Property escape namespaced class name in property types.
2021-08-31 11:56:39 +02:00
Nikita Popov
52d3af1790 Minor cleanup in gen_stubs
Unshare the stmt flag handling code, as this does not always
generalize (e.g. to enum cases, which have no visibility or flags
at all).
2021-08-31 11:44:14 +02:00
Nikita Popov
c1c1822e8c Fix type hint in gen_stub.php
There is no ClassType class, only SimpleType.

[ci skip]
2021-08-31 10:11:15 +02:00
Máté Kocsis
a57b713d66
Fix typo in gen_stub.php 2021-08-30 16:09:10 +02:00
Máté Kocsis
c19e4b9997
Generate optimizer func info from stubs for ext/standard - part 3 (#7426) 2021-08-30 15:56:47 +02:00
Máté Kocsis
8e6e9838b0
Add support for generating MAY_BE_ARRAY_OF_REF func info flag (#7416) 2021-08-30 13:50:34 +02:00
Nikita Popov
fab1222128 Ensure stub files are processed in predictable order
The zend_func_infos.h file was generated in a different order for
me.
2021-08-30 10:28:22 +02:00
dixyes
e4c23fa16b Add haiku shared objects support in libtool 2021-08-27 16:44:10 +02:00
Derick Rethans
802316301d Merge branch 'PHP-7.4' into PHP-8.0 2021-08-25 16:00:14 +01:00
Derick Rethans
3677db6386 Backport speling fix
This change was originall only done for 'master'. Xdebug bundles this file as
it requires it, but PHP 7.2/7.3 don't have it bundled. By doing "phpize" with
master, it updates the file introducing a local diff. By fixing it in older
versions, that problem goes away.
2021-08-25 15:58:28 +01:00
Peter Cowburn
36e88a0066
Use &Properties; entity in xpointer for inherited properties in class synopses (#7400)
This changes ClassInfo::createIncludeElement() such that it takes the $query
argument as-is for the xpointer attribute value. Special characters, like
" and &, are used as-is so be careful not to break the resulting XML.
2021-08-25 12:14:03 +02:00
Máté Kocsis
4a7a414735
Fix callable and iterable handling 2021-08-25 10:37:43 +02:00
Máté Kocsis
d0897b3602
Clean up function map production slightly
There's no need to iterate over $fileInfos again while generating the class map
2021-08-24 19:30:00 +02:00
Máté Kocsis
e35a7fe919
Fix function map production 2021-08-24 18:45:31 +02:00
Máté Kocsis
2141bee69d
Add more specific array type hints 2021-08-24 18:40:36 +02:00
Máté Kocsis
b1822899fc
Add support for generating optimizer function info from stubs (#7367) 2021-08-24 16:35:33 +02:00
Máté Kocsis
076f2899ba
Add support for replacing class synopses based on stubs (#7340) 2021-08-13 15:03:31 +02:00
Máté Kocsis
ac17b3646d
Add support for generating classynopses from stubs
Closes GH-7310
2021-08-02 17:56:22 +02:00
Kamil Tekiela
cd0cd3d31e
Fix typos (#7327) 2021-08-01 18:03:30 +01:00
Máté Kocsis
fc56de113c
Add support for generating readonly properties via stubs (#7297) 2021-07-22 11:09:10 +02:00
Máté Kocsis
23b1c4a982
Migrate to PHP-Parser 4.12.0 and regenerate some arginfos 2021-07-22 09:40:16 +02:00
Nikita Popov
814a932734 Add ZEND_ACC_NOT_SERIALIZABLE flag
This prevents serialization and unserialization of a class and its
children in a way that does not depend on the zend_class_serialize_deny
and zend_class_unserialize_deny handlers that will be going away
in PHP 9 together with the Serializable interface.

In stubs, `@not-serializable` can be used to set this flag.

This patch only uses the new flag for a handful of Zend classes,
converting the remainder is left for later.

Closes GH-7249.
Fixes bug #81111.
2021-07-19 15:59:11 +02:00
Máté Kocsis
553574165a
Add support for the never type in gen_stub.php 2021-07-14 15:21:15 +02:00
Máté Kocsis
0192fd20cc
Merge branch 'PHP-8.0' 2021-07-12 10:32:07 +02:00
Máté Kocsis
80e5ad5a29
Various ext/spl stub fixes
Closes GH-7215
2021-07-12 10:27:05 +02:00
Tyson Andre
e748dcacad
Allow build/gen_stub.php to process multiple CLI file args (#7179)
E.g. `build/gen_stub.php *.stub.php` will generate `*_arginfo.h`
from multiple files.

Previously, gen_stub.php would silently ignore files after the first file.

Invoking gen_stub.php with no arguments will continue to process the entire
directory.
2021-06-20 15:14:01 -04:00
Nikita Popov
be92a87371 Fix PHP_ADD_EXTENSION_DEP without indentation
Adjust FS in order_by_dep.awk to only each whitespace around (,)
rather than any whitespace. Thus a leading indent does not result
in a separate element.
2021-06-10 11:48:25 +02:00
haosun01
657b00d7c0 Hybrid use of registers
1. one **hybrid** solution of register usage
After the discussion with Dmitry, we may want to propose one hybrid
solution of register usage.

1) Following the x86 implementation, we define REG0/1/2 to be the
scratch registers. Clever tricks are utilized in x86 implementation for
better register allocation. Note that we define REG0/1/2 as x8/9/10. One
reason is that R0 and FCARG1 should be distinguished.

2) Temporary registers are also reserved(i.e. they are excluded from the
candidates of register allocator), and they would be used due to the
different addressing modes in AArch64.

2. update the 'make clean' target.

3. remove the unnecessary AArch64 related macros in zend_jit_internal.h.

[ci skip]

Change-Id: I627157b88b2344530d705751eb7f73a223ed83e5
CustomizedGitHooks: yes
2021-05-18 15:32:23 +03:00
Hao Sun
0de9494464 Initial support of JIT/arm64
SUMMARY

We implemented a prototype of PHP JIT/arm64. Briefly speaking,

1. build system
Changes to the build system are made so that PHP JIT can be successfully
built and run on ARM-based machine.
Major change lies in file zend_jit_arm64.dasc, where the handler for
each opcode is generated into machine code. Note that this file is just
copied from zend_jit_x86.dasc and the *unimplemented* parts are
substitued with 'brk' instruction for future work.

2. registers
AArch64 registers are defined in file zend_jit_arm64.h. From our
perspectives, the register usage is quite different from the x86
implementation due to the different ABI, number of registers and
addressing modes.
We had many confusions on this part, and will discuss it in details in
the final section.

3. opcodes
Several opcodes are partially supported, including INIT_FCALL, DO_UCALL,
DO_ICALL, RETURN, ADD, PRE_INC, JMP, QM_ASSIGN, etc. Hence, simple use
scenarios such as user function call, loops, addition with integer and
floating point numbers can be supported.
18 micro test cases are added under 'ext/opcache/tests/jit/arm64/'. Note
that majority of these test cases are design for functional JIT, and
cases 'hot_func_*.phpt' and 'loop_002.phpt' can trigger tracing JIT.

4. test
Our local test environment is an ARM-based server with Ubuntu 20.04 and
GCC-10. Note that both HYBRID and CALL VM modes are supported. We
suggest running the JIT test cases using the following command. Out of
all 130 test cases, 66 cases can be passed currently.
```
  $ make test TESTS='-d opcache.jit=1203 ext/opcache/tests/jit/'
```

DETAILS

1. I-cache flush
Instruction cache must be flushed for the JIT-ed code on AArch64. See
macro JIT_CACHE_FLUSH in file 'zend_jit_internal.h'.

2. Disassembler
Add initialization and jump target parse operations for AArch64 backed.
See the updates in file 'zend_jit_disasm.c'.

3. redzone
Enable redzone for AArch64. See the update in zend_vm_opcodes.h.
Redzone is designated to prevent 'vm_stack_data' from being optimized
out by compilers. It's worth noting that this 16-byte redzone might be
reused as temporary use(treated as extra stack space) for HYBRID mode.

4. stack space reservation
The definitions of HYBRID_SPAD, SPAD and NR_SPAD are a bit tricky for
x86/64.
In AArch64, HYBRID_SPAD and SPAD are both defined as 16. These 16 bytes
are pre-allocated for tempoerary usage along the exuection of JIT-ed
code. Take line 4185 in file zend_jit_arm64.dasc as an example. NR_SPAD
is defined as 48, out of which 32 bytes to save FP/IP/LR registers.
Note that we choose to always reserve HYBRID_SPAD bytes in HYBRID mode,
no matter whether redzone is used or not, for the sake of safety.

5. stack alignment
In AArch64 the stack pointer should be 16-byte aligned. Since shadow
stack is used for JIT, it's easy to guarantee the stack alignment, via
simply moving SP with an offset like 16 or a multiple of 16. That's why
NR_SPAD is defined as 48 and we use 32 of them to save FP/IP/LR
registers which only occupies 24 bytes.

6. global registers
x27 and x28 are reserved as global registers. See the updates in file
zend_jit_vm_helpers.c

7. function prologue for CALL mode
Two callee-saved registers x27 and x28 should saved in function
zend_jit_prologue() in file zend_jit_arm64.dasc. Besides the LR, i.e.
x30, should also be saved since runtime C helper functions(such as
zend_jit_find_func_helper) might be invoked along the execution of
JIT-ed code.

8. regset
Minor changes are done to regset operations particularly for AArch64.
See the updates in file zend_jit_internal.h.

REGISTER USAGE

In this section, we will first talk about our understanding on register
usage and then demonstrate our design.

1. Register usage for HYBRID/CALL modes
Registers are used similarly between HYBRID mode and CALL mode.

One difference is how FP and IP are saved. In HYBRID mode, they are
assigned to global registers, while in CALL mode they are saved/restored
on the VM stack explicitly in prologue/epilogue.

The other difference is that LR register should also be saved/restored
in CALL mode since JIT-ed code are invoked as normal functions.

2. Register usage for functional/tracing JIT
The way registers are used differs a lot between functional JIT and
tracing JIT.

For functional JIT, runtime C code (e.g. helper functions) would be
invoked along the execution of JIT-ed code. As the operands for *most*
opcodes are accessed via the stack slot, i.e. FP + offset. Hence there
is no need to save/restore local(caller-saved) registers before/after
invoking runtime C code.
Exception lies in Phi node and registers might be allocated for these
nodes. Currently I don't fully understand the reason, why registers are
allocated for Phi functions, because I suppose for different versions of
SSA variables at the Phi function, their postions on the stack slot
should be identical(in other words, access via the stack slot is enough
and there is no need to allocate registers).

For tracing JIT, runtime information are recorded for traces(before the
JIT compilation), and the data types and control flows are concrete as
well. Hence it's would be faster to conduct operations and computations
via registers rather than stack slots(as functional JIT does) for these
collected hot paths. Besides, runtime C code can be invoked for tracing
JIT, however this only happends for deoptimization and all registers are
saved to stack in advance.

3. Candidates for register allocator
1) opcode candidates
Function zend_jit_opline_supports_reg() determines the candidate opcodes
which can use CPU registers.

2) register candidates
Registers in set "ZEND_REGSET_FP + ZEND_REGSET_GP - ZEND_REGSET_FIXED -
ZEND_REGSET_PRESERVED" are available for register allocator.
Note that registers from ZEND_REGSET_FIXED are reserved for special
purpose, such as the stack pointer, and they are excluded from register
allocation process.
Note that registers from ZEND_REGSET_PRESERVED are callee-saved based on
the ABI and it's safe to not use them either.

4. Temporary registers
Temporary registers are needed by some opcodes to save intermediate
computation results.

1) Functions zend_jit_get_def_scratch_regset() and
zend_jit_get_scratch_regset() return which registers might be clobbered
by some opcodes. Hence register allocator would spill these scratch
registers if necessary when encountering these opcodes.

2) Macro ZEND_REGSET_LOW_PRIORITY denotes a set of registers which would
be allocated with low priority, and these registers can be used as
temporary usage to avoid conflicts to its best.

5. Compared to the x86 implementation, in JIT/arm64
1) Called-saved FP registers are included into ZEND_REGSET_PRESERVED for
AArch64.

2) We follow the logic of function zend_jit_opline_supports_reg().

3) We reserve 4 GPRs and 2 FPRs out from register allocator and use them
as temporary registers in particular. Note that these 6 registers are
included in set ZEND_REGSET_FIXED.
Since they are reserved, may-clobbered registers can be removed for most
opcodes except for function calls. Besides, low-priority registers are
defined as empty since all candidate registers are of the same priority.
See the updates in function zend_jit_get_scratch_regset() and macro
ZEND_REGSET_LOW_PRIORITY.

6. Why we reserve registers for temporary usage?
1) Addressing mode in AArch64 needs more temporary registers.
The addressing mode is different from x86 and tempory registers might be
*always* needed for most opcodes. For instance, an immediate must be
first moved into one register before storing into memory in AArch64,
whereas in x86 this immediate can be stored directly.

2) There are more registers in AArch64.
Compared to the solution in JIT/x86(that is, temporary registers are
reserved on demand, i.e. different registers for different opcodes under
different conditions), our solution seems a coarse-granularity and
brute-force solution, and the execution performance might be downgraded
to some extent since the number of candidate registers used for
allocation becomes less.
We suppose the performance loss might be acceptable since there are more
registers in AArch64.

3) Based on my understanding, scratch registers defined in x86 are
excluded from candidates for register allocator with *low possibility*,
and it can still allocate these registers. Special handling should be
conducted, such as checking 'reg != ZREG_R0'.
Hence, as we see it, it's simpler to reserve some temporary registers
exclusively. See the updates in function zend_jit_math_long_long() for
instance. TMP1 can be used directly without checking.

Co-Developed-by: Nick Gasson <Nick.Gasson@arm.com>
2021-05-18 15:32:23 +03:00
Máté Kocsis
532c60cb92
Add support for tentative return types of internal methods
RFC: https://wiki.php.net/rfc/internal_method_return_types

Closses GH-6971
2021-05-14 15:55:25 +02:00
Nikita Popov
37173460b0
Update config.guess (#6886)
In particular, this pulls in support for Apple M1 detection.
2021-04-20 10:47:47 +02:00
Dmitry Stogov
f1ad9199ef Better support for cross-compilation 2021-04-16 17:28:54 +03:00
Nikita Popov
e35f9dfecc Don't check executability
As $(PHP) is not an absolute path, test -x doesn't do anything
meaningful. Rely on the autoconf check.
2021-03-16 14:36:10 +01:00
Nikita Popov
fa9e2b31b8 Check for php program in autoconf
Use the detected PHP (minimum 7.1) to run gen_stubs, and other
code generation scripts in the future.
2021-03-16 12:30:56 +01:00
Nikita Popov
bbb86ba7e2 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove generated zend_jit_x86.c on `make clean`
2021-02-17 09:45:31 +01:00
Dylan T
408272b8d9 Remove generated zend_jit_x86.c on make clean
Not removing this causes build failure when reconfiguring and rebuilding after a `make clean`, e.g. enabling/disabling ZTS.

This makes https://bugs.php.net/bug.php?id=80561 more bearable. Ideally it would be rebuilt automatically on configuration change if necessary, but I have no idea how to implement this.

Closes GH-6702.
2021-02-17 09:45:12 +01:00
Máté Kocsis
803779e84b
Add support for generating properties with union type of multiple classes
Closes GH-6701
2021-02-16 15:50:13 +01:00
Máté Kocsis
cad66533f0
Generate class entries from stubs for ldap, libxml, mbstring and mysqli
Closes GH-6684
2021-02-16 14:46:19 +01:00
Máté Kocsis
bf0f6aaf18
Improve class entry generation
Related to GH-6701
2021-02-16 13:09:56 +01:00
Florian Sowade
c4d508c2bc Add dependency tracking for header files
This ensures all .c files which include a header file directly or
indirectly are rebuilt whenever the header file is changed.

Closes GH-6693.
2021-02-16 10:50:03 +01:00
Máté Kocsis
99b08ac281
Implicitly enable function entry generation when class entry generation is enabled
Closes GH-6675
2021-02-09 13:37:24 +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
Tyson Andre
b4c6d5f799 Properly render 2+ namespaces functions in build/gen_stub.php
Affects both INIT_NS_CLASS_ENTRY and ZEND_NS_FE

Add test cases of the global function and namespaced values

Closes GH-6664
2021-02-06 14:09:25 -05:00
Máté Kocsis
1954e59758
Add support for generating class entries from stubs
Closes GH-6289

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-01-26 11:50:36 +01:00
Nikita Popov
a9efcb1561 gen_stub: Also verify implementation-alias
This makes --verify also check @implementation-alias. Failures are
ignored using @no-verify instead. Some mistakes have been made that
would have been caught by this...

Closes GH-6615.
2021-01-19 09:48:33 +01:00
Nikita Popov
f0d6151918 gen_stub: Don't use $aliasMap during verification
Some functions have multiple aliases, while the $aliasMap can
only record one.

Methodsynopsis generation probably shouldn't use it either, but
at least that case seems to only be interested in whether there
is an alias at all.
2021-01-18 16:04:14 +01:00
Nikita Popov
496e4741a3 gen_stub: Compare phpdoc return type in --verify 2021-01-18 14:41:53 +01:00
Nikita Popov
85bfa2243a gen_stub: Allow additional text after @return
In case the stub file also contains documentation.
2021-01-18 13:13:32 +01:00
Nikita Popov
43d5cef448 gen_stub: Automatically add function name to exceptions
This makes sure that it's present even on exceptions from deeper
down the stack, where we can't add it manually.
2021-01-18 13:13:32 +01:00
Nikita Popov
45a4d07dd0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add support for union types for internal functions
2021-01-12 10:15:13 +01:00
Nikita Popov
973138f39d Add support for union types for internal functions
This closes the last hole in the supported types for internal
function arginfo types. It's now possible to represent unions of
multiple classes. This is done by storing them as TypeA|TypeB and
PHP will then convert this into an appropriate union type list.

Closes GH-6581.
2021-01-12 10:14:41 +01:00
Máté Kocsis
dc4d8400b4
Merge branch 'PHP-8.0' 2020-12-30 18:28:33 +01:00
Máté Kocsis
446ad04524
Fix refentry attribute replacing 2020-12-30 18:26:24 +01:00
Máté Kocsis
74e39ce06c
Merge branch 'PHP-8.0' 2020-12-28 14:46:00 +01:00
Máté Kocsis
9cec093b7f
Add support for generating methodsynopses from stubs
Closes GH-6367
2020-12-28 14:44:43 +01:00
Peter Kokot
d386ed1e6b Backport fix for bug #78750
Cherry-picks
fe2afef36f
and
86e2b7bb70.
2020-12-03 10:07:09 +01:00
Nikita Popov
08006e8337 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80402: Don't strip -lpthread
2020-11-26 11:56:07 +01:00
Nikita Popov
6132389d1c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #80402: Don't strip -lpthread
2020-11-26 11:56:00 +01:00
Nikita Popov
ea372e7463 Fix bug #80402: Don't strip -lpthread
The current behavior has been introduced 20 years ago in
f9e375f493 as part of a larger change.
It's not clear to me why special treatement of -lpthread is necessary
here.
2020-11-26 11:54:20 +01:00
Nikita Popov
14eabd9523 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80393
2020-11-24 15:27:50 +01:00
Nikita Popov
ae6e56fb98 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80393
2020-11-24 15:27:43 +01:00
Nikita Popov
d016434ad3 Fixed bug #80393
Handle macos versions that don't start with 10.* in libtool.

Patch by kir dot morozov at gmail dot com.
2020-11-24 15:26:40 +01:00
Nikita Popov
b6a93c38bf Merge branch 'PHP-8.0'
* PHP-8.0:
  Use true/false instead of TRUE/FALSE in intl
2020-11-09 14:44:46 +01:00
Nikita Popov
975735c027 Use true/false instead of TRUE/FALSE in intl
And drop the U_DEFINE_TRUE_AND_FALSE flag.
2020-11-09 14:44:11 +01:00
Nikita Popov
5143b4d8aa Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80310: Support for icu4c 68.1.
2020-11-09 14:35:48 +01:00
Nikita Popov
4cd393453a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80310: Support for icu4c 68.1.
2020-11-09 14:35:40 +01:00
Nikita Popov
96b725122d Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #80310: Support for icu4c 68.1.
2020-11-09 14:34:24 +01:00
Nikita Popov
e1cbfb38f6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix another implicit function declaration in configure
2020-11-03 10:39:33 +01:00
Nikita Popov
53c417d81c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix another implicit function declaration in configure
2020-11-03 10:39:26 +01:00
Nikita Popov
4e68c53a21 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix another implicit function declaration in configure
2020-11-03 10:39:13 +01:00