Skip to content

Commit 4d9f314

Browse files
committed
Simplify wasm
1 parent f2b69a8 commit 4d9f314

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

dist/lib/sha256-load.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/sha256.wast

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,23 @@
4343
(i32.add (get_local $byteLength) (i32.const 63)) ;; could use up to 63 extra bytes
4444
)
4545
)
46-
(set_local $needed ;; needed = (needed >> 16) + (needed % (1 << 16) ? 1 : 0) - memory.size
47-
(i32.sub
48-
(i32.add
49-
(i32.shr_u (get_local $needed) (i32.const 16))
50-
(select
51-
(i32.const 1)
52-
(i32.const 0)
53-
(i32.and (get_local $needed) (i32.const 0xffff))
46+
(if ;; if (needed > 0) memory.grow(needed)
47+
(i32.gt_s
48+
(tee_local $needed ;; needed = (needed >> 16) + (needed % (1 << 16) ? 1 : 0) - memory.size
49+
(i32.sub
50+
(i32.add
51+
(i32.shr_u (get_local $needed) (i32.const 16))
52+
(select
53+
(i32.const 1)
54+
(i32.const 0)
55+
(i32.and (get_local $needed) (i32.const 0xffff))
56+
)
57+
)
58+
(current_memory)
5459
)
5560
)
56-
(current_memory)
61+
(i32.const 0)
5762
)
58-
)
59-
(if (i32.gt_s (get_local $needed) (i32.const 0)) ;; if (needed > 0) memory.grow(needed)
6063
(drop (grow_memory (get_local $needed)))
6164
)
6265
)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"test": "test"
2727
},
2828
"scripts": {
29-
"wabt": "bash -c '[[ -d wabt ]]' || (git clone --recursive https://github.com/WebAssembly/wabt && cd wabt && make gcc-release)",
29+
"wabt": "bash -c '[[ -d wabt ]]' || (git clone --depth 1 https://github.com/WebAssembly/wabt && cd wabt && make gcc-release-no-tests)",
3030
"wat2wasm": "npm run wabt && wabt/bin/wat2wasm lib/sha256.wast -o lib/sha256.wasm && ./wasm2ts.js lib/sha256",
3131
"build": "npm run wat2wasm && rm -rf dist && tsc",
3232
"build-client": "rm -rf compiled && webpack",

0 commit comments

Comments
 (0)