php / php/php-src

Tracing JIT drops loop-PHI CV register from SNAPSHOT after intermediate op1_def

未关闭
#22,115 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Status: Needs Triage
主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 13 小时
30 天内合并 PR
96

描述

Description

Tracing JIT returns wrong values from hot loops!

<?php
function f(array $meta, int $n): int {
    $s = 0; $i = 0; $sink = 0;
    while ($i < $n) {
        $copy = $s;                    // QM_ASSIGN, op1_def on $s under RC inference
        $sink += $copy;                // keep ASSIGN past DCE
        $m = (int) $meta[$s];          // FETCH_DIM_R use of $s, ZREG_LAST_USE
        if (($m & 0xFF) === 1) {       // IS_IDENTICAL guard, side-exit's SNAPSHOT misses $s
            $i++;
            $s = ($m >> 32) & 0xFFFFFF;
            continue;
        }
        return $s;
    }
    return $s;
}
$meta = [0 => 1 | (1 << 32), 1 => 2 | (2 << 32)];
for ($w = 0; $w < 2000; $w++) f($meta, 3);
var_dump(f($meta, 3));

Results in:

$ php -d opcache.enable_cli=1 -d opcache.jit_buffer_size=64M -d opcache.jit=tracing repro.php
int(0)

Expected:

$ php -d opcache.enable_cli=1 -d opcache.jit_buffer_size=64M -d opcache.jit=function repro.php
int(1)
PHP Version

PHP 8.4 and above

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用 tracing JIT 和 function JIT 设置运行提供的 repro.php,然后比较所得值,并检查中间操作和 side exit 附近循环的 snapshot 行为。完成的标准是 tracing JIT 返回 int(1),与 function JIT 的结果一致,同时不导致提供的 hot-loop 用例出现回归。

由索引模型根据 Issue 内容生成。

评估

技术栈
c, php
领域
compilers
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。