Skip to content

Provide script to TSSA build in tracing JIT #18353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nielsdos
Copy link
Member

For the following script:

final class Foo {
  public $prop = 0;
}
function test(Foo $obj) {
  $obj->prop=1;
}

$foo = new Foo;
for ($i=0;$i<3;$i++) {
  test($foo);
}

When comparing the TSSA (via opcache.jit_debug) vs the opcache SSA (via opcache.opt_debug_level=0x400000) we note that in TSSA, the RECV op for test does not infer the type of the argument to be class Foo. This is because the optimizer uses the script pointer to figure out known classes but TSSA always sets script to NULL. This in turn generates suboptimal assembly because zend_may_throw returns 1 due to the unknown CE in the TSSA, resulting in an extra exception check in the assembly code.

@nielsdos nielsdos force-pushed the jit-experiments-1 branch 2 times, most recently from 9b8e160 to ee732d3 Compare April 21, 2025 12:34
For the following script:
```php
final class Foo {
  public $prop = 0;
}
function test(Foo $obj) {
  $obj->prop=1;
}

$foo = new Foo;
for ($i=0;$i<3;$i++) {
  test($foo);
}
```

When comparing the TSSA (via opcache.jit_debug) vs the opcache SSA
(via opcache.opt_debug_level=0x400000) we note that in TSSA, the RECV op
for `test` does not infer the type of the argument to be class `Foo`.
This is because the optimizer uses the `script` pointer to figure out
known classes but TSSA always sets `script` to NULL. This in turn
generates suboptimal assembly because `zend_may_throw` returns 1 due to
the unknown CE in the TSSA, resulting in an extra exception check in the
assembly code.
@nielsdos nielsdos marked this pull request as ready for review April 21, 2025 13:39
@nielsdos nielsdos requested a review from dstogov as a code owner April 21, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant