Skip to content

Commit ee732d3

Browse files
committed
Provide script to TSSA build in tracing JIT
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.
1 parent 8376904 commit ee732d3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ext/opcache/jit/zend_jit_trace.c

+8
Original file line numberDiff line numberDiff line change
@@ -4117,6 +4117,14 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
41174117

41184118
checkpoint = zend_arena_checkpoint(CG(arena));
41194119

4120+
zend_accel_hash_entry *accel_h_entry = zend_accel_hash_find_entry(&ZCSG(hash), trace_buffer->op_array->filename);
4121+
if (accel_h_entry) {
4122+
zend_persistent_script *persistent_script = (zend_persistent_script *) accel_h_entry->data;
4123+
if (!persistent_script->corrupted) {
4124+
script = &persistent_script->script;
4125+
}
4126+
}
4127+
41204128
ssa = zend_jit_trace_build_tssa(trace_buffer, parent_trace, exit_num, script, op_arrays, &num_op_arrays);
41214129

41224130
if (!ssa) {

0 commit comments

Comments
 (0)