WebAssembly

1 program Added 2026-02-23T23:57:27Z Agent: claude-codeModel: claude-sonnet-4-6WebSearch: enabled Evidence Report issue View issues
Aliases: Wasm, WAT
Provenance: commit a103213379 · authored 2026-02-24T00:58:00+01:00 · agent claude-code · model claude-sonnet-4-6

Sources mentioning this language

7 sources · pl_id: pl/webassembly
LLM (this repo) · 1LinguistPygmentsWikipediaHyperpolyglotRosettacodeWikidata · Q20155677

Wikipedia infobox

Pulled from the wikimedia/structured-wikipedia snapshot — see data/raw/wikipedia_pl_facts.*.jsonl and pl_fact.csv for the long-table provenance.

Paradigmsstructured · stack machine
Designed byW3C · Mozilla · Microsoft · Google · Apple
First appeared2017
Influenced byasm.js · PNaCl · Lisp
LicenseApache License 2.0
Homepagehttps://webassembly.org/

Extensions claimed by this language

7 claims. Each row is one upstream assertion with its strength. SWH column shows file occurrences with that extension across the entire archive.
ExtensionSourceStrengthSWH
.wasmwikidataprimary460.4K files
.wastlinguistprimary41.1K files
.wastwikidataprimary41.1K files
.watpygmentsprimary189.8K files
.wastpygmentssecondary41.1K files
.watlinguistsecondary189.8K files
.watwikipediaproposed189.8K files

Related languages

WebAssembly Text (0.50)WebAssembly Text Format (0.49)WAT (0.48)MIPS Assembly (0.29)MSP430 Assembly (0.28)

LLM-contributed programs

Recursive Functions: Factorial and Mutual Recursion

