1
0
mirror of https://github.com/php/php-src.git synced 2026-04-19 22:11:12 +02:00
Commit Graph

760 Commits

Author SHA1 Message Date
Dmitry Stogov
3e996622c7 Replace function with macro 2021-03-24 10:36:47 +03:00
Dmitry Stogov
7adaec1ce8 Move system independent code out from x86 specific header 2021-03-23 17:12:15 +03:00
Dmitry Stogov
c290de157c Move x86 dependent code out from platform independed parts. 2021-03-23 16:39:51 +03:00
Dmitry Stogov
617276d807 Use capstone disassembler, if available. 2021-03-23 12:39:42 +03:00
Dmitry Stogov
6690547a58 Use zend_hash_lookup() 2021-03-19 23:34:38 +03:00
Nikita Popov
2d0e2733c8 Support prototypes in call graph
Even if we don't know the exact method being called, include it
in the call graph with the is_prototype flag. In particular, we
can still make use of return types from prototype methods, as
PHP 8 makes LSP violations a hard error.

Most other places are adjusted to skip calls with !is_prototype.
Maybe some of them would be fine, but ignoring them is conservative.
2021-03-19 10:49:15 +01:00
Nikita Popov
2f73cbb1b1 Update one more use of NO_AUTOLOAD 2021-03-18 16:25:22 +01:00
Dmitry Stogov
eb8f5e4347 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80861 (erronous array key overflow in 2D array with JIT)
2021-03-17 23:00:22 +03:00
Dmitry Stogov
7e494d9225 Fixed bug #80861 (erronous array key overflow in 2D array with JIT) 2021-03-17 22:59:59 +03:00
Dmitry Stogov
8f0ca7c16c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80839 (PHP problem with JIT)
2021-03-17 16:55:42 +03:00
Dmitry Stogov
faf1567212 Fixed bug #80839 (PHP problem with JIT) 2021-03-17 16:55:09 +03:00
Dmitry Stogov
d336ccaa08 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80814 (threaded mod_php won't load on FreeBSD: No space available for static Thread Local Storage)
2021-03-10 16:04:33 +03:00
Dmitry Stogov
3b377b51a2 Fixed bug #80814 (threaded mod_php won't load on FreeBSD: No space available for static Thread Local Storage) 2021-03-10 16:03:47 +03:00
Dmitry Stogov
ae2ea348dd Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80782 (DASM_S_RANGE_VREG on PHP_INT_MIN-1)
2021-02-24 12:20:49 +03:00
Dmitry Stogov
b7fa5268e4 Fixed bug #80782 (DASM_S_RANGE_VREG on PHP_INT_MIN-1) 2021-02-24 12:20:20 +03:00
Nikita Popov
8be711be47 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80786
2021-02-23 10:22:20 +01:00
Nikita Popov
79cf2c56d3 Fixed bug #80786
Don't use r0 as temporary register in math_double_long if it is
already used for a memory result.

This was already done in one branch, but not the other.
2021-02-23 10:22:00 +01:00
Dmitry Stogov
5c78e87399 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80745 (JIT produces Assert failure and UNKNOWN:0 var_dumps in code involving bitshifts)
2021-02-17 11:51:50 +03:00
Dmitry Stogov
7f68a7afe6 Fixed bug #80745 (JIT produces Assert failure and UNKNOWN:0 var_dumps in code involving bitshifts) 2021-02-17 11:51:13 +03:00
Dmitry Stogov
319f73e06b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80742 (Opcache JIT makes some boolean logic unexpectedly be true)
2021-02-16 20:02:48 +03:00
Dmitry Stogov
fad87a24da Fixed bug #80742 (Opcache JIT makes some boolean logic unexpectedly be true) 2021-02-16 20:02:12 +03:00
Nikita Popov
f74a02d263 Revert "Implement fetching TLS TCB offset on MacOS"
This reverts commit 1106ff9a0e.

Looks like this sauses segfaults on MacOs ZTS with JIT.
2021-02-12 15:16:05 +01:00
David Carlier
1106ff9a0e Implement fetching TLS TCB offset on MacOS
Tested with php-cgi and wordpress and 1255 for jit settings.

Closes GH-6659.
2021-02-11 15:48:20 +01:00
Dmitry Stogov
ef51648185 Use zend_type.ce_cache__ptr for caching class resulution during argument/result type checks 2021-02-10 18:00:00 +03:00
Tyson Andre
d9510342ee Optimize ZEND_COUNT opcodes on arrays in the jit
Avoid the overhead of a call and checking types
when the argument is definitely an array.
Avoid the overhead of gc when `__destruct` won't get called.

This seemed cheap enough to check for in the jit.

Because of https://wiki.php.net/rfc/restrict_globals_usage
we can be sure in the ZEND_COUNT handler that the array count does not have to
be recomputed in php 8.1.

The below example took 0.854 seconds before the optimization,
and 0.564 seconds after the optimization, giving the same result

```php
<?php
/** @jit */
function bench_count(int $n): int {
    $total = 0;
    $arr = [];
    for ($i = 0; $i < $n; $i++) {
        $arr[] = $i;
        $total += count($arr);
    }
    return $total;
}

function main() {
    $n = 1000;
    $iterations = 50000;
    $start = microtime(true);
    $result = 0;
    for ($i = 0; $i < $iterations; $i++) {
        $result += bench_count($n);
    }
    $elapsed = microtime(true) - $start;

    printf("Total for n=%d, iterations=%d = %d, elapsed=%.3f\n", $n, $iterations, $result, $elapsed);
}
main();
```

Before

```asm
mov $0x7feb8cf8a858, %r15
mov $ZEND_COUNT_SPEC_CV_UNUSED_HANDLER, %rax
call *%rax
```

After

```asm
mov 0x70(%r14), %rdi - Copy the count from the `zend_array*` pointer
mov %rdi, (%rax)     - Store the count in the destination's value
mov $0x4, 0x8(%rax)  - Store IS_LONG(4) in the destination's type
```

And add tracing jit support

Closes GH-5584
2021-02-09 16:09:32 -05:00
Dmitry Stogov
4b79dba932 Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.

PHP  classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.

Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).

