diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-05-19 11:53:12 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-05-19 11:53:12 +0900 |
| commit | 7cec89f22a9a09916f1b9c98fc117ec4a1ea7793 (patch) | |
| tree | 4282bbd899efb977680545c4b68ad6f8ddf68165 /src | |
| parent | 07b375c2c5ae968735f2390b523dbcc088b03ee5 (diff) | |
| download | php-waddiwasi-7cec89f22a9a09916f1b9c98fc117ec4a1ea7793.tar.gz php-waddiwasi-7cec89f22a9a09916f1b9c98fc117ec4a1ea7793.tar.zst php-waddiwasi-7cec89f22a9a09916f1b9c98fc117ec4a1ea7793.zip | |
fix: iNN.reinterpret_fMM
Diffstat (limited to 'src')
| -rw-r--r-- | src/Execution/Runtime.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/Execution/Runtime.php b/src/Execution/Runtime.php index 9987118..8944ff1 100644 --- a/src/Execution/Runtime.php +++ b/src/Execution/Runtime.php @@ -1093,13 +1093,19 @@ final class Runtime private function execInstrNumericI32ReinterpretF32(Instrs\Numeric\I32ReinterpretF32 $instr): void { $v = $this->stack->popFloat(); - $this->stack->pushValue($v); + $result = unpack('l', pack('f', $v)); + assert($result !== false); + $vAsI32 = $result[1]; + $this->stack->pushValue($vAsI32); } private function execInstrNumericI32ReinterpretF64(Instrs\Numeric\I32ReinterpretF64 $instr): void { $v = $this->stack->popFloat(); - $this->stack->pushValue($v); + $result = unpack('q', pack('d', $v)); + assert($result !== false); + $vAsI64 = $result[1]; + $this->stack->pushValue(self::phpIntToWasmI32($vAsI64 & 0xFFFFFFFF)); } private function execInstrNumericI32RemS(Instrs\Numeric\I32RemS $instr): void @@ -1505,13 +1511,19 @@ final class Runtime private function execInstrNumericI64ReinterpretF32(Instrs\Numeric\I64ReinterpretF32 $instr): void { $v = $this->stack->popFloat(); - $this->stack->pushValue($v); + $result = unpack('q', pack('f', $v)); + assert($result !== false); + $vAsI64 = $result[1]; + $this->stack->pushValue($vAsI64); } private function execInstrNumericI64ReinterpretF64(Instrs\Numeric\I64ReinterpretF64 $instr): void { $v = $this->stack->popFloat(); - $this->stack->pushValue($v); + $result = unpack('q', pack('d', $v)); + assert($result !== false); + $vAsI64 = $result[1]; + $this->stack->pushValue($vAsI64); } private function execInstrNumericI64RemS(Instrs\Numeric\I64RemS $instr): void |
