-
Notifications
You must be signed in to change notification settings - Fork 0
/
wasm-simple.html
35 lines (32 loc) · 1.15 KB
/
wasm-simple.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<html>
<head>
<title>BF WebAssembly simple implementation</title>
<script src="bfCode.js"></script>
<script>
onload = async () => {
const worker = new Worker('./wasm-simple.js');
window.worker = worker; // avoid Safari's bug: https://bugs.webkit.org/show_bug.cgi?id=240062
const startTime = Date.now();
worker.postMessage(bfCode);
worker.onmessage = (e) => {
if (e.data) {
document.getElementsByTagName('pre')[0].textContent += String.fromCharCode(e.data);
} else {
document.getElementsByTagName('span')[0].textContent = `time: ${(Date.now() - startTime) / 1000} sec.`;
worker.terminate();
}
};
};
</script>
</head>
<body>
<h1>BF WebAssembly simple implementation</h1>
Source: <a href="https://github.com/tkihira/dynamic-wasm/blob/main/wasm-simple.wat" target="_blank">https://github.com/tkihira/dynamic-wasm/blob/main/wasm-simple.wat</a>
<hr>
<pre></pre>
<span></span>
<hr>
Go to <a href="./">top</a>.
</body>
</html>