From 378a315f15a26158885d4e1b14cb97cf04676ba9 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 7 Jul 2024 12:54:36 +0900 Subject: chore: update README --- README.md | 11 ++++++++--- composer.json | 2 ++ examples/rubyvm-on-php-on-wasm/HelloWorld.sh | 1 - examples/rubyvm-on-php-on-wasm/php-wasm.php | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) delete mode 100755 examples/rubyvm-on-php-on-wasm/HelloWorld.sh diff --git a/README.md b/README.md index 891a6a1..2701439 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ It is partially compatible with the WebAssembly specification version 2.0. The PHP runtime can be compiled to WebAssembly binary. This Wasm runtime can execute it. Currently, "Hello, World!" program works on the PHP runtime on the Wasm runtime. ``` -$ php -d zend.assertions=-1 -d memory_limit=512M -d opcache.enable_cli=on -d opcache.jit=on -d opcache.jit_buffer_size=1G examples/php-on-wasm/php-wasm.php +$ composer example:php-on-wasm ``` ### RubyVM on PHP on Wasm @@ -23,8 +23,7 @@ https://github.com/m3m0r7/rubyvm-on-php is a RubyVM written in pure PHP. It works on the PHP runtime on my Wasm runtime. ``` -$ cd examples/rubyvm-on-php-on-wasm -$ ./HelloWorld.sh +$ composer example:rubyvm-on-php-on-wasm ``` NOTE: there is a known bug where `munmap()`-related errors are reported. @@ -37,6 +36,12 @@ NOTE: there is a known bug where `munmap()`-related errors are reported. +## Known Bugs + +See [BUGS.txt](./BUGS.txt). + + + ## License See [LICENSE](./LICENSE). diff --git a/composer.json b/composer.json index 86e23eb..f4defbd 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,8 @@ ], "ecs": "ecs check", "ecsfix": "ecs --memory-limit=1G check --fix", + "example:php-on-wasm": "@php -d memory_limit=512M -d opcache.enable_cli=on -d opcache.jit=on -d opcache.jit_buffer_size=1G examples/php-on-wasm/php-wasm.php", + "example:rubyvm-on-php-on-wasm": "@php -d memory_limit=-1 -d opcache.enable_cli=on -d opcache.jit=on -d opcache.jit_buffer_size=1G examples/rubyvm-on-php-on-wasm/php-wasm.php", "lint": [ "@ecs", "@phpstan" diff --git a/examples/rubyvm-on-php-on-wasm/HelloWorld.sh b/examples/rubyvm-on-php-on-wasm/HelloWorld.sh deleted file mode 100755 index c5fc8ae..0000000 --- a/examples/rubyvm-on-php-on-wasm/HelloWorld.sh +++ /dev/null @@ -1 +0,0 @@ -php -d memory_limit=-1 -d opcache.enable_cli=on -d opcache.jit=on -d opcache.jit_buffer_size=1G ./php-wasm.php diff --git a/examples/rubyvm-on-php-on-wasm/php-wasm.php b/examples/rubyvm-on-php-on-wasm/php-wasm.php index beb854f..704254f 100644 --- a/examples/rubyvm-on-php-on-wasm/php-wasm.php +++ b/examples/rubyvm-on-php-on-wasm/php-wasm.php @@ -20,7 +20,7 @@ use Nsfisis\Waddiwasi\Structure\Types\ValType; const PHP_EMPTY = ''; const PHP_HELLO_WORLD = <<<'EOS' -require_once __DIR__ . '/HelloWorld.php'; +require_once '%DIR%/HelloWorld.php'; EOS; $wasmBinary = file_get_contents(__DIR__ . '/php-wasm.wasm'); @@ -135,7 +135,7 @@ foreach ($hostFuncs as $hostFunc) { $externVals[] = ExternVal::Func(\count($store->funcs) - 1); } $runtime = Runtime::instantiate($store, $module, $externVals); -$codePtr = allocateStringOnWasmMemory($runtime, PHP_HELLO_WORLD); +$codePtr = allocateStringOnWasmMemory($runtime, strtr(PHP_HELLO_WORLD, ['%DIR%' => __DIR__])); $results = $runtime->invoke("php_wasm_run", [$codePtr]); \assert(\count($results) === 1); -- cgit v1.2.3-70-g09d2