aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/WebAssembly
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-04-06 02:19:44 +0900
committernsfisis <nsfisis@gmail.com>2025-04-06 02:19:44 +0900
commitde116dceae7ea654df28caab3fd2f3aefdffe188 (patch)
tree95a81c0909e761e9cecb3cd7333201cb4ac62161 /src/WebAssembly
parentb47f6c38389762aff3b1b86c179517d3e9d9eb87 (diff)
downloadphp-waddiwasi-de116dceae7ea654df28caab3fd2f3aefdffe188.tar.gz
php-waddiwasi-de116dceae7ea654df28caab3fd2f3aefdffe188.tar.zst
php-waddiwasi-de116dceae7ea654df28caab3fd2f3aefdffe188.zip
fix: pass FloatMemoryTest
Diffstat (limited to 'src/WebAssembly')
-rw-r--r--src/WebAssembly/Execution/MemInst.php29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/WebAssembly/Execution/MemInst.php b/src/WebAssembly/Execution/MemInst.php
index 94d57cf..9ced0a3 100644
--- a/src/WebAssembly/Execution/MemInst.php
+++ b/src/WebAssembly/Execution/MemInst.php
@@ -44,11 +44,6 @@ final class MemInst
private CData $dataS64_6;
private CData $dataS64_7;
- private CData $dataF32_0;
- private CData $dataF32_1;
- private CData $dataF32_2;
- private CData $dataF32_3;
-
private CData $dataF64_0;
private CData $dataF64_1;
private CData $dataF64_2;
@@ -155,11 +150,6 @@ final class MemInst
$this->dataS64_6 = $castInt(64, true, 6);
$this->dataS64_7 = $castInt(64, true, 7);
- $this->dataF32_0 = $castFloat(32, 0);
- $this->dataF32_1 = $castFloat(32, 1);
- $this->dataF32_2 = $castFloat(32, 2);
- $this->dataF32_3 = $castFloat(32, 3);
-
$this->dataF64_0 = $castFloat(64, 0);
$this->dataF64_1 = $castFloat(64, 1);
$this->dataF64_2 = $castFloat(64, 2);
@@ -380,7 +370,10 @@ final class MemInst
if ($this->size() < $ptr + 4) {
return null;
}
- return $this->dataF32($ptr)[$ptr >> 2];
+ // f32 cannot be loaded directly from memory because PHP handles NaN
+ // differently than WebAssembly spec defines.
+ $i = $this->dataU32($ptr)[$ptr >> 2];
+ return NumericOps::f32ReinterpretI32($i);
}
/**
@@ -517,7 +510,9 @@ final class MemInst
if ($this->size() < $ptr + 4) {
return false;
}
- $this->dataF32($ptr)[$ptr >> 2] = $c;
+ // f32 cannot be stored directly in memory because PHP handles NaN
+ // differently than WebAssembly spec defines.
+ $this->dataU32($ptr)[$ptr >> 2] = NumericOps::i32ReinterpretF32($c);
return true;
}
@@ -578,16 +573,6 @@ final class MemInst
};
}
- private function dataF32(int $ptr): CData
- {
- return match ($ptr & 3) {
- 0 => $this->dataF32_0,
- 1 => $this->dataF32_1,
- 2 => $this->dataF32_2,
- 3 => $this->dataF32_3,
- };
- }
-
private function dataF64(int $ptr): CData
{
return match ($ptr & 7) {