aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-03-04 07:38:45 +0900
committernsfisis <nsfisis@gmail.com>2024-03-04 07:38:58 +0900
commit659447b1abca505b9bce0eeb1fea4ca1162fcb94 (patch)
treec240a1b2fa4ac9b8806e6a2294e540a2c09e4e3b /src
parent8b689c5ff077252a68c88bc7d70990405fc8dd5a (diff)
downloadphp-waddiwasi-659447b1abca505b9bce0eeb1fea4ca1162fcb94.tar.gz
php-waddiwasi-659447b1abca505b9bce0eeb1fea4ca1162fcb94.tar.zst
php-waddiwasi-659447b1abca505b9bce0eeb1fea4ca1162fcb94.zip
Hello, World!
Diffstat (limited to 'src')
-rw-r--r--src/Execution/Runtime.php25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/Execution/Runtime.php b/src/Execution/Runtime.php
index e43a23a..d66e01b 100644
--- a/src/Execution/Runtime.php
+++ b/src/Execution/Runtime.php
@@ -698,9 +698,19 @@ final readonly class Runtime
}
$this->stack->pushI64($trailingZeros);
} elseif ($instr instanceof Instrs\Numeric\I64DivS) {
- throw new \RuntimeException("I64DivS: not implemented");
+ $c2 = $this->stack->popI64();
+ $c1 = $this->stack->popI64();
+ if ($c2 === 0) {
+ throw new TrapException("i64.div_s: divide by zero");
+ }
+ $this->stack->pushI64(intdiv($c1, $c2));
} elseif ($instr instanceof Instrs\Numeric\I64DivU) {
- throw new \RuntimeException("I64DivU: not implemented");
+ $c2 = $this->stack->popI64();
+ $c1 = $this->stack->popI64();
+ if ($c2 === 0) {
+ throw new TrapException("i64.div_u: divide by zero");
+ }
+ $this->stack->pushI64(intdiv($c1, $c2));
} elseif ($instr instanceof Instrs\Numeric\I64Eq) {
$c2 = $this->stack->popI64();
$c1 = $this->stack->popI64();
@@ -800,7 +810,10 @@ final readonly class Runtime
} elseif ($instr instanceof Instrs\Numeric\I64RemU) {
throw new \RuntimeException("I64RemU: not implemented");
} elseif ($instr instanceof Instrs\Numeric\I64RotL) {
- throw new \RuntimeException("I64RotL: not implemented");
+ $i2 = $this->stack->popI64();
+ $i1 = $this->stack->popI64();
+ $k = $i2 % 64;
+ $this->stack->pushI64(($i1 << $k) | ($i1 >> (64 - $k)));
} elseif ($instr instanceof Instrs\Numeric\I64RotR) {
throw new \RuntimeException("I64RotR: not implemented");
} elseif ($instr instanceof Instrs\Numeric\I64Shl) {
@@ -1150,10 +1163,8 @@ final readonly class Runtime
// foreach ($instrs as $instr) {
// echo " " . $instr::opName() . "\n";
// }
- if ($f->debugName === "wasm: 2695") {
- // push dummy
- $this->stack->pushI32(0);
- }
+ // WORKAROUND:
+ $this->stack->pushI32(0);
}
}
$this->deactivateLabel($n);