In the case where there are still references to an array being iterated
over when the iterator is freed (or the array is not reference counted):
- There's need to save the opline.
- There's no need to check for exceptions.
```
// Before: 0.404 seconds
// After: 0.362 seconds
// loop_iter_empty(1000, 5000);
function loop_iter_empty(int $a, int $b) {
$values = array_fill(0, $b, []);
$total = 0;
for ($i = 0; $i < $b; $i++) {
foreach ($values as $v) {
foreach ($v as $x) {
$total += $x;
}
}
}
return $total;
}
```
And `$x = !$x`
Noticed while working on GH-4912
The included test would not emit undefined variable errors in php 8.0
with opcache enabled. The command used:
```
php -d zend_extension=opcache.so --no-php-ini -d error_reporting=E_ALL \
-d opcache.file_cache= -d opcache.enable_cli=1 test.php
```
Postpone signal delivery while spawning children.
Prevent the following case:
- Reload (reexec) is in progress.
- New master is forking to start enough children for pools
where `pm` is not `on-demand`.
- Another `SIGUSR2` is received by the master process.
- Master process switches to reloading state.
- Some child has not set its own signal handlers.
- `SIGQUIT` and `SIGTERM` sent by master process are caught
by signal handler set by master process and so they are ignored.
- A child is running, it has no reason to finish
Before pull request #4465 this scenario could cause deadlock,
however with 0ed6c37140 reload finishes after `SIGKILL`.
Use sigprocmask() around fork() to avoid race of delivery signal to children
and setting of own signal handlers.
Fixes bug #76601
Using this requires care! The zpp implementation for this union
must be consistent with the arginfo implementation!
Apart from array|object, this is probably only the case for
int|float right now.
Do this by reusing the implementation used for `==`
when both arguments are ints (IS_LONG) or both are floats (IS_DOUBLE)
```php
// Before: nestedloop_ni took 0.442 seconds
// After: nestedloop_ni takes 0.401 seconds (same as nestedloop_ne)
function nestedloop_ni(int $k) {
$x = 0;
for ($i=0; $i < 50000000; $i++) {
if ($i === $k) {
$x++;
}
}
print "$x\n";
}
function nestedloop_ne(int $k) {
$x = 0;
for ($i=0; $i < 50000000; $i++) {
if ($i == $k) {
$x++;
}
}
print "$x\n";
}
```
Opcache stores `opline->handler`s in shared memory. These pointers are
invalid, if the main PHP DLL is loaded at another base address due to
ASLR. We therefore store the address of `execute_ex` in the mmap base
file, and check on startup whether it matches its current address. If
not, we fall back on the file cache if enabled, and bail out otherwise.
This still does not address cases where the opline handler is located
inside of another DLL (e.g. for some profilers, debuggers), but there
seems to be no general solution for now.
(cherry picked from commit 8ba10b8fbc)
That parameter is mostly useless in practise, and likely has been
directly ported from the underlying `gdImagePolygon()` and friends,
which require that parameter since the number of elements of the point
array would otherwise be unknown. Typical usages of `imagepolygon()`,
`imageopenpolygon()` and `imagefilledpolygon()` pass `count($points)/2`
or hard-code this value as literal. Since explicitly specifying this
parameter is annoying and error-prone, we offer the possibility to omit
it, in which case the `$points` array must have an even number of
elements, and the number of points is calculated as `count($points)/2`.
Optimizations such as specializations for is_resource were first added in
dfb4f6b38d9efedafab7d2d98b9333715561256
I don't see any mention of is_scalar (and optimizing it) in the commit history,
or in prior PRs on github, or searching for is_scalar in externals.io