Skip to content

Commit 550a3a9

Browse files
committed
Wasm runtime: move JavaString hash function from wasm:js-string to bindings
For compatibility with Firefox which does not allow additional functions in builtin modules.
1 parent 1da259e commit 550a3a9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

runtime/wasm/jsstring.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
(func $compare_strings (param externref externref) (result i32)))
2121
(import "wasm:js-string" "test"
2222
(func $is_string (param externref) (result i32)))
23-
(import "wasm:js-string" "hash"
24-
(func $hash_string (param i32) (param anyref) (result i32)))
2523
(import "wasm:js-string" "fromCharCodeArray"
2624
(func $fromCharCodeArray
2725
(param (ref null $wstring)) (param i32) (param i32)
@@ -35,6 +33,8 @@
3533
(func $encodeStringToUTF8Array
3634
(param externref) (result (ref $bytes))))
3735

36+
(import "bindings" "hash_string"
37+
(func $hash_string (param i32) (param anyref) (result i32)))
3838
(import "bindings" "read_string"
3939
(func $read_string (param i32) (result anyref)))
4040
(import "bindings" "read_string_stream"

runtime/wasm/runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,12 @@
569569
},
570570
map_set: (m, x, v) => m.set(x, v),
571571
map_delete: (m, x) => m.delete(x),
572+
hash_string,
572573
log: (x) => console.log(x),
573574
};
574575
const string_ops = {
575576
test: (v) => +(typeof v === "string"),
576577
compare: (s1, s2) => (s1 < s2 ? -1 : +(s1 > s2)),
577-
hash: hash_string,
578578
decodeStringFromUTF8Array: () => "",
579579
encodeStringToUTF8Array: () => 0,
580580
fromCharCodeArray: () => "",

0 commit comments

Comments
 (0)