Explorer

core.wasm-runtime-string-hash

description
Runtime function 33 of the definy compiler: string_hash(value) -> i32: the 32-bit hash h = h * 33 + byte (from h = 0, wrapping) of the UTF-8 bytes of a string, 0 for a value that is not a string. Used by list_hash_index and list_hash_index_find (core.eval-value-hash computes the same in the evaluator). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
type
List<Number>
expression
[
  2,
  1,
  @wasm.value-type-ref-null,
  @core.wasm-type-bytes,
  3,
  @wasm.value-type-i32,
  @wasm.local-get,
  0,
  @wasm.gc-prefix,
  @wasm.struct-get,
  @core.wasm-type-value,
  0,
  @wasm.i32-const,
  2,
  @wasm.i32-ne,
  @wasm.if,
  @wasm.block-type-empty,
  @wasm.i32-const,
  0,
  @wasm.return,
  @wasm.end,
  @wasm.local-get,
  0,
  @wasm.gc-prefix,
  @wasm.ref-cast,
  @core.wasm-type-string,
  @wasm.gc-prefix,
  @wasm.struct-get,
  @core.wasm-type-string,
  1,
  @wasm.local-tee,
  1,
  @wasm.gc-prefix,
  @wasm.array-len,
  @wasm.local-set,
  4,
  @wasm.block,
  @wasm.block-type-empty,
  @wasm.loop,
  @wasm.block-type-empty,
  @wasm.local-get,
  3,
  @wasm.local-get,
  4,
  @wasm.i32-ge-u,
  @wasm.br-if,
  1,
  @wasm.local-get,
  2,
  @wasm.i32-const,
  5,
  @wasm.i32-shl,
  @wasm.local-get,
  2,
  @wasm.i32-add,
  @wasm.local-get,
  1,
  @wasm.local-get,
  3,
  @wasm.gc-prefix,
  @wasm.array-get-u,
  @core.wasm-type-bytes,
  @wasm.i32-add,
  @wasm.local-set,
  2,
  @wasm.local-get,
  3,
  @wasm.i32-const,
  1,
  @wasm.i32-add,
  @wasm.local-set,
  3,
  @wasm.br,
  0,
  @wasm.end,
  @wasm.end,
  @wasm.local-get,
  2,
  @wasm.end
]
visibility
public
core.wasm-runtime-string-hash (project definy, branch main, snapshot CfIAXM725tR74SWd4aoTUz4-JJQfqnllblZbQ2Sv204)
id: iz7Z0_g1_KZLXh41MGYGUiRanesICwvVNAn_B3yVcrk
content hash: IviVvyPLR7R7Q6EZ2Vq4effGyRFIE5WVbZR5il350c8