aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-03-15 18:43:20 +0900
committernsfisis <nsfisis@gmail.com>2024-03-15 18:44:54 +0900
commit0cf8c73ece11e857aefc2c33e531cf81531995de (patch)
treea4d7979fba9bd9ba5d98a40a2cf22015555ae6e2 /examples
parent939dd0ace0e97c17dbf24fd3e22fce0c82127c4a (diff)
downloadphp-waddiwasi-0cf8c73ece11e857aefc2c33e531cf81531995de.tar.gz
php-waddiwasi-0cf8c73ece11e857aefc2c33e531cf81531995de.tar.zst
php-waddiwasi-0cf8c73ece11e857aefc2c33e531cf81531995de.zip
chore: remove debug code
Diffstat (limited to 'examples')
-rw-r--r--examples/php-on-wasm/php-wasm.php14
1 files changed, 0 insertions, 14 deletions
diff --git a/examples/php-on-wasm/php-wasm.php b/examples/php-on-wasm/php-wasm.php
index c82862f..9072bf0 100644
--- a/examples/php-on-wasm/php-wasm.php
+++ b/examples/php-on-wasm/php-wasm.php
@@ -6,7 +6,6 @@ require_once __DIR__ . '/../../vendor/autoload.php';
use Nsfisis\Waddiwasi\BinaryFormat\Decoder;
use Nsfisis\Waddiwasi\BinaryFormat\InvalidBinaryFormatException;
-use Nsfisis\Waddiwasi\Debug\Debug;
use Nsfisis\Waddiwasi\Execution\ExternVal;
use Nsfisis\Waddiwasi\Execution\FuncInst;
use Nsfisis\Waddiwasi\Execution\Refs;
@@ -26,16 +25,13 @@ EOS;
$wasmBinary = file_get_contents(__DIR__ . '/php-wasm.wasm');
\assert($wasmBinary !== false);
-fprintf(STDERR, "Decoding...\n");
try {
$module = (new Decoder($wasmBinary))->decode();
- // Debug::printImports($module);
} catch (InvalidBinaryFormatException $e) {
fprintf(STDERR, $e->getMessage() . "\n");
exit(1);
}
-fprintf(STDERR, "Instantiating...\n");
$hostFuncs = [
makeHostFunc('(i32, i32, i32) -> (i32)', hostFunc__env__invoke_iii(...)),
makeHostFunc('(i32, i32, i32, i32, i32) -> (i32)', hostFunc__env__invoke_iiiii(...)),
@@ -140,19 +136,11 @@ foreach ($hostFuncs as $hostFunc) {
$runtime = Runtime::instantiate($store, $module, $externVals);
$codePtr = allocateStringOnWasmMemory($runtime, PHP_HELLO_WORLD);
-fprintf(STDERR, "Executing...\n");
$results = $runtime->invoke("php_wasm_run", [$codePtr]);
\assert(\count($results) === 1);
$exitCode = $results[0];
\assert(\is_int($exitCode));
-fprintf(STDERR, "Exit code: $exitCode\n");
-fprintf(STDERR, "Memory peak usage: %s\n", memory_get_peak_usage());
-fprintf(STDERR, "\n\n");
-foreach ($runtime->getInstrMetrics() as $instr => [$count, $time]) {
- fprintf(STDERR, "%s: %d %d %f\n", $instr, $time, $count, $time / $count);
-}
-
function allocateStringOnWasmMemory(Runtime $runtime, string $str): int
{
// Plus 1 for the null terminator in C.
@@ -788,8 +776,6 @@ function hostFunc__env____syscall_openat(Runtime $runtime): void
$mode = 0;
}
- // echo "syscall_openat: $path, $flags, $mode\n";
-
// no such file
$runtime->stack->pushValue(-44);
}