Provenance: commit a103213379 · authored 2026-02-24T00:58:00+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch enabled
code.wat · license: Public Domain · added: 2026-02-23T23:57:27Z
;; Examples of recursive functions.
;;
;; factorial: a recursive function that calls itself.
;; is_even and is_odd: mutually recursive functions that call each other.
;;
;; Eli Bendersky [https://eli.thegreenplace.net]
;; This code is in the public domain.
(module
    ;; factorial(n) returns the factorial of n.
    (func $factorial (export "factorial") (param $n i32) (result i32)
        (if (result i32)
            (i32.le_s (local.get $n) (i32.const 1))
            (then (i32.const 1))
            (else
                (i32.mul
                    (local.get $n)
                    (call $factorial (i32.sub (local.get $n) (i32.const 1)))))
        )
    )

    ;; is_odd(n) returns 1 if n is odd, 0 otherwise.
    (func $is_even (export "is_even") (param $n i32) (result i32)
        (if (result i32)
            (i32.eqz (local.get $n))
            (then (i32.const 1))
            (else (call $is_odd (i32.sub (local.get $n) (i32.const 1))))
        )
    )

    ;; is_even(n) returns 1 if n is even, 0 otherwise.
    (func $is_odd (export "is_odd") (param $n i32) (result i32)
        (if (result i32)
            (i32.eqz (local.get $n))
            (then (i32.const 0))
            (else (call $is_even (i32.sub (local.get $n) (i32.const 1))))
        )
    )
)

Real programs from Software Heritage

3 samples mined from derived_datasets/<date>/contents/*.parquet, byte-verified against the SWH archive. Citation-grade qualified SWHIDs preserved.
fac-multi-value.wat · 3005 B · ext .wat · seen 120× in SWH
via fallback
swh:1:cnt:d39353d8fae1f25692c551ff6c50a9416dee3c0e;origin=https://github.com/Lind-Project/lind-wasm;anchor=swh:1:rev:5be4c7e80c3ee5d5092e34edf4852f1d21893d24;path=/src/wasmtime/tests/disas/fac-multi-value.wat
Open in SWH · Raw bytes (SWH) · GitHub raw
Show source
;;! target = "x86_64"

(module
  ;; Iterative factorial without locals.
  (func $pick0 (param i64) (result i64 i64)
    (local.get 0) (local.get 0)
  )
  (func $pick1 (param i64 i64) (result i64 i64 i64)
    (local.get 0) (local.get 1) (local.get 0)
  )
  (func (export "fac-ssa") (param i64) (result i64)
    (i64.const 1) (local.get 0)
    (loop $l (param i64 i64) (result i64)
      (call $pick1) (call $pick1) (i64.mul)
      (call $pick1) (i64.const 1) (i64.sub)
      (call $pick0) (i64.const 0) (i64.gt_u)
      (br_if $l)
      (drop) (return)
    )
  )
)

;; function u0:0(i64 vmctx, i64, i64) -> i64, i64 tail {
;;     gv0 = vmctx
;;     gv1 = load.i64 notrap aligned readonly gv0+8
;;     gv2 = load.i64 notrap aligned gv1
;;     stack_limit = gv2
;;
;;                                 block0(v0: i64, v1: i64, v2: i64):
;; @0040                               jump block1(v2, v2)
;;
;;                                 block1(v3: i64, v4: i64):
;; @0040                               return v3, v4
;; }
;;
;; function u0:1(i64 vmctx, i64, i64, i64) -> i64, i64, i64 tail {
;;     gv0 = vmctx
;;     gv1 = load.i64 notrap aligned readonly gv0+8
;;     gv2 = load.i64 notrap aligned gv1
;;     stack_limit = gv2
;;
;;                                 block0(v0: i64, v1: i64, v2: i64, v3: i64):
;; @0049                               jump block1(v2, v3, v2)
;;
;;                                 block1(v4: i64, v5: i64, v6: i64):
;; @0049                               return v4, v5, v6
;; }
;;
;; function u0:2(i64 vmctx, i64, i64) -> i64 tail {
;;     gv0 = vmctx
;;     gv1 = load.i64 notrap aligned readonly gv0+8
;;     gv2 = load.i64 notrap aligned gv1
;;     sig0 = (i64 vmctx, i64, i64, i64) -> i64, i64, i64 tail
;;     sig1 = (i64 vmctx, i64, i64) -> i64, i64 tail
;;     fn0 = colocated u0:1 sig0
;;     fn1 = colocated u0:0 sig1
;;     stack_limit = gv2
;;
;;                                 block0(v0: i64, v1: i64, v2: i64):
;; @004c                               v4 = iconst.i64 1
;; @0050                               jump block2(v4, v2)  ; v4 = 1
;;
;;                                 block2(v5: i64, v6: i64):
;; @0052                               v8, v9, v10 = call fn0(v0, v0, v5, v6)
;; @0054                               v11, v12, v13 = call fn0(v0, v0, v9, v10)
;; @0056                               v14 = imul v12, v13
;; @0057                               v15, v16, v17 = call fn0(v0, v0, v11, v14)
;; @0059                               v18 = iconst.i64 1
;; @005b                               v19 = isub v17, v18  ; v18 = 1
;; @005c                               v20, v21 = call fn1(v0, v0, v19)
;; @005e                               v22 = iconst.i64 0
;; @0060                               v23 = icmp ugt v21, v22  ; v22 = 0
;; @0060                               v24 = uextend.i32 v23
;; @0061                               brif v24, block2(v16, v20), block4
;;
;;                                 block4:
;; @0064                               return v16
;; }
multi-11.wat · 720 B · ext .wat · seen 120× in SWH
via fallback
swh:1:cnt:053e745d27b0e435d81d9de06db5311594dd65b0;origin=https://github.com/Lind-Project/lind-wasm;anchor=swh:1:rev:5be4c7e80c3ee5d5092e34edf4852f1d21893d24;path=/src/wasmtime/tests/disas/multi-11.wat
Open in SWH · Raw bytes (SWH) · GitHub raw
Show source
;;! target = "x86_64"

(module
  (func (export "multiLoop") (param i64) (result i64 i64)
    (local.get 0)
    ;; Fewer params than results.
    (loop (param i64) (result i64 i64)
      i64.const 42
      return)))

;; function u0:0(i64 vmctx, i64, i64) -> i64, i64 tail {
;;     gv0 = vmctx
;;     gv1 = load.i64 notrap aligned readonly gv0+8
;;     gv2 = load.i64 notrap aligned gv1
;;     stack_limit = gv2
;;
;;                                 block0(v0: i64, v1: i64, v2: i64):
;; @002b                               jump block2(v2)
;;
;;                                 block2(v5: i64):
;; @002d                               v8 = iconst.i64 42
;; @002f                               return v5, v8  ; v8 = 42
;; }
return-int32.wast · 1269 B · ext .wast · seen 1× in SWH
via unique-primary
swh:1:cnt:bca1fd03b460feee90314f9d6c9f56cdeef50fe7;origin=https://github.com/johalun/rustkpi;anchor=swh:1:rev:dd2950397b0d12fdffe1a5692f65fe2c2e769e51;path=/rust/rust-src-1.25.0/src/binaryen/test/llvm_autogenerated/return-int32.wast
Open in SWH · Raw bytes (SWH) · GitHub raw
Show source
(module
 (import "env" "memory" (memory $0 1))
 (table 0 anyfunc)
 (data (i32.const 4) "\10\04\00\00")
 (export "return_i32" (func $return_i32))
 (export "return_i32_twice" (func $return_i32_twice))
 (export "stackSave" (func $stackSave))
 (export "stackAlloc" (func $stackAlloc))
 (export "stackRestore" (func $stackRestore))
 (func $return_i32 (; 0 ;) (param $0 i32) (result i32)
  (get_local $0)
 )
 (func $return_i32_twice (; 1 ;) (param $0 i32) (result i32)
  (block $label$0
   (br_if $label$0
    (i32.eqz
     (get_local $0)
    )
   )
   (i32.store
    (i32.const 0)
    (i32.const 0)
   )
   (return
    (i32.const 1)
   )
  )
  (i32.store
   (i32.const 0)
   (i32.const 2)
  )
  (i32.const 3)
 )
 (func $stackSave (; 2 ;) (result i32)
  (i32.load offset=4
   (i32.const 0)
  )
 )
 (func $stackAlloc (; 3 ;) (param $0 i32) (result i32)
  (local $1 i32)
  (set_local $1
   (i32.load offset=4
    (i32.const 0)
   )
  )
  (i32.store offset=4
   (i32.const 0)
   (i32.and
    (i32.sub
     (get_local $1)
     (get_local $0)
    )
    (i32.const -16)
   )
  )
  (get_local $1)
 )
 (func $stackRestore (; 4 ;) (param $0 i32)
  (i32.store offset=4
   (i32.const 0)
   (get_local $0)
  )
 )
)
;; METADATA: { "asmConsts": {},"staticBump": 1040, "initializers": [] }

Contribute — propose a file extension

Tell us where to find evidence about WebAssembly (mapped to pl/webassembly). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/WebAssembly/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← web3js WebAssembly Interface Type →