Commit Graph

2868 Commits

Author SHA1 Message Date
Dmitry Stogov
833821ac24 Eliminate CHECK_VAR instructions for defined CVs 2019-10-10 16:07:31 +03:00
Dmitry Stogov
6a459a8a3f Separate common code and add few more patterns 2019-10-10 12:19:06 +03:00
Dmitry Stogov
0cb977a691 Fixed edge cases introduced by 170ed1f5a7 2019-10-10 11:48:31 +03:00
Dmitry Stogov
d9964efe23 One more place 2019-10-10 02:21:37 +03:00
Dmitry Stogov
bf5d299ef4 Fixed typo 2019-10-10 02:17:50 +03:00
Dmitry Stogov
fa0a17a76f Move ECHO handling into common switch 2019-10-09 23:24:41 +03:00
Dmitry Stogov
fd69af38c8 Cleanup JMP optimization. Remove duplicate code (conditional jums with constant operand) and outdated commented code. 2019-10-09 23:07:32 +03:00
Dmitry Stogov
78a1c8c811 Cleanup JMP optimization pass 2019-10-09 22:52:09 +03:00
Dmitry Stogov
d37f5da75e typo and cleanup 2019-10-09 17:58:35 +03:00
Dmitry Stogov
f6f32f2cf0 SAMRT BRANCH improvement.
Avoid need of insertion NOP opcoes between unrelated SMART BRANCH instruction and following JMPZ/JMPNZ.
Now instead of checking the opcode of following instruction, the same information is encoded into SMART BRANH result_type.
2019-10-09 13:48:39 +03:00
Dmitry Stogov
170ed1f5a7 Otimize out useless QM_ASSIGN 2019-10-09 09:08:25 +03:00
Remi Collet
3dabce087c Merge branch 'PHP-7.4'
* PHP-7.4:
  add librt for opcache
2019-10-08 10:49:30 +02:00
Remi Collet
e1362b3cf0 add librt for opcache 2019-10-08 10:48:10 +02:00
Dmitry Stogov
b02b81299c Comparison cleanup:
- introduce zend_compare() that returns -1,0,1 dirctly (without intermediate zval)
- remove compare_objects() object handler, and keep only compare() handler
2019-10-07 17:57:49 +03:00
Nikita Popov
fdc133063d Convert count_chars invalid mode error to ValueError 2019-10-07 11:10:05 +02:00
Tyson Andre
dd61edfd7c Update opcache return type info for gd functions
Many of these now have reflection types,
making the old signatures redundant or inaccurate.
(Some methods also throw Errors instead of returning null/false)

Closes GH-4785.
2019-10-07 10:16:50 +02:00
Tyson Andre
02f2056864 Update zend_func_info for pcre/curl/iconv/json
preg_quote and curl_error now have a non-null return type of `string`.

zend_func_info now duplicates many real reflection types
(some of which are now non-null)

Closes GH-4788.
2019-10-07 10:16:31 +02:00
Tyson Andre
52dfe873ab Remove redundant zend_func_info for zlib/hash/session
E.g. hash_equals is outdated - it has a non-null reflection type of bool.

Remove redundant signatures for types that are obviously not reference
counted (`F0`).

Closes GH-4787.
2019-10-07 10:16:08 +02:00
Tyson Andre
d0f7a7e7c9 Remove redundant func info for ctype/bc/fileinfo
This is limited to types that aren't reference counted.
I assume the info that there is exactly one reference
should be preserved (e.g. for bcsqrt)

Closes GH-4786.
2019-10-07 10:15:50 +02:00
Tyson Andre
3c2ba240a9 Update zend_func_info for zend, array extensions
Some of these functions now have real reflection types
and will throw instead of return null/false.

Others provide the exact same reflection type information
that zend_func_info does. (or would after updating outdated types)

Closes GH-4790.
2019-10-07 10:15:30 +02:00
Dmitry Stogov
dc3c8c75da Prefer optimization without JMPZNZ instruction 2019-10-04 12:52:46 +03:00
Dmitry Stogov
bf56daa8c8 Remove "finally" restriction. 2019-10-04 02:53:24 +03:00
Dmitry Stogov
204660fd9a Simplify protection from infinity loops 2019-10-04 02:04:00 +03:00
Dmitry Stogov
3a78c3aaf5 Moved non-constant JMP optimizations from pass1 to pass3.
Removed useless "break"s, that stopped optimization too early.
2019-10-04 00:27:49 +03:00
Dmitry Stogov
39d1e50b2d Avoid "$a = $a + ..." to "$a += ..." conversion (compound assignments work slower).
Added DFA optimization patters (e.g. "$a = $a + 1" to "++$a"), that previously worked only for compound assignments.
2019-10-03 16:33:17 +03:00
Dmitry Stogov
de3c1eb85e Move obvious optimization patterns from pass1 directly to compiler 2019-10-03 14:57:20 +03:00
Dmitry Stogov
a5465728c2 Added missing rules 2019-10-03 14:56:02 +03:00
Dmitry Stogov
c1de93efbe Fixed comments 2019-10-03 13:55:58 +03:00
Dmitry Stogov
59c828a8c4 Added missing rules 2019-10-03 13:54:08 +03:00
Dmitry Stogov
1e4c553e0d Cleanup JMP optimization rules 2019-10-03 04:26:40 +03:00
Dmitry Stogov
6cac8d5b3b Optimizer cleanup
- all rules from pass2 moved to pass1
- all JMP unrelated rules from pass3 moved to pass1
- pass3 keeps only JMP optimization rules
- pass2.c is removed
- pass1_5.c remaned to pass1.c ("_5" was related to PHP 5)
2019-10-03 02:18:16 +03:00
Nikita Popov
a653240bd7 Prune opcache func info
Remove opcache func info for some functions which have arg info
with same or better accuracy (this is incomplete, we can drop more).
2019-10-02 10:54:47 +02:00
Nikita Popov
2f92957fd3 Convert some notices to warnings
Part of https://wiki.php.net/rfc/engine_warnings.
2019-10-02 10:34:08 +02:00
Nikita Popov
27ad0efb58 Revert "Save opline before fallible arg type check in recv_init jit"
This reverts commit b09bddcaa5.

