On Sat, Sep 21, 2024, 3:41 AM Dennis Snell <dennis.sn...@automattic.com>
wrote:

>
> On Sep 20, 2024, at 1:21 PM, Jakub Zelenka <bu...@php.net> wrote:
>
> Hi,
>
> On Fri, Sep 20, 2024 at 6:32 PM Dennis Snell <dennis.sn...@automattic.com>
> wrote:
>
>>
>> My goal in sharing here is to help better represent my own perspective of
>> WordPress’ needs based on what I’ve seen. It’s long been on my list to
>> propose a WASM RFC, but because I personally haven’t had the priority
>> available to get an implementation working I haven’t done so. It’s my
>> impression from the documentation that the purpose of these email threads
>> w.r.t. RFCs is to gather interest and input before any RFC would be put
>> together, to hold these discussions before anyone commits any major time to
>> it.
>>
>
> Is your objective to support building PHP to wasm32-wasi target like it
> was proposed here: https://github.com/php/php-src/pull/10457? If so, the
> main issue with that was inability to do the zend_bailout as wasm does not
> support currently support setjmp and longjmp. Otherwise it's mostly about
> disabling some functionality.
>
>
> It’s the other way around. We’ve been having a great time already building
> PHP as a WASM binary - we package it with SQLite and WordPress to create
> “The WordPress Playground.” There’s a wonderful new world of things that
> can happen when packaging PHP inside a WASM runtime.
>
> However, this is about calling compiled WebAssembly code from user-space
> PHP.
>
>     load_wasm( __DIR__ . ‘/interesting-computation.wasm’ );
>     $description = null;
>     call_wasm_func( ‘lazy_json_decode’, $json, ‘items[0].description’,
> $description );
>

this is a very important target which is not directly discussed in this
thread.

I played with the (very good) IR when it was submitted by Dmitry back then.
It sounded like the most effective way.

However it was not designed (nothing  bad with that) with such goals in
mind. I was hoping it could be used like any other IR (similar to what llvm
does f.e.) to then target wasm. The closest one from php is python with
py2wasm, but there are pretty existing solutions that make it possible,
they use the out of python core approach:

https://wasmer.io/posts/py2wasm-a-python-to-wasm-compiler

which looks very much like what could be done with php as I see the chances
to have that in php as very low without major changes.

best,
Pierre

It may be possible but the time required to figure it out is not something
I have sadly (falling back to porting our php code to other when we need it
to be used in many environments where putting a php is not an option).

As of now, I feel like writing a parser-compiler may be easier, even with
limited features. But ideally the way could be to allow it the same way we
can see it in other languages, but the paradigms used are very different.

All in all, it is not absolutely vital for php to have this but it will
help to keep it on for the next 2 decades. Similarly to other discussions
lately about new types.

best,
Pierre

>

Reply via email to