JIT: Set the IP and check for invalidation in `POP_TOP` only if `Py_Dealloc` is called.
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
The optimizer removes many POP_TOPs, but quite a few remain.
The code for POP_TOP looks like this:
inst(POP_TOP, (value --)) {
PyStackRef_XCLOSE(value);
}
which is fine for the interprete but in the JIT, as POP_TOP is marked as escaping, we need to set the IP before and check for invalidation afterwards.
What we could do, is have a version of POP_TOP that sets the IP and checks for invalidation only if Py_Dealloc is called, so we don't need to add SET_IP and CHECK_VALIDITY.
The new form of POP_TOP would look like this:
op(_POP_TOP_SET_IP_CHECK_INVALID, (value --)) {
if (do_decref_and_refcnt_is_zero(value)) {
SET_IP()
Py_Dealloc()
CHECK_VALID();
}
}
_POP_TOP_SET_IP_CHECK_INVALID should be inserted in the same pass that we insert _SET_IP and _CHECK_VALIDITY as we know whether we need to insert those uops, and leave POP_TOP alone in those cases.
Overall, this should speed things up as it doesn't increase the overall code size, but it does execute less code in many cases.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
檢查 POP_TOP 的 JIT 實作,以及插入 _SET_IP 和 _CHECK_VALIDITY 的 pass。追蹤 do_decref_and_refcnt_is_zero 以及現有的 SET_IP、Py_Dealloc 和 CHECK_VALID 路徑;完成的標準是,僅在需要的位置插入專用形式,同時其他位置的 POP_TOP 維持不變,並保留失效行為。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- c, python
- 領域
- compilers, performance
- Issue 類型
- 重構
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100