This causes test failures on macos -- presumably the relevant
difference is that it has no global regs. I suspect that this
is related to the fact that SAVE_VALID_OPLINE may use r0 as
a scratch register, which is already in use. Reverting for now.
2019-10-01 22:16:56 +02:00
Nikita Popov
b09bddcaa5 Save opline before fallible arg type check in recv_init jit
The verify arg functions may throw an exception, so we need to save
the opline beforehand. Asan failures could be observed in
Zend/tests/type_declarations/scalar_constant_defaults.phpt
with a ZTS build.
2019-10-01 17:19:27 +02:00
Nikita Popov
01fc1a3057 Remove most uses of the ERROR type
It is now only used to signal exceptions for property reads. ERROR
zvals are never returned back to the VM anymore, so there's no
need to check for them when receiving a VAR.

Also return MAY_BE_ERROR, as ERROR is now no longer relevant for
inference.
2019-09-30 11:35:07 +02:00
Nikita Popov
e8b0163e0b Promote write "use scalar as array" warning to Error 2019-09-27 15:49:18 +02:00
Nikita Popov
0ebf2bdba0 Convert "Illegal offset type" warnings to exceptions 2019-09-27 13:00:07 +02:00
Nikita Popov
f2b09969db Convert "cannot add element" warning to exception 2019-09-27 13:00:07 +02:00
Nikita Popov
34e7c2daf0 Merge branch 'PHP-7.4' 2019-09-27 10:49:25 +02:00
Nikita Popov
a6c9c7c2b8 Handle resources used as array keys consistently
Resources used as array keys are generally handled by throwing a
notice and converting the resource to the resource handle. The only
exception is the [$resource => null] syntax, where this was treated
as an illegal offset type instead. However, this also only happened
for VM evaluations, the AST evaluator did handle resources correctly.
2019-09-27 10:40:41 +02:00
Nikita Popov
a66c60cce3 Throw Error when writing property of non-object
This removes object auto-vivification support.

This also means that we can remove the corresponding special
handling for typed properites: We no longer need to check that a
property is convertible to stdClass if such a conversion might
take place indirectly due to a nested property write.

Additionally OBJ_W style operations now no longer modify the
object operand, and as such we no longer need to treat op1 as a
def in SSA form.

The next step would be to actually compile the whole LHS of OBJ_W
operations in R rather than W mode, but that causes issues with
SimpleXML, whose object handlers depend on the current compilation
structure.

Part of https://wiki.php.net/rfc/engine_warnings.
2019-09-27 10:11:47 +02:00
Tyson Andre
e8d2097bdc Update opcache zend_func_info after wbmp/xml_parser changes
See UPGRADING on the master branch.

```
- GD:
  . The deprecated function image2wbmp() has been removed.
    RFC: https://wiki.php.net/rfc/image2wbmp
  . The deprecated functions png2wbmp() and jpeg2wbmp() have been removed.
    RFC: https://wiki.php.net/rfc/deprecate-png-jpeg-2wbmp
- XML:
  . xml_parser_create(_ns) will now return an XmlParser object rather than a
    resource.
```
2019-09-27 10:06:36 +02:00
Dmitry Stogov
7d7b20ea91 Don't generate useless stubs 2019-09-26 23:21:48 +03:00
Dmitry Stogov
cf33837d75 Cleanup CFG optimization 2019-09-25 17:30:59 +03:00
Nikita Popov
a369430b00 Avoid signed shift 2019-09-24 11:36:05 +02:00
Dmitry Stogov
1030ff5f5f Use cheaper code for scalar type check 2019-09-23 23:04:08 +03:00
Dmitry Stogov
6e226c188c Change ZEND_RECV and ZEND_RECV_VARIADIC to use extended_value for cache slot (instead of op2), to be consistent with ZEND_RECV_INIT. 2019-09-23 22:28:56 +03:00
Nikita Popov
9e8ba7891e Change representation of zend_type from type code to MAY_BE_* mask
This switches zend_type from storing a single IS_* type code to
storing a MAY_BE_* type mask. Right now most code still assumes
that there is only a single type in the mask (or two together
with MAY_BE_NULL). But this will make it a lot simpler to introduce
union types.

