aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/WebAssembly/Execution/Allocator.php
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-07-11 20:02:34 +0900
committernsfisis <nsfisis@gmail.com>2024-07-11 20:02:34 +0900
commitd1c268b76f65e69ea708096d5023c4d731cff594 (patch)
treee48836287272388df613a370fda7a46598c517f8 /src/WebAssembly/Execution/Allocator.php
parente4324d3d1d3bf3568d4e2f3b80c9cc324d324f83 (diff)
downloadphp-waddiwasi-d1c268b76f65e69ea708096d5023c4d731cff594.tar.gz
php-waddiwasi-d1c268b76f65e69ea708096d5023c4d731cff594.tar.zst
php-waddiwasi-d1c268b76f65e69ea708096d5023c4d731cff594.zip
fix: various spectests
Diffstat (limited to 'src/WebAssembly/Execution/Allocator.php')
-rw-r--r--src/WebAssembly/Execution/Allocator.php18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/WebAssembly/Execution/Allocator.php b/src/WebAssembly/Execution/Allocator.php
index 4e2adbf..79f8679 100644
--- a/src/WebAssembly/Execution/Allocator.php
+++ b/src/WebAssembly/Execution/Allocator.php
@@ -12,6 +12,7 @@ use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\MemType;
use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\TableType;
use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\ValType;
use RuntimeException;
+use function assert;
use function count;
final readonly class Allocator
@@ -61,7 +62,7 @@ final readonly class Allocator
foreach ($externVals as $externVal) {
match ($externVal::class) {
- ExternVals\Func::class => null, // handled below.
+ ExternVals\Func::class => $m->funcAddrs[] = $externVal->addr,
ExternVals\Table::class => $m->tableAddrs[] = $externVal->addr,
ExternVals\Mem::class => $m->memAddrs[] = $externVal->addr,
ExternVals\Global_::class => $m->globalAddrs[] = $externVal->addr,
@@ -72,14 +73,13 @@ final readonly class Allocator
foreach ($preAllocatedFuncs as $funcAddr) {
$m->funcAddrs[] = $funcAddr;
$funcInst = $this->store->funcs[$funcAddr];
- if ($funcInst instanceof FuncInsts\Wasm) {
- // @phpstan-ignore-next-line
- $this->store->funcs[$funcAddr] = FuncInst::Wasm(
- $funcInst->type,
- $m,
- $funcInst->code,
- );
- }
+ assert($funcInst instanceof FuncInsts\Wasm);
+ // @phpstan-ignore-next-line
+ $this->store->funcs[$funcAddr] = FuncInst::Wasm(
+ $funcInst->type,
+ $m,
+ $funcInst->code,
+ );
}
foreach ($module->tables as $table) {
$m->tableAddrs[] = $this->allocTable($table->type, Ref::RefNull($table->type->refType));