Re: PHP FFI extenesion
| From: | Dmitry Stogov | Date: | Fri, 27 Apr 2018 13:47:44 +0000 |
| Subject: | Re: PHP FFI extenesion | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-102084@lists.php.net to get a copy of this message | ||
Pre-loading of *.h files is fully functional now. See tests/300.phpt
________________________________
From: Dmitry Stogov <dmitry@zend.com>
Sent: Friday, April 27, 2018 1:29:48 AM
To: Michael Wallner
Cc: Stanislav Malyshev; Zeev Suraski; Xinchen Hui; Nikita Popov; Bob Weinand; Anatol Belski
(ab@php.net); PHP internals list
Subject: Re: [PHP-DEV] PHP FFI extenesion
Hi Michael,
I've, also, tried to implement FFI definition pre-loading (currently just H files).
I spent just two hours and implementation misses a lot of details, but it looks like this may work
with FFI extension almost out of the box.
https://github.com/dstogov/php-ffi/commit/75cdae7a26406ae75ee27317ddb1981774a81006
Thanks. Dmitry.
________________________________
From: Michael Wallner <mike.php.net@gmail.com> on behalf of Michael Wallner
<mike@php.net>
Sent: Thursday, April 26, 2018 10:30:38 PM
To: Dmitry Stogov
Cc: Stanislav Malyshev; Zeev Suraski; Xinchen Hui; Nikita Popov; Bob Weinand; Anatol Belski
(ab@php.net); PHP internals list
Subject: Re: [PHP-DEV] PHP FFI extenesion
Hey!
> On 26 04 2018, at 20:47, Dmitry Stogov <dmitry@zend.com> wrote:
>
> Hi Michael,
>
>
> I've just tried to run PSI with php-master (32-bit DEBUG build) and got SIGSEGV on the
> simplest test.
>
> Use "psi.d/string.psi" and attemt to call psi\strerror(10)
>
>
> #0 0xf44916ba in psi_call_frame_parse_args (frame=0xf426c500, execute_data=0x0) at
> /home/dmitry/php/ext-psi/src/call.c:273
> #1 0xf4494fe7 in psi_context_call (C=0x92dfe90, execute_data=0x0, return_value=0x8fc0144
> <HARDCODED_INI+4>, impl=0x9341658)
> at /home/dmitry/php/ext-psi/src/context.c:250
> #2 0xf4499b44 in psi_ffi_handler (sig=0x92e0fa0, result=0xffff9760, args=0xffff96f0,
> data=0x9341658)
> at /home/dmitry/php/ext-psi/src/libffi.c:387
> #3 0xf4467a76 in ffi_closure_SYSV_inner () from /lib/libffi.so.6
> #4 0xf4467eb6 in ffi_closure_SYSV () from /lib/libffi.so.6
> #5 0x08701d21 in ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER () at
> /home/dmitry/php/php-master/Zend/zend_vm_execute.h:890
> #6 0x0875fd12 in execute_ex (ex=0xf421d020) at
> /home/dmitry/php/php-master/Zend/zend_vm_execute.h:54819
> #7 0x087643b1 in zend_execute (op_array=0xf426c460, return_value=0x0) at
> /home/dmitry/php/php-master/Zend/zend_vm_execute.h:59987
> #8 0x086b0d2f in zend_execute_scripts (type=8, retval=0x0, file_count=3) at
> /home/dmitry/php/php-master/Zend/zend.c:1566
> #9 0x0863cdde in php_execute_script (primary_file=0xffffcbbc) at
> /home/dmitry/php/php-master/main/main.c:2467
> #10 0x0876676a in do_cli (argc=2, argv=0x90e4850) at
> /home/dmitry/php/php-master/sapi/cli/php_cli.c:1011
> #11 0x087673b2 in main (argc=2, argv=0x90e4850) at
> /home/dmitry/php/php-master/sapi/cli/php_cli.c:1404
>
> execute_data is NULL
>
>
> Did you test ext-psi with php-master?
>
I only test on master, but never tested 32bit :-/
https://travis-ci.org/m6w6/ext-psi/jobs/368760446#L2102
>
> As I understood, you create libffi callback/closure for each function declared in *.psi
> file(s).
>
> And then use it to call a general psi_ffi_handler().
>
> Why not to call a general function handler in first place (without any ffi magic)?
>
Let me think about that. It’s my first with libffi/libjit, so maybe I was thinking too complicated
and took more corners than I had to…
Thanks,
Mike