diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-11 20:02:34 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-11 20:02:34 +0900 |
| commit | d1c268b76f65e69ea708096d5023c4d731cff594 (patch) | |
| tree | e48836287272388df613a370fda7a46598c517f8 /src/WebAssembly/Execution/Runtime.php | |
| parent | e4324d3d1d3bf3568d4e2f3b80c9cc324d324f83 (diff) | |
| download | php-waddiwasi-d1c268b76f65e69ea708096d5023c4d731cff594.tar.gz php-waddiwasi-d1c268b76f65e69ea708096d5023c4d731cff594.tar.zst php-waddiwasi-d1c268b76f65e69ea708096d5023c4d731cff594.zip | |
fix: various spectests
Diffstat (limited to 'src/WebAssembly/Execution/Runtime.php')
| -rw-r--r-- | src/WebAssembly/Execution/Runtime.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/WebAssembly/Execution/Runtime.php b/src/WebAssembly/Execution/Runtime.php index d0f90b5..07dc0d0 100644 --- a/src/WebAssembly/Execution/Runtime.php +++ b/src/WebAssembly/Execution/Runtime.php @@ -20,6 +20,7 @@ use function abs; use function array_map; use function array_merge; use function array_reverse; +use function array_slice; use function assert; use function ceil; use function count; @@ -114,7 +115,7 @@ final class Runtime $externVals, $vals, $refsList, - $moduleInstInit->funcAddrs, + array_slice($moduleInstInit->funcAddrs, count(array_filter($externVals, fn ($e) => $e instanceof ExternVals\Func))), ); $runtime = new self($store, $stack, $moduleInst); @@ -203,6 +204,9 @@ final class Runtime { try { $export = $this->getExport($name); + if ($export === null) { + throw new TrapException("invoke($name) not found", trapKind: TrapKind::UninitializedElement); + } assert($export instanceof ExternVals\Func); $funcAddr = $export->addr; |
