php / php/php-src

MSVC ZEND_FASTCALL not portable?

Đang mở
#17,497 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Bug Category: Engine Category: JIT OS: Windows Status: Needs Triage
Ngôn ngữ chính
C
Star
40.4k
Fork
8.1k
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
96

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Issue này nêu tên ZEND_FASTCALL, MSVC, clang-cl, GCC và JIT nhưng không có file hoặc test nào. Hãy bắt đầu bằng việc tìm các định nghĩa của ZEND_FASTCALL và cách JIT xử lý calling convention, sau đó so sánh các ABI x64 và x86 liên quan. Được xem là hoàn tất khi đã thiết lập hành vi portable cho các compiler được hỗ trợ và giải quyết được vấn đề về convention trên x86.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
c
Lĩnh vực
compilers
Loại issue
Lỗi
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
32/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.