An additional advantage (and why I'm doing this separately), is
that a number of special cases no longer need to be handled
separately: We can do a single mask & (1 << type) check to handle
all simple types, booleans (true|false) and null.
2019-09-23 15:31:35 +02:00
Dmitry Stogov
ddfb3d6056 Fixed 32-bit JIT 2019-09-19 21:53:36 +03:00
Nikita Popov
edfcf2d81f Merge branch 'PHP-7.4' 2019-09-19 17:22:34 +02:00
Nikita Popov
5bee9c9062 Merge branch 'PHP-7.3' into PHP-7.4 2019-09-19 17:22:28 +02:00
Nikita Popov
85e7668129 Merge branch 'PHP-7.2' into PHP-7.3 2019-09-19 17:21:45 +02:00
Nikita Popov
003c13d7bc Fix iterable return type optimization 2019-09-19 17:21:00 +02:00
Nikita Popov
cdd4e591a4 Don't make argument nullable based on AST null initializer
Closes GH-4720.
2019-09-19 11:27:00 +02:00
Dmitry Stogov
2aefd11211 Optimize access to thread local cache.
This patch saves one CPU instruction on each "_tsrm_ls_cache" access in ZTS CLI/CGI/FPM builds.
This reduce typical instruction sequence for EG(current_execute_data) access from 4 to 3 CPU instructions.
2019-09-18 14:03:07 +03:00
Nikita Popov
8af9043766 Merge branch 'PHP-7.4' 2019-09-17 12:18:01 +02:00
Nikita Popov
62b440ffbb Merge branch 'PHP-7.3' into PHP-7.4 2019-09-17 12:09:06 +02:00
Nikita Popov
f98684b06c Merge branch 'PHP-7.2' into PHP-7.3 2019-09-17 12:08:57 +02:00
Tyson Andre
29bced9521 Fix opcache return type for get_headers in zend_func_info
https://www.php.net/manual/en/function.get-headers.php#refsect1-function.get-headers-examples
shows that it will return string keys when the second argument is
non-zero. I've verified that this is the case.

This bug was there since the initial commit in c88ffa9a56.

Closes GH-4702.
2019-09-17 12:08:29 +02:00
Christoph M. Becker
9b9fac78b0 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #78429: opcache_compile_file(__FILE__); segfaults
2019-09-16 16:01:49 +02:00
Christoph M. Becker
20f73d3d8f Fix #78429: opcache_compile_file(__FILE__); segfaults
We have to ensure that OPcache has been properly started up when
`opcache_compile_file()` is called.
2019-09-16 16:01:09 +02:00
Dmitry Stogov
78a890e45f Merge branch 'PHP-7.4'
* PHP-7.4:
  Make constant and copy propagation only for IS_TMP_VAR operands
2019-09-13 12:39:45 +03:00
Dmitry Stogov
af9b127fed Make constant and copy propagation only for IS_TMP_VAR operands 2019-09-13 12:38:57 +03:00
Nikita Popov
f61f122b9a Merge branch 'PHP-7.4' 2019-09-12 16:41:45 +02:00
Nikita Popov
4b9ebd837b Allow throwing exception while loading parent class
This is a fix for symfony/symfony#32995.

The behavior is:

* Throwing exception when loading parent/interface is allowed
  (and we will also throw one if the class is simply not found).
* If this happens, the bucket key for the class is reset, so
  it's possibly to try registering the same class again.
* However, if the class has already been used due to a variance
  obligation, the exception is upgraded to a fatal error, as we
  cannot safely unregister the class stub anymore.
2019-09-12 16:41:18 +02:00
Nikita Popov
c70bab7b24 Merge branch 'PHP-7.4' 2019-09-11 09:53:18 +02:00
Nikita Popov
0a24cd4e7c Preloading: Fix handling of static vars in inherited methods
Part of bug #78512.
2019-09-11 09:53:10 +02:00
Dmitry Stogov
628fd6ec71 clenup 2019-09-09 22:40:28 +03:00
Dmitry Stogov
f43fe067e9 Avoid hash value recalculation on each counter update 2019-09-09 21:25:54 +03:00
Nikita Popov
004f31c434 Merge branch 'PHP-7.4' 2019-09-09 17:19:12 +02:00
Tyson Andre
3e89e9a636 Add opcache return type for random_int()
random_int() will throw for incorrect argument counts, types (e.g. float
that can't cast to int), or having min > max.

See ext/standard/random.c
2019-09-09 17:19:04 +02:00
Tyson Andre
45e529d673 Fix opcache zend_func_info for microtime/gettimeofday
microtime() doesn't return an array,
and gettimeofday() doesn't return a string.
See _php_gettimeofday in microtime.c (mode is non-zero for gettimeofday)
2019-09-09 17:13:19 +02:00
Nikita Popov
f16ad678f7 Merge branch 'PHP-7.4' 2019-09-09 11:37:36 +02:00
Nikita Popov
36a8cf5182 Fixed bug #78514
The property class may have already been translated as part of
some other class. Only translate if xlat returns non-null.
2019-09-09 11:36:50 +02:00
Nikita Popov
ee4b11c668 Detect calls to abstract methods in get_method() already
Instead of checking for this during DO_FCALL, already detect this
case during get_method()/get_static_method(), similar to visibility
checks.

This causes a minor difference in behavior, in that arguments will
no longer be evaluated. I think this is correct though (and consistent
with visibility errors).
2019-09-06 15:05:24 +02:00
Nikita Popov
d9750ac41e Load execute_data without global regs 2019-09-05 10:46:50 +02:00
Nikita Popov
5d490742cb Fix deprecated args freeing with JIT
I'm including the logic for this rare case in the helper function
to avoid complicating the main JIT logic.
2019-09-05 10:05:46 +02:00
Nikita Popov
91b69beec8 Merge branch 'PHP-7.4' 2019-09-04 11:12:56 +02:00
Tyson Andre
94e2f25f07 Add missing opcache return types for functions in spl
(excluding spl_autoload)

spl_object_id() is of the most interest to me,
since I frequently call it in an application.

This includes false/null types caused by wrong argument types and wrong argument
counts.

I can't rule out iterator_to_array returning null in spl_iterator_apply,
so leave MAY_BE_NULL in.

With review comments by nikic:
Co-Authored-By: Nikita Popov <nikita.ppv@googlemail.com>
2019-09-04 11:12:41 +02:00
Dmitry Stogov
3be83233c3 Merge branch 'PHP-7.4'
* PHP-7.4:
  Execute preload script under user defined by opcache.preload_user directive
2019-09-03 14:23:44 +03:00
Dmitry Stogov
5dc37cc306 Execute preload script under user defined by opcache.preload_user directive 2019-09-03 14:23:13 +03:00
Nikita Popov
597a5da027 Support computing func info from ret arg info for internal funcs 2019-09-03 10:32:47 +02:00
Nikita Popov
3cca014ce4 Remove duplicate func info for array_key_first/last
Looks like this was already added in master separately...
2019-09-03 10:31:39 +02:00
Nikita Popov
d4a7d17b9a Merge branch 'PHP-7.4' 2019-09-03 09:58:29 +02:00
Tyson Andre
4de8503c22 Add missing opcache return info for ext/standard.
array_key_first/last returns null for invalid args,
wrong argument counts, and empty arrays.

random_bytes returns a string or throws.
2019-09-03 09:57:51 +02:00
Nikita Popov
d440a3cddb Merge branch 'PHP-7.4' 2019-09-03 09:53:51 +02:00
Tyson Andre
1a905bcb1e Add new missing functions from ext/hash 2019-09-03 09:53:41 +02:00
Tyson Andre
149588280b Fix opcache optimizer info for time_nanosleep (again)
Fixes my earlier PR #4617

If I remember correctly,
The F0 macro is used for return values that are guaranteed to not be
reference counted.
The F1 macro is used for return values that may have up to 1 reference
(i.e. MAY_BE_RC1).

I didn't notice that time_nanosleep needed to be F1 since it could
return an array, and that array is reference counted.
2019-09-03 09:31:01 +02:00
Nikita Popov
7f78f839dc php_stream_from_zval can no longer return false 2019-09-03 09:25:50 +02:00
Nikita Popov
3ac0f42c40 Merge branch 'PHP-7.4' 2019-09-03 09:24:20 +02:00
Nikita Popov
632708ac02 Merge branch 'PHP-7.3' into PHP-7.4 2019-09-03 09:24:05 +02:00
Nikita Popov
d66e0f165d Merge branch 'PHP-7.2' into PHP-7.3 2019-09-03 09:23:55 +02:00
Tyson Andre
9c3b7ccda5 Fix opcache return type for hash_update_stream
It can return false if the resource type is wrong.

```
php > var_export(hash_update_stream(hash_init('md5'),
        imagecreate(1,1)));

Warning: hash_update_stream(): supplied resource is not a valid stream
resource in php shell code on line 1
false
```

The return types were initially added in
c88ffa9a56
2019-09-03 09:23:39 +02:00
Dmitry Stogov
0581508ba4 Fixed pow() function info 2019-09-02 21:44:10 +03:00
Nikita Popov
24b1c2447c JIT: Fix missing free on JMPZ_EX with op1 == res
We need to free the operand before we overwrite it with the result.
2019-08-30 14:50:22 +02:00
Nikita Popov
65fa6dac19 Add jit_bisect_limit
To help identify which function is being miscompiled.
2019-08-30 14:50:22 +02:00
Nikita Popov
69cf535261 Fix func info for chop()
chop() is an alias of rtrim() and may return copied strings, so
should use FN.
2019-08-30 11:18:47 +02:00
Nikita Popov
8239b58bea Fix closure extra args freeing for JIT as well 2019-08-30 10:35:41 +02:00
Christoph M. Becker
0ab4fca8e3 Add ext\opcache stubs 2019-08-26 16:05:01 +02:00
Nikita Popov
774cdb1d59 Merge branch 'PHP-7.3' into PHP-7.4 2019-08-26 11:13:57 +02:00
Nikita Popov
e4ecadcb62 Merge branch 'PHP-7.2' into PHP-7.3 2019-08-26 11:13:49 +02:00
Tyson Andre
1e82a2d659 Also fix signature for passthru
Backported from a1a8d14485
https://www.php.net/manual/en/function.passthru.php#refsect1-function.passthru-returnvalues

`passthru()` is false with invalid args
`passthru('command')` is null.
2019-08-26 11:13:26 +02:00
Tyson Andre
f5bccc0eb5 Fix opcache optimizer info for time_nanosleep
This can also return an array. See
https://www.php.net/manual/en/function.time-nanosleep.php#refsect1-function.time-nanosleep-returnvalues

> If the delay was interrupted by a signal, an associative array will be
returned with the components:
>
> - seconds - number of seconds remaining in the delay
> - nanoseconds - number of nanoseconds remaining in the delay

Sending a SIGUSR1 to the below program would trigger this behavior.

```
pcntl_signal(\SIGUSR1, function ($signo, $signinfo) {
    echo "Handling a signal $signo\n";
});
echo "Sleeping for 100 seconds\n";
var_export(time_nanosleep(100, 0));
```

The incomplete signature existed since c88ffa9a5.
No phpt tests existed for time_nanosleep returning an array
2019-08-26 11:13:26 +02:00
George Peter Banyard
1059e3dc39 Promote warnings to errors in str_repeat() 2019-08-23 20:01:19 +02:00
Tyson Andre
50be2ecbd7 Fix opcache type info for stream_bucket_make_writable()
Closes GH-4567.
2019-08-20 16:21:53 +02:00
Nikita Popov
19378ae44a Merge branch 'PHP-7.4' 2019-08-13 11:23:35 +02:00
Nikita Popov
76fecb339f Merge branch 'PHP-7.3' into PHP-7.4 2019-08-13 11:23:06 +02:00
Nikita Popov
a33361a37c Merge branch 'PHP-7.2' into PHP-7.3 2019-08-13 11:22:41 +02:00
Nikita Popov
4eeb41d1ea Fixed bug #77191 2019-08-13 11:19:58 +02:00
Dmitry Stogov
f64650408a Merge branch 'PHP-7.4'
* PHP-7.4:
  typo
2019-08-06 13:58:29 +03:00
Dmitry Stogov
ef35556498 typo 2019-08-06 13:58:17 +03:00
Dmitry Stogov
e2440c3da5 Merge branch 'PHP-7.4'
* PHP-7.4:
  Preloading is not comatible with dl() function
2019-08-06 12:45:48 +03:00
Dmitry Stogov
d5d76ea6e7 Preloading is not comatible with dl() function 2019-08-06 12:44:55 +03:00
Dmitry Stogov
d6a8a5ac64 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #78376 (Incorrect preloading of constant static properties)
2019-08-05 22:56:03 +03:00
Dmitry Stogov
3fc0e2bb80 Fixed bug #78376 (Incorrect preloading of constant static properties) 2019-08-05 22:55:06 +03:00
Nikita Popov
21cd438c33 Merge branch 'PHP-7.4' 2019-08-01 17:00:49 +02:00
Nikita Popov
bf53d30fae Fix forwarding of extra args in opcache server tests 2019-08-01 17:00:11 +02:00
Nikita Popov
e63093e547 Merge branch 'PHP-7.4' 2019-08-01 10:11:02 +02:00
Nikita Popov
afd96392a3 Revert "Use RW fetch for argument unpacking"
This reverts commit 6913ec3282.
This reverts commit a9e332e027.

Causes https://bugs.php.net/bug.php?id=78356, which I don't have
a good solution for.
2019-08-01 10:06:53 +02:00
Nikita Popov
a4cfbeb143 Merge branch 'PHP-7.4' 2019-07-30 10:32:26 +02:00
Nikita Popov
a9e332e027 Handle RW UNPACK in inference 2019-07-30 10:31:51 +02:00
Christoph M. Becker
7548421202 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix build for --disable-signals
2019-07-29 18:50:13 +02:00
Christoph M. Becker
3429370d69 Fix build for --disable-signals 2019-07-29 18:49:44 +02:00
Nikita Popov
9a3aef3c21 Merge branch 'PHP-7.4' 2019-07-29 17:15:35 +02:00
Nikita Popov
6df1665bb3 Merge branch 'PHP-7.3' into PHP-7.4 2019-07-29 17:14:40 +02:00
Nikita Popov
bbed5564eb Merge branch 'PHP-7.2' into PHP-7.3 2019-07-29 16:57:57 +02:00
Nikita Popov
38f1288b64 Fix Zend signals unblocking
There are a few parts here:
 * opcache should not be blocking signals while invoking compile_file,
   otherwise signals may remain blocked on a compile error. While at
   it, also protect SHM memory during compile_file.
 * We should deactivate Zend signals at the end of the request, to make
   sure that we gracefully recover from a missing unblock and signals
   don't remain blocked forever.
 * We don't use a critical section in deactivation, because it should
   not be necessary. Additionally we want to clean up the signal queue,
   if it is non-empty.
 * Enable SIGG(check) in debug builds so we notice issues in the future.
2019-07-29 15:17:32 +02:00
Nikita Popov
45eabeca81 Merge branch 'PHP-7.4' 2019-07-29 13:03:59 +02:00
Nikita Popov
a22a06c351 Merge branch 'PHP-7.3' into PHP-7.4 2019-07-29 13:03:53 +02:00
Nikita Popov
8e63bb5e46 Fixed bug #78341
The smart branch logic assumed b->start refers to the old offsets,
while b->start was already adjusted to the new offsets at this
point. Delay the change until later.
2019-07-29 13:02:01 +02:00
Nikita Popov
36db71df47 Merge branch 'PHP-7.4' 2019-07-22 12:28:40 +02:00
Nikita Popov
b3f74b0b7d Deprecate allow_url_include 2019-07-22 11:39:52 +02:00
Dmitry Stogov
97912023bb Merge branch 'PHP-7.4'
* PHP-7.4:
  Use run-time cache to avoid repeatable hash lookups in ZEND_DECLARE_CLASS_DELAYED
2019-07-19 11:46:35 +03:00
Dmitry Stogov
445d51347d Use run-time cache to avoid repeatable hash lookups in ZEND_DECLARE_CLASS_DELAYED 2019-07-19 11:46:03 +03:00
Nikita Popov
eb766751dc Merge branch 'PHP-7.4' 2019-07-19 10:06:30 +02:00
rjhdby
d574df63dc Deprecate alternative array access syntax
RFC: https://wiki.php.net/rfc/deprecate_curly_braces_array_access
2019-07-19 10:06:10 +02:00
Dmitry Stogov
3cc6dd9c76 Fixed JIT 2019-07-19 10:50:51 +03:00
Dmitry Stogov
a837b80a48 Merge branch 'PHP-7.4'
* PHP-7.4:
  Use run-time cache to avoid repeatable hash lookups when creating anonymous functions and classes
2019-07-19 10:45:00 +03:00
Dmitry Stogov
d5943f5a11 Use run-time cache to avoid repeatable hash lookups when creating anonymous functions and classes 2019-07-19 10:43:49 +03:00
Dmitry Stogov
5ac3580b9b Merge branch 'PHP-7.4'
* PHP-7.4:
  ZEND_DECLARE_ANON_CLASS doesn't need to skip anything now. It's immediatelly followed by ZEND_NEW.
2019-07-19 10:10:50 +03:00
Dmitry Stogov
b065fbde19 ZEND_DECLARE_ANON_CLASS doesn't need to skip anything now. It's immediatelly followed by ZEND_NEW. 2019-07-19 10:09:26 +03:00
Peter Kokot
139ecf84ff Merge branch 'PHP-7.4'
* PHP-7.4:
  Update changelog
  Remove unused HAVE_SHM_MMAP_ZERO and HAVE_SHM_MMAP_FILE
2019-07-18 02:13:32 +02:00
Peter Kokot
6afc3cede8 Remove unused HAVE_SHM_MMAP_ZERO and HAVE_SHM_MMAP_FILE
Closes GH-4424
2019-07-18 02:11:19 +02:00
Christoph M. Becker
54401001a8 Merge branch 'PHP-7.4'
* PHP-7.4:
  Allow multiple cache instances per user/host on Windows
2019-07-17 19:52:49 +02:00
Christoph M. Becker
e2ed7e6716 Allow multiple cache instances per user/host on Windows
Formerly, there was at most a single OPcache instance per user and the
so called system ID (which is determined from the PHP version).
Sometimes multiple OPcaches might be desired, though, particularly for
unrelated CLI scripts, which may even be necessary (e.g. for our test
suite in parallel mode).

We therefore introduce a new INI directive `opcache.cache_id` which
allows to configure independent OPcache instances for the same user.

We also use `GetUserNameW()` instead of `php_win32_get_username()`,
because the latter retrieves the user name encoded in the
`default_charset`, which can obviously yield different results for
different charsets, leading to OPcache "incompatibilities".  Slightly
worse, some characters may not even be encodeable in the
`default_charset` and would be replaced by question marks, which could
result in different users sharing the same OPcache.

We also refactor, and re-use existing APIs to avoid duplicated code.
2019-07-17 19:51:07 +02:00
Dmitry Stogov
ca68570609 Merge branch 'PHP-7.4'
* PHP-7.4:
  Provide type info
2019-07-16 22:56:47 +03:00
Dmitry Stogov
a6812c0c84 Provide type info 2019-07-16 22:56:20 +03:00
Nikita Popov
c4a6998c62 Merge branch 'PHP-7.4' 2019-07-16 17:45:03 +02:00
Nikita Popov
b317f0eb59 Remove ZEND_HANDLE_MAPPED
The buf/len members are now simply used in addition to the main
stream, without changing the handle kind.
2019-07-16 17:44:32 +02:00
Nikita Popov
3faa903d47 Merge branch 'PHP-7.4' 2019-07-16 16:44:46 +02:00
Nikita Popov
49bac9b77b Introduce zend_stream_init_filename()
Avoid more ad-hoc initialization of zend_file_handle structures.
2019-07-16 16:44:37 +02:00
Nikita Popov
06cf349dc3 Merge branch 'PHP-7.4' 2019-07-16 15:48:24 +02:00
Nikita Popov
e08cc4d921 Remove ZEND_HANDLE_FD
This handle type was unused.
2019-07-16 15:47:10 +02:00
Nikita Popov
760308cbff Fix build without jit 2019-07-16 10:26:25 +02:00
Nikita Popov
8a10258a53 Merge branch 'PHP-7.4' 2019-07-15 10:33:31 +02:00
Nikita Popov
a520c24269 Merge branch 'PHP-7.3' into PHP-7.4 2019-07-15 10:29:37 +02:00
Nikita Popov
3eb057c4a7 Merge branch 'PHP-7.2' into PHP-7.3 2019-07-15 10:23:51 +02:00
Andrew Collington
768ad70f70 Fix bug #78291 Missing opcache directives
New opcache directives have been added recently which are returned
if using `ini_get_all('zend opcache')` but are not listed in the
directives if using `opcache_get_configuration()`.  This fix adds
those missing directives as well as if `opcache.mmap_base` is used
instead of `opcache.lockfile_path`.  Also adds a test to ensure the
directives match with both methods of fetching.
2019-07-15 10:22:47 +02:00
Nikita Popov
74bf7bfb88 Merge branch 'PHP-7.4' 2019-07-11 15:49:02 +02:00
Nikita Popov
17f7fb7605 Switch to using shell-less proc_open() in various server tests 2019-07-11 15:48:10 +02:00
Nikita Popov
cf7dd00280 Drop support for JIT without SSE
Closes GH-4388.
2019-07-10 17:31:51 +02:00
Nikita Popov
df84d680bf Merge branch 'PHP-7.4' 2019-07-10 17:28:52 +02:00
Nikita Popov
a54ee8a947 Merge branch 'PHP-7.3' into PHP-7.4 2019-07-10 17:28:37 +02:00
Nikita Popov
e7a83ec8df Fix bug #78271
When cleaning nops in the dfa pass, we were always keeping the
smart branch inhibiting nop that occurs directly before the jump
instruction. However, as we skip unreachable blocks entirely, it
may happen that we need to keep a nop that occurs further back,
prior to the unreachable blocks. Account for that case now.

We should really do something about the smart branch situation,
this is very fragile...
2019-07-10 17:25:40 +02:00
Nikita Popov
36235cf5d7 Read from original address
References are derefed into FCARG1, which is later clobbered by the
undef handling code. Make sure we load from the original address
instead.
2019-07-10 14:13:29 +02:00
Nikita Popov
26431d1995 Implement array access notice in JIT 2019-07-10 12:20:16 +02:00
Dmitry Stogov
db02d7ae75 Reduce cost for GC references to strings and resources in JIT 2019-07-10 12:41:19 +03:00
Nikita Popov
3ee570ae0d Remove redundant variable declaration 2019-07-08 12:50:00 +02:00
David Carlier
5e13688142 JIT: Reading php binary symbols list on FreeBSD
Closes GH-4363.
2019-07-08 12:39:18 +02:00
Nikita Popov
da8b583ac1 Always generate interrupt check in jit
Even if zend_interrupt_function is NULL, we still need to perform
the interrupt check for timeouts (which do not use
zend_interrupt_function).
2019-07-05 20:52:30 +02:00
Nikita Popov
e3c701ea38 Merge branch 'PHP-7.2' into PHP-7.3 2019-07-05 12:07:10 +02:00
Nikita Popov
5846e85283 Backport fe_reset_rw case 2019-07-05 12:06:52 +02:00
Nikita Popov
a92e6d7136 Merge branch 'PHP-7.4' 2019-07-05 12:05:10 +02:00
Nikita Popov
73fd2da754 Make sure all cases of fetch_dim_w adjustment are handled
Use EMPTY_SWITCH_DEFAULT_CASE() to trigger an assertion in case
we miss something.

Add missing FE_RESET_RW case.
2019-07-05 12:02:26 +02:00
Nikita Popov
8ae9e1b9a2 Merge branch 'PHP-7.4' 2019-07-05 11:43:26 +02:00
Nikita Popov
1086198711 Merge branch 'PHP-7.3' into PHP-7.4 2019-07-05 11:41:57 +02:00
Nikita Popov
920283ff2b Merge branch 'PHP-7.2' into PHP-7.3 2019-07-05 11:40:45 +02:00
Nikita Popov
c353f17d42 Fix inference for compound object op on dim 2019-07-05 11:39:42 +02:00
Dmitry Stogov
1f800e2f82 Removed die('skip wurstuoppe'); 2019-07-05 12:20:12 +03:00
Dmitry Stogov
1b5b8175af Merge branch 'PHP-7.4'
* PHP-7.4:
  Replace ZEND_ASSIGN_ADD (and others) by ZEND_ASSIGN_OP, ZEND_ASSIGN_DIM_OP, ZEND_ASSGIN_OBJ_OP and ZEND_ASSIGN_STATIC_PROP_OP
2019-07-05 12:16:30 +03:00
Dmitry Stogov
48ca5a1e17 Replace ZEND_ASSIGN_ADD (and others) by ZEND_ASSIGN_OP, ZEND_ASSIGN_DIM_OP, ZEND_ASSGIN_OBJ_OP and ZEND_ASSIGN_STATIC_PROP_OP 2019-07-05 12:03:25 +03:00
Nikita Popov
215e9d069c Merge branch 'PHP-7.4' 2019-07-05 11:00:54 +02:00
Nikita Popov
24ecfcc833 Add test
Forgot to commit this.
2019-07-05 11:00:27 +02:00
Nikita Popov
f8d8b96e92 Merge branch 'PHP-7.4' 2019-07-05 10:47:01 +02:00
Nikita Popov
ea43624972 Fix wrong size calculation related to function name
It would be nice if we could drop this manual function name reuse
code altogether and rely on interning for it.
2019-07-05 10:46:41 +02:00
Nikita Popov
d3c4841b18 Preloading: Don't move conditional functions to back to scripts
Conditional function declaration may be referenced by functions or
classes that have been preloaded, so we should not move them back
to scripts.

What we probably should be doing though is to discard conditional
functions that are not used in the optimizer. This is probably
reasonably common for polyfills, where we will be able to const-eval
the conditions and drop the BBs declaring the functions, but won't
delete the function declarations themselves.
2019-07-05 10:46:41 +02:00
Nikita Popov
9fbf9e3e13 Merge branch 'PHP-7.4' 2019-07-04 17:13:04 +02:00
Nikita Popov
a0e7624059 Compact literals: Don't insert unmergeable keys
LITERAL_VALUE with related literals cannot be merged, avoid inserting
them in the literals hash in the first place. Otherwise we may end up
inserting the same key multiple times. We may also miss merging
opportunities due to the duplicate keys.
2019-07-04 17:12:55 +02:00
Nikita Popov
8c647946ff Merge branch 'PHP-7.4' 2019-07-04 12:20:40 +02:00
Nikita Popov
b250f89b92 Preloading: Relax known type restrictions
Check whether there is a parent/interface/trait method with the same
name and only then require the type to be known. This reduces the
number of cases where this triggers in practice a lot.
2019-07-04 12:20:32 +02:00
Nikita Popov
4a2646cf45 Preloading: Also handle trait methods outside main script 2019-07-04 12:20:31 +02:00
Nikita Popov
6473ec30a1 Merge branch 'PHP-7.4' 2019-07-04 11:07:14 +02:00
Nikita Popov
df243f19be Preloading: Prevent autoloading while resolving constants 2019-07-04 11:05:01 +02:00
Nikita Popov
f124bf22e0 Merge branch 'PHP-7.4' 2019-07-03 14:05:31 +02:00
Nikita Popov
f857648270 Improve unlinked class diagnostics during preloading 2019-07-03 14:05:10 +02:00
Nikita Popov
fa1a03f7a2 Merge branch 'PHP-7.4' 2019-07-03 10:22:41 +02:00
Nikita Popov
c0924cf67d Merge branch 'PHP-7.3' into PHP-7.4 2019-07-03 10:20:32 +02:00
Nikita Popov
4892bbc167 Fixed bug #78230 2019-07-03 10:20:07 +02:00
Nikita Popov
ad81aae8bf Merge branch 'PHP-7.4' 2019-07-02 12:28:51 +02:00
Nikita Popov
4a08885ed9 Merge branch 'PHP-7.3' into PHP-7.4 2019-07-02 12:28:46 +02:00
Nikita Popov
7174c44557 Merge branch 'PHP-7.2' into PHP-7.3 2019-07-02 12:28:37 +02:00
Alex Scott
a4acff3e21 Fix bug #78138: opcache.validate_permission incorrectly works with PHAR files
opcache incorrectly handles PHAR files when opcache.validate_permission
option enabled, because it calls

  access("phar://path-to/file.phar/path/inside.php", R_OK);

rather than

  access("path-to/file.phar", R_OK)
2019-07-02 12:25:50 +02:00
Nikita Popov
2f7c3971cc Merge branch 'PHP-7.4' 2019-07-02 11:59:21 +02:00
David Carlier
7f1fef9fe0 Fix opcache huge page mapping on FreeBSD
Too much room were given process mappings and were not unmapped.

Closes GH-4345.
2019-07-02 11:59:08 +02:00
Christoph M. Becker
fc94e0fc6e Fix SKIPIF conditions
The SKIPIF sections are executed in the directory where run-tests.php
is located; therefore a relative path like `../skipif.inc` won't work
as desired.
2019-07-01 19:47:23 +02:00
Christoph M. Becker
8a0717255c Merge branch 'PHP-7.4'
* PHP-7.4:
  Add missing SKIPIFs
2019-07-01 18:14:55 +02:00
Christoph M. Becker
52a0630cd4 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Add missing SKIPIFs
2019-07-01 18:13:52 +02:00
Christoph M. Becker
3e25ddb07b Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Add missing SKIPIFs
2019-07-01 18:12:28 +02:00
Christoph M. Becker
57688ad7bf Add missing SKIPIFs
All these tests are meant to run with OPcache available, and some will
even fail inevitably without it, so we add OPcache as SKIPIF
requirement.
2019-07-01 18:11:13 +02:00
Christoph M. Becker
017e293992 Merge branch 'PHP-7.4'
* PHP-7.4:
  Add missing SKIPIFs
2019-07-01 17:25:31 +02:00
Christoph M. Becker
42bedcfb50 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Add missing SKIPIFs
2019-07-01 17:24:33 +02:00
Christoph M. Becker
99e6c701e6 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Add missing SKIPIFs
2019-07-01 17:22:55 +02:00
Christoph M. Becker
75bc3446f8 Add missing SKIPIFs
All these tests are meant to run with OPcache available, and some will
even fail inevitably without it, so we add OPcache as SKIPIF
requirement.
2019-07-01 17:21:16 +02:00
Nikita Popov
4e1a225e3e Merge branch 'PHP-7.4' 2019-07-01 16:55:39 +02:00
David Carlier
994a01ea43 opcache huge pages: Little fix for FreeBSD
Calculating the vm entries size beforehand, as we could
possibly miss few entries.

Closes GH-4344.
2019-07-01 16:55:23 +02:00
Christoph M. Becker
b8d6d4a2bd Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix brittle test
2019-07-01 16:45:49 +02:00
Christoph M. Becker
237f07ea9d Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix brittle test
2019-07-01 16:44:54 +02:00
Christoph M. Becker
d714be0f57 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix brittle test
2019-07-01 16:43:47 +02:00
Christoph M. Becker
be559e6c37 Fix brittle test
This test is easily tripped by former test runs with other PHP
versions.  To avoid such false positives, we check that there is at
least one respective OPcache file, and that all found OPcache user ID
folders have exactly 32 hexadecimal digits.
2019-07-01 16:42:55 +02:00
Nikita Popov
8fc58a1a1d Merge branch 'PHP-7.4' 2019-07-01 11:14:54 +02:00
Nikita Popov
da06f7f383 Msan: Unpoison buffer written by file cache
It would be great if this were fully initialized, but it's not
really a problem either (as long as we don't care about reproducible
file cache), so ignore this for now.
2019-07-01 11:14:28 +02:00
Nikita Popov
c8af6a7fa7 Don't use fast_memcpy under msan 2019-07-01 11:14:23 +02:00
Nikita Popov
4a8fe02c7c Undef opline result on mod/shift error in jit 2019-07-01 10:15:06 +02:00
Nikita Popov
b7ed20662e Fix out of bounds read in jit_fetch_obj_read 2019-07-01 09:54:21 +02:00
Peter Kokot
98d0892dd8 Merge branch 'PHP-7.4'
* PHP-7.4:
  Sync functions checks
2019-06-30 23:59:47 +02:00
Peter Kokot
9a3c8e51e3 Sync functions checks
Removed unused checks:
- mbsinit check removed, HAVE_MBSINIT removed (not used in php-src)
- mempcpy check removed, HAVE_MEMPCPY removed (not used in php-src anymore since
  560ed89bfb which uses PHP's own implementation)
- strpncpy check removed, added via a8c9e893b6 and
  not used.
- setpgid check removed since HAVE_SETPGID is not used

Moved to a central configure.ac:
- fpclass
- mbrlen moved to configure.ac (since the HAVE_MBRLEN is used accross the php-src)
- sigprocmask
- getcwd
- getwd
- glob
- strfmon
- nice

Duplicated checks removed:
- gethostname
- getlogin
- getpwuid_r
- socketpair

- mprotect check simplified
2019-06-30 23:57:54 +02:00
Nikita Popov
b98c148f78 Merge branch 'PHP-7.4' 2019-06-28 15:05:00 +02:00
Nikita Popov
54dd762f59 Set up asan+ubsan scheduled build on azure
Also adds an --asan flag to run-tests.php to setup all the necessary
environment variables. Some tests are marked as skipped because they
are incompatible with asan or too slow.

I'm basing this on the DEBUG_ZTS build, which seems to give us the
most mileage.
2019-06-28 15:00:54 +02:00
Nikita Popov
0a0ca984f0 Merge branch 'PHP-7.4' 2019-06-28 14:48:08 +02:00
Nikita Popov
ca6f41aa5a Fix out of bounds read in sccp 2019-06-28 14:47:49 +02:00
Nikita Popov
aa8d70f309 Merge branch 'PHP-7.4' 2019-06-28 09:19:49 +02:00
Nikita Popov
a78adce5cb Free ZTS lock in opcache
For some reason this only shows up as a leak when using phpdbg.
2019-06-28 09:18:14 +02:00
Peter Kokot
7f994990ea Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove HAVE_STRCOLL check
2019-06-28 00:13:25 +02:00
Peter Kokot
638c21765c Remove HAVE_STRCOLL check
The strcoll function is defined in the C89 standard and should be
on today's systems always available via the <string.h> header.

https://port70.net/~nsz/c/c89/c89-draft.html#4.11.4.3

- Remove also SKIPIF strcoll check in test
2019-06-28 00:05:55 +02:00
Nikita Popov
e31936205b Merge branch 'PHP-7.4' 2019-06-27 16:16:57 +02:00
Nikita Popov
40d6147dd0 Fix opcache blacklist leak
Don't recompute (and leak) the regex for every glob element, only
do this once at the end.
2019-06-27 16:11:58 +02:00
Peter Kokot
6bfa6bff0b Merge branch 'PHP-7.4'
* PHP-7.4:
  Clean headers checks
2019-06-27 02:45:31 +02:00
Peter Kokot
2079b09854 Clean headers checks
Some headers were checked multiple times in the main configure.ac file
and in the bundled extensions or SAPIs themselves. Also many of these
checks are then used accross other extensions or SAPIs so a central
configure.ac makes most sense for these checks.
2019-06-27 02:45:09 +02:00
Christoph M. Becker
d1141ff24b Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #78202: Opcache stats for cache hits are capped at 32bit NUM
2019-06-25 13:07:00 +02:00
Christoph M. Becker
ead40e31e9 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #78202: Opcache stats for cache hits are capped at 32bit NUM
2019-06-25 13:06:20 +02:00
Christoph M. Becker
18bba63f39 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #78202: Opcache stats for cache hits are capped at 32bit NUM
2019-06-25 13:04:28 +02:00
Christoph M. Becker
4366f22dfc Fix #78202: Opcache stats for cache hits are capped at 32bit NUM
We use the proper format specifiers now.
2019-06-25 13:00:28 +02:00
Dmitry Stogov
ca22c456ca Merge branch 'PHP-7.4'
* PHP-7.4:
  Keep lowercased parent class name as second argument of DECLARE_CLASS to avoid extra work at run-time
2019-06-25 11:32:03 +03:00
Dmitry Stogov
759f4ecd8b Keep lowercased parent class name as second argument of DECLARE_CLASS to avoid extra work at run-time 2019-06-25 11:30:58 +03:00
Dmitry Stogov
e18c60cd8d Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug 78175 (Preloading must store default values of static variables and properties)
2019-06-24 20:34:05 +03:00
Dmitry Stogov
0f29fb5cd8 Fixed bug 78175 (Preloading must store default values of static variables and properties) 2019-06-24 20:32:27 +03:00
Nikita Popov
38909b7526 Merge branch 'PHP-7.4' 2019-06-21 10:25:17 +02:00
Nikita Popov
7a1ca07a60 Don't try to exclude zreg_none
zreg_none has no representation in the regset, so this operation
doesn't make sense.
2019-06-21 10:24:58 +02:00
Nikita Popov
8227e0f747 Avoid ub in shift overflow check
Also fix an off-by-one error. While 1 << 63 overflows, -1 << 63 does
not.
2019-06-21 10:24:27 +02:00