The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-09 22:53:57 +03:00
Dmitry Stogov
b6bfb27b8e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed observer API and JIT compatibility
2021-01-26 21:31:51 +03:00
Dmitry Stogov
64622979f9 Fixed observer API and JIT compatibility 2021-01-26 21:31:15 +03:00
Nikita Popov
7571edc398 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix opcache phpize build on FreeBSD
  Updated to version 2021.1 (2021a)
2021-01-25 15:11:56 +01:00
Alex Samorukov
527bcb1e2e Fix opcache phpize build on FreeBSD
Closes GH-6589.
2021-01-25 15:10:47 +01:00
Dmitry Stogov
378f870d7c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80634 (write_property handler of internal classes is skipped on preloaded JITted code)
2021-01-20 11:04:30 +03:00
Dmitry Stogov
6288228b56 Fixed bug #80634 (write_property handler of internal classes is skipped on preloaded JITted code) 2021-01-20 11:03:37 +03:00
Nikita Popov
e422ab2af7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Keep JIT region executable under ZTS
2021-01-19 10:28:42 +01:00
Dylan K. Taylor
872f302b8d Keep JIT region executable under ZTS
When one thread tries to compile a script, another thread may
already be executing JITed code. In this case we can't make the
memory non-executable.

This violates the W^X principle, but doesn't seem to be avoidable
for ZTS builds for now. The same problem does not exist for NTS,
as it's a different process executing there, which has it's own
memory protection mapping.

Closes GH-6595.
2021-01-19 10:25:42 +01:00
Nikita Popov
29cf59895a Merge branch 'PHP-8.0'
* PHP-8.0:
  Observe unused return values in JIT
2021-01-19 10:10:08 +01:00
Nikita Popov
fbd8e20ed5 Observe unused return values in JIT
Even if the return value is not used, it should still be available
to the observer.
2021-01-19 10:09:53 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Dmitry Stogov
924ec32426 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80422 (php_opcache.dll crashes when using Apache 2.4 with JIT)
2021-01-14 08:16:50 +03:00
Dmitry Stogov
3edf5c969a Fixed bug #80422 (php_opcache.dll crashes when using Apache 2.4 with JIT) 2021-01-14 08:16:27 +03:00
Dmitry Stogov
c6b2b3b1b5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add guard if lvalue of assignment may be a reference, but wasn't a reference during recording
2021-01-11 15:13:32 +03:00
Dmitry Stogov
35e0506a2e Add guard if lvalue of assignment may be a reference, but wasn't a reference during recording 2021-01-11 15:12:27 +03:00
Dmitry Stogov
d9e441be42 Better CPU registers usage 2021-01-11 14:40:30 +03:00
Dmitry Stogov
59401aa2ef Remove redundand IS_INDIRECT checks (they were necessary for $GLOBALS handling) 2021-01-11 14:39:21 +03:00
Nikita Popov
63263abff8 Remove unnecessary INDIRECT checks in JIT helpers 2021-01-06 14:28:17 +01:00
Dmitry Stogov
da0ca53f39 Initialize EX(call)->func by single instruction 2020-12-29 13:20:10 +03:00
Dmitry Stogov
56fde2a381 Reuse value stored in %r0 instead of immediate operand 2020-12-29 13:18:56 +03:00
Dmitry Stogov
23bbff2b05 Eliminate redundand comparison insructions 2020-12-24 16:58:54 +03:00
Ayesh Karunaratne
724e241c9d JIT: Update invalid opcache.jit INI value message to include "tracing" and "function" values
`opcache.jit` accepts `tracing` and `function` as aliases, but they were not mentioned in the start-up INI warning message.
This updates the error message to include all possible values.

Closes GH-6490.
2020-12-15 10:18:33 +01:00
Dmitry Stogov
dde5572937 Eliminate some repeatable IS_REFERENCE checks 2020-12-10 14:45:54 +03:00
Dmitry Stogov
e9f9e9f863 Perform early guard type check for result of FETCH_CONSTANT 2020-12-09 22:24:03 +03:00