Truly independent web browser
<!doctype html>
<script src="../include.js"></script>
<script>
// Each call from JavaScript enters WebAssembly anew, which once read /proc/self/maps every time and made this test
// time out.
// (module (func (export "f") (param i32) (result i32) (local.get 0)))
const bytes = new Uint8Array([
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x60, 0x01, 0x7f, 0x01, 0x7f,
0x03, 0x02, 0x01, 0x00, 0x07, 0x05, 0x01, 0x01, 0x66, 0x00, 0x00, 0x0a, 0x06, 0x01, 0x04, 0x00,
0x20, 0x00, 0x0b,
]);
test(() => {
const f = new WebAssembly.Instance(new WebAssembly.Module(bytes)).exports.f;
let sum = 0;
for (let i = 0; i < 200000; ++i)
sum += f(i);
println(`sum: ${sum}`);
});
</script>