Req #78270 [Fbk->Opn]: Usage of __vectorcall convention with FFI

From: Date: Mon, 22 Jul 2019 13:45:40 +0000
Subject: Req #78270 [Fbk->Opn]: Usage of __vectorcall convention with FFI
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221892@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78270&edit=1 ID: 78270 Updated by: cmb@php.net Reported by: lisachenko dot it at gmail dot com Summary: Usage of __vectorcall convention with FFI -Status: Feedback +Status: Open Type: Feature/Change Request Package: Unknown/Other Function Operating System: Windows x64 PHP Version: 7.4.0alpha2 Assigned To: cmb Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2019-07-22 12:29:29] lisachenko dot it at gmail dot com Unfortunately, recompiling PHP with custom ZEND_FASTCALL doesn't change anything. Nobody will do this for general purposes, so in my opinion, we shouldn't affect overall performance by dropping this call convention, as it is a step back. However I have an interesting idea. What if we could solve this in another way, by defining all internal API functions as ZEND_FASTCALL and removing ZEND_API macros for them, thus they won't be exposed outside. And select some useful methods to work with internal structures with ZEND_API, but without declaring them as ZEND_FASTCALL convention. I can see some conflicts in presence of both ZEND_API and ZEND_FASTCALL. Because in some places the macros ZENA_API is present and in another it is absent, like with ZEND_FASTCALL. ------------------------------------------------------------------------ [2019-07-22 10:56:28] cmb@php.net I don't see a good *general* solution here. Assuming that #define ZEND_FASTCALL __vectorcall yields a more performant binary than #define ZEND_FASTCALL, we would have to sacrifice performance for the supposedly rare case when someone wants to use such functions via FFI. A compromise might be to let the configuration override the definition in zend_portability.h, e.g. something like the attached patch, so it would be possible to do set CFLAGS=/D ZEND_FASTCALL= & configure … Would that be sufficent for you, Alexander, or would you want the official binaries to be built without __vectorcall? ------------------------------------------------------------------------ [2019-07-22 10:56:25] cmb@php.net The following patch has been added/updated: Patch Name: override-zend-fastcall Revision: 1563792985 URL: https://bugs.php.net/patch-display.php?bug=78270&patch=override-zend-fastcall&revision=1563792985 ------------------------------------------------------------------------ [2019-07-21 04:22:04] php-bugs at lists dot php dot net No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. ------------------------------------------------------------------------ [2019-07-11 14:53:28] lisachenko dot it at gmail dot com I've checked the source code of libffi. Zero lines about vectorcall, so unlikely that this convention is supported right now. x32 was typo, there should be "x86" of course. You can start debug this with simple attempt to import zend_atoi function under Windows platform which is declared as following: ZEND_API int ZEND_FASTCALL zend_atoi(const char *str, size_t str_len); Minimal reproduced case: <?php $vectorcallBug = FFI::cdef("extern int zend_atoi(const char *str, size_t str_len);", 'php7.dll'); $vectorcallBug->zend_atoi(); // Good if we can see an exception about invalid argument number But now we can get only this: Fatal error: Uncaught FFI\Exception: Failed resolving C function 'zend_atoi' ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=78270 -- Edit this bug report at https://bugs.php.net/bug.php?id=78270&edit=1

« previous php.bugs (#221892) next »