aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUGS4
-rw-r--r--TODO1
-rw-r--r--phpunit.xml1
-rw-r--r--src/WebAssembly/Execution/MemInst.php29
4 files changed, 8 insertions, 27 deletions
diff --git a/BUGS b/BUGS
index 042151c..3e88d14 100644
--- a/BUGS
+++ b/BUGS
@@ -1,9 +1,5 @@
# Failed spec tests
-## Numeric
-
-* FloatMemoryTest
-
## Validation
* ImportsTest
diff --git a/TODO b/TODO
index a361e26..171eb28 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,6 @@
* Support text format (.wat)
* Implement validation
* Fix known bugs (BUGS)
-* Implement NaN propagation
* Provide sane bindings to PHP
* Write PHPDoc for public APIs
* Provide high-level APIs
diff --git a/phpunit.xml b/phpunit.xml
index 02e668c..a6c6ac1 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -42,6 +42,7 @@
<file>tests/src/SpecTestsuites/Core/FacTest.php</file>
<file>tests/src/SpecTestsuites/Core/FloatExprsTest.php</file>
<file>tests/src/SpecTestsuites/Core/FloatLiteralsTest.php</file>
+ <file>tests/src/SpecTestsuites/Core/FloatMemoryTest.php</file>
<file>tests/src/SpecTestsuites/Core/FloatMiscTest.php</file>
<file>tests/src/SpecTestsuites/Core/ForwardTest.php</file>
<file>tests/src/SpecTestsuites/Core/FuncPtrsTest.php</file>
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) {