MSVC ZEND_FASTCALL not portable?
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.1k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
L’issue cita ZEND_FASTCALL, MSVC, clang-cl, GCC e il JIT, ma non indica file o test. Inizia individuando le definizioni di ZEND_FASTCALL e la gestione della calling convention nel JIT, quindi confronta le ABI x64 e x86 pertinenti. Il lavoro è completato quando è stato stabilito un comportamento portabile per i compilatori supportati e risolta la questione della convenzione x86.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 32/100