php / php/php-src

MSVC ZEND_FASTCALL not portable?

オープン
#17,497 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Category: Engine Category: JIT OS: Windows Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 15時間
マージ済み PR(30日)
103

説明

Description

When building with MSVC (or clang-cl), ZEND_FASTCALL is defined as __vectorcall. While __vectorcall is similar to the default x64 calling convention, and __fastcall on x86, respectively, there are notable differences. It seems to me that our JIT does not cater to these. That may still not be relevant to core functions, but could be an issue with external extensions which declare function as ZEND_FASTCALL.

Furthermore, there is definitely an issue regarding portability, since GCC doesn't support __vectorcall at all. While we do not necessarily support GCC on Windows, compatibility still seems to be a good thing.

Note that even __fastcall appears to be slightly different to the Windows __fastcall convention:

On x86-32 targets, the fastcall attribute causes the compiler to pass the first argument (if of integral type) in the register ECX and the second argument (if of integral type) in the register EDX. Subsequent and other typed arguments are passed on the stack.

The first two DWORD or smaller arguments that are found in the argument list from left to right are passed in ECX and EDX registers; all other arguments are passed on the stack from right to left.

This is possibly just a documentation issue (I haven't checked).

Anyhow, I suggest to change ZEND_FASTCALL with MSVC to use the default x64 calling convention for the x64 ABI; not sure what to suggest regarding x86.

cc @dstogov, @nielsdos, @arnaud-lb

PHP Version

PHP 8.4 (likely older)

Operating System

Windows

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

このissueではZEND_FASTCALL、MSVC、clang-cl、GCC、JITの名前が挙げられていますが、ファイルやテストは示されていません。まずZEND_FASTCALLの定義とJITでのcalling conventionの処理を探し、次に関連するx64およびx86のABIを比較してください。対応しているコンパイラでポータブルな動作を確立し、x86の規約に関する問題を解決できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c
領域
compilers
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
32/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。