deflate.bend relies on unsafe/foreign
raw source on the hub · import gralha-deflate@0.1.0.1/deflate.bend as Deflate
gralha-deflate: RFC 1951 DEFLATE over gralha-byte-words packed arrays. inflate decodes a raw stream into an exactly sized output; compress encodes with LZ77 and dynamic Huffman blocks (levels 1-9, 0 stores), splitting the input into 248 KiB chunks that compress in parallel and concatenate into one stream. write_parts writes the chunks in order.
2 imports
import Base import gralha-byte-words@0.1.0.0/words.bend as Words
Types
type Br source · line 27 · raw
Type
Br@a:Array<U32> -> @pos:U32 -> @n:U32 -> @buf:U32 -> @cnt:U32 -> Br
type Bf source · line 31 · raw
Type
the refill: need says the buffer is still short of kk bits
Bf@a:Array<U32> -> @pos:U32 -> @n:U32 -> @buf:U32 -> @cnt:U32 -> @need:Bool -> Bf
type Huf source · line 95 · raw
Type
Huf@cnt:Array<U32> -> @sym:Array<U32> -> @fast:Array<U32> -> Huf
type Cs source · line 99 · raw
Type
count the lengths: cnt[len[i]] += 1
Cs@lens:Array<U32> -> @cnt:Array<U32> -> Cs
type Of source · line 119 · raw
Type
offsets: offs[l+1] = offs[l] + cnt[l], for l in 1..15
Of@cnt:Array<U32> -> @offs:Array<U32> -> Of
type Pl source · line 135 · raw
Type
place: sym[offs[len[i]]] = i and offs[len[i]] += 1, for lengths > 0
Pl@lens:Array<U32> -> @offs:Array<U32> -> @sym:Array<U32> -> Pl
type Hn source · line 183 · raw
Type
Hn@cnt:Array<U32> -> @next:Array<U32> -> Hn
type Hf source · line 203 · raw
Type
Hf@lens:Array<U32> -> @next:Array<U32> -> @fast:Array<U32> -> Hf
type Hl source · line 265 · raw
Type
decoding walks the lengths over a peeked window; hit says the code is complete and at is its symbol's index
Hl@cnt:Array<U32> -> @buf:U32 -> @len:U32 -> @code:U32 -> @first:U32 -> @index:U32 -> @at:U32 -> @hit:Bool -> Hl
type Hd source · line 287 · raw
Type
a decoded symbol with the reader and the table handed back
Hd@br:Br -> @h:Huf -> @sym:U32 -> Hd
type Inf source · line 371 · raw
Type
The inflate output is packed four bytes per word. Its exact byte capacity comes from the gzip ISIZE trailer, so decoding neither grows a byte-per-word array nor makes a second pass to pack it afterwards.
Inf@br:Br -> @out:Array<U32> -> @cap:U32 -> @pos:U32 -> @last:Bool -> Inf
type Hs source · line 375 · raw
Type
a block's tables
Hs@lit:Huf -> @dst:Huf -> Hs
type Cd source · line 469 · raw
Type
Cd@st:Inf -> @hs:Hs -> @done:Bool -> Cd
type Cp source · line 472 · raw
Type
Cp@out:Array<U32> -> Cp
type Dy source · line 589 · raw
Type
Dy@br:Br -> @lens:Array<U32> -> @i:U32 -> @n:U32 -> @prev:U32 -> Dy
type Dl source · line 631 · raw
Type
the lengths being read with their table
Dl@dy:Dy -> @h:Huf -> @more:Bool -> Dl
type Sp source · line 674 · raw
Type
lens[off..off+n) copied into dst[0..n)
Sp@src:Array<U32> -> @dst:Array<U32> -> Sp
type Bw source · line 786 · raw
Type
bit writer over the output sink; more says a byte is ready
Bw@ob:0x365c60316ea66a6c80658fc03b4eeac5/words.Sink -> @buf:U32 -> @cnt:U32 -> @more:Bool -> Bw
type Tok source · line 850 · raw
Data
Tok@sym:U32 -> @ex:U32 -> @eb:U32 -> @ds:U32 -> @dx:U32 -> @db:U32 -> Tok
type Ts source · line 865 · raw
Type
the token state of a block: the words, the count, the literal/length and distance counts, and the bytes covered
Ts@tk:Array<U32> -> @nt:U32 -> @fl:Array<U32> -> @fd:Array<U32> -> @cov:U32 -> Ts
type Cf source · line 912 · raw
Data
Cf@good:U32 -> @lazy:U32 -> @nice:U32 -> @chain:U32 -> @slow:Bool -> Cf
type Mw source · line 933 · raw
Type
Match extension keeps one linear input handle. The old implementation forked that handle for every candidate and joined it afterwards. On repetitive data, all workers then contended on the input array's atomic ownership metadata. The agreeing bytes of a step are the xor's trailing zero bytes (4 when it is 0: U32.ctz answers 32). Serially reading the two four-byte windows costs two more word reads per step, but leaves the shared input read-only and ownership-local to each chunk.
Mw@w:Array<U32> -> @a:U32 -> @b:U32 -> @len:U32 -> @more:Bool -> Mw
type In source · line 968 · raw
Type
the hash tables: hd holds the 4-byte chain heads (the first 32768) and the one-entry 3-byte table (the last 32768); prev links the 4-byte chain
In@w:Array<U32> -> @hd:Array<U32> -> @prev:Array<U32> -> In
type Ix source · line 973 · raw
Type
the tables after an insert, the 4-byte chain's previous head and the 3-byte table's previous entry (positions + 1, 0 for none)
Ix@ht:In -> @c4:U32 -> @c3:U32 -> Ix
type Ch source · line 1024 · raw
Type
the chain walk: the best length and distance so far, the four bytes at i (first) and the four ending at the best length (tail; at i while the best is under 4), and the candidate to try; more says it is live, in the window, and worth trying. A candidate is extended only when its four bytes at both places agree, so a chain on 4-byte hashes rarely extends a candidate that cannot do better.
Ch@w:Array<U32> -> @prev:Array<U32> -> @first:U32 -> @bl:U32 -> @bd:U32 -> @tail:U32 -> @cand:U32 -> @more:Bool -> Ch
type Lz source · line 1121 · raw
Type
the pass: input, tables, the block's tokens, the position, and on the lazy levels the held match (pl, pd) for position i - 1 with pend saying that byte is still unsent; stop says the block is full or the input done
Lz@w:Array<U32> -> @hd:Array<U32> -> @prev:Array<U32> -> @ts:Ts -> @i:U32 -> @n:U32 -> @pl:U32 -> @pd:U32 -> @pend:Bool -> @done:Bool -> @stop:Bool -> Lz
type Hq source · line 1286 · raw
Type
the queues: counts by node (merged nodes from n), parents, the leaves left, the front merged node qi and the node count
Hq@fq:Array<U32> -> @par:Array<U32> -> @lv:List<&2, U32> -> @qi:U32 -> @cnt:U32 -> Hq
type Pk source · line 1290 · raw
Type
a taken node and its count; 4294967295 when both queues are empty
Pk@q:Hq -> @node:U32 -> @f:U32 -> Pk
type Mq source · line 1337 · raw
Type
merging the two taken nodes; more says there were two
Mq@q:Hq -> @more:Bool -> Mq
type Dq source · line 1380 · raw
Type
depths from the root down: dep[k] = dep[par[k]] + 1 for k below the root (a dead leaf's entry is unused)
Dq@par:Array<U32> -> @dep:Array<U32> -> Dq
type Ln source · line 1400 · raw
Type
the lengths of the live leaves and the longest
Ln@f0:Array<U32> -> @dep:Array<U32> -> @lens:Array<U32> -> @mx:U32 -> Ln
type Hc source · line 1427 · raw
Type
one build; over says a length passed the limit
Hc@f0:Array<U32> -> @lens:Array<U32> -> @mx:U32 -> @over:Bool -> Hc
type Nz source · line 1496 · raw
Type
at least two live symbols, as a tree needs: 0 and 1 are bumped otherwise
Nz@a:Array<U32> -> @c:U32 -> Nz
type Nx source · line 1529 · raw
Type
Nx@cnt:Array<U32> -> @next:Array<U32> -> Nx
type Cc source · line 1546 · raw
Type
codes[i] = next[len[i]]++ for live symbols, stored bit-reversed: a Huffman code goes most significant bit first
Cc@lens:Array<U32> -> @next:Array<U32> -> @codes:Array<U32> -> Cc
type Tb source · line 1578 · raw
Type
a code table: lengths and codes by symbol
Tb@lens:Array<U32> -> @codes:Array<U32> -> Tb
type Ew source · line 1600 · raw
Type
the writer with a table
Ew@bw:Bw -> @tb:Tb -> Ew
type Lx source · line 1624 · raw
Type
the count of codes up to the last live one, at least lo
Lx@a:Array<U32> -> @last:U32 -> Lx
type Rt source · line 1671 · raw
Type
the run-length tokens (reversed) and the code-length symbol counts
Rt@toks:List<&2, Tok> -> @fc:Array<U32> -> Rt
type Rn source · line 1725 · raw
Type
the run of a length from i; more says the next entry may extend it
Rn@a:Array<U32> -> @r:U32 -> @more:Bool -> Rn
type Re source · line 1746 · raw
Type
the lengths being coded: the array, the tokens and counts, the position
Re@a:Array<U32> -> @toks:List<&2, Tok> -> @fc:Array<U32> -> @i:U32 -> @more:Bool -> Re
type Hw source · line 1781 · raw
Type
the code-length lengths, 3 bits each in cl_order
Hw@bw:Bw -> @a:Array<U32> -> Hw
type Em source · line 1829 · raw
Type
Em@bw:Bw -> @lit:Tb -> @dst:Tb -> @tk:Array<U32> -> Em
type Ct source · line 1874 · raw
Type
the block's cost under the tables, in bits, end-of-block included
Ct@tk:Array<U32> -> @ll:Array<U32> -> @dl:Array<U32> -> @bits:U32 -> Ct
type Cr source · line 1914 · raw
Type
the run-length tokens' cost under the code-length code
Cr@cl:Array<U32> -> @bits:U32 -> Cr
type Sb source · line 1945 · raw
Type
Sb@w:Array<U32> -> @bw:Bw -> Sb
type Bk source · line 2087 · raw
Type
Bk@lz:Lz -> @bw:Bw -> @fin:Bool -> Bk
type Ck source · line 2134 · raw
Type
Ck@a:Array<U32> -> @start:U32 -> @n:U32 -> @d:U32 -> @last:Bool -> Ck
type Cq source · line 2137 · raw
Type
CLeaf@ck:Ck -> Cq
CPair@l:Ck -> @r:Ck -> Cq
CNode@l:Cq -> @r:Cq -> Cq
type Parts source · line 2142 · raw
Type
OLeaf@ob:0x365c60316ea66a6c80658fc03b4eeac5/words.Sink -> Parts
ONode@l:Parts -> @r:Parts -> Parts
type Lv source · line 2194 · raw
Type
the chunks as leaves, built from the last down so the list runs in order
Lv@w:Array<U32> -> @acc:List<&1, Cq> -> Lv
Definitions
def pick source · line 9 · raw
@c:Bool -> @a:U32 -> @b:U32 -> U32
def b2u source · line 15 · raw
@b:Bool -> U32
def bf_byte source · line 34 · raw
@r:Pair(Array<U32>, U32) -> @+pos:U32 -> @+n:U32 -> @+buf:U32 -> @+cnt:U32 -> @+kk:U32 -> Bf
def bf_step source · line 39 · raw
@a:Array<U32> -> @+pos:U32 -> @+n:U32 -> @+buf:U32 -> @+cnt:U32 -> @+kk:U32 -> @live:Bool -> Bf
def bf_loop source · line 47 · raw
@fuel:Nat -> @st:Bf -> @+kk:U32 -> Bf
def bf_br source · line 60 · raw
@st:Bf -> Br
def br_ready source · line 65 · raw
@br:Br -> @+kk:U32 -> Br
def br_take source · line 71 · raw
@+k:Nat -> @+kk:U32 -> @br:Br -> Pair(Br, U32)
def br_bits source · line 78 · raw
@+k:Nat -> @br:Br -> Pair(Br, U32)
k bits, k <= 16
def br_align source · line 83 · raw
@br:Br -> Br
drop the bits of a partial byte
def cnt_set source · line 102 · raw
@lens:Array<U32> -> @+l:U32 -> @rc:Pair(Array<U32>, U32) -> Cs
def cnt_at source · line 106 · raw
@rl:Pair(Array<U32>, U32) -> @cnt:Array<U32> -> Cs
def cnt_loop source · line 111 · raw
@n:Nat -> @st:Cs -> @+i:U32 -> Cs
def offs_at source · line 122 · raw
@rc:Pair(Array<U32>, U32) -> @offs:Array<U32> -> @+l:U32 -> @+o:U32 -> Pair(Of, U32)
def offs_loop source · line 127 · raw
@n:Nat -> @st:Pair(Of, U32) -> @+l:U32 -> Of
def place_skip source · line 138 · raw
@lens:Array<U32> -> @sym:Array<U32> -> @ro:Pair(Array<U32>, U32) -> Pl
def place_do source · line 142 · raw
@lens:Array<U32> -> @+l:U32 -> @+i:U32 -> @sym:Array<U32> -> @ro:Pair(Array<U32>, U32) -> Pl
def place_put source · line 147 · raw
@lens:Array<U32> -> @+l:U32 -> @+i:U32 -> @sym:Array<U32> -> @ro:Pair(Array<U32>, U32) -> @live:Bool -> Pl
def place_at source · line 154 · raw
@rl:Pair(Array<U32>, U32) -> @offs:Array<U32> -> @sym:Array<U32> -> @+i:U32 -> Pl
def place_loop source · line 159 · raw
@n:Nat -> @st:Pl -> @+i:U32 -> Pl
def hrev source · line 169 · raw
@n:Nat -> @+c:U32 -> @+acc:U32 -> U32
A nine-bit primary decode table. Entries pack code length in the high half and symbol in the low half; zero means that a longer code needs the canonical fallback walk.
def hfast_fill source · line 176 · raw
@n:Nat -> @fast:Array<U32> -> @+at:U32 -> @+step:U32 -> @+v:U32 -> Array<U32>
def hn_at source · line 186 · raw
@r:Pair(Array<U32>, U32) -> @next:Array<U32> -> @+l:U32 -> @+code:U32 -> Pair(Hn, U32)
def hn_loop source · line 191 · raw
@n:Nat -> @st:Pair(Hn, U32) -> @+l:U32 -> Hn
def hn_next source · line 198 · raw
@st:Hn -> Array<U32>
def hf_code source · line 206 · raw
@r:Pair(Array<U32>, U32) -> @lens:Array<U32> -> @fast:Array<U32> -> @+i:U32 -> @+l:U32 -> Hf
def hf_live source · line 213 · raw
@lens:Array<U32> -> @next:Array<U32> -> @fast:Array<U32> -> @+i:U32 -> @+l:U32 -> @live:Bool -> Hf
def hf_at source · line 220 · raw
@r:Pair(Array<U32>, U32) -> @next:Array<U32> -> @fast:Array<U32> -> @+i:U32 -> Hf
def hf_loop source · line 225 · raw
@n:Nat -> @st:Hf -> @+i:U32 -> Hf
def hf_fast source · line 232 · raw
@st:Hf -> Array<U32>
def hfast_of source · line 237 · raw
@lens:Array<U32> -> @cnt:Array<U32> -> @+n:U32 -> Array<U32>
def huf_with_fast source · line 240 · raw
@r:Pair(Array<U32>, Array<U32>) -> @lens:Array<U32> -> @sym:Array<U32> -> @+n:U32 -> Huf
def huf_of_pl source · line 244 · raw
@st:Pl -> @cnt:Array<U32> -> @+n:U32 -> Huf
def huf_of_of source · line 249 · raw
@st:Of -> @lens:Array<U32> -> @+n:U32 -> Huf
def huf_of_cs source · line 254 · raw
@st:Cs -> @+n:U32 -> Huf
def huf_build source · line 260 · raw
@lens:Array<U32> -> @+n:U32 -> Huf
the table for n code lengths
def hl_step source · line 268 · raw
@rc:Pair(Array<U32>, U32) -> @+buf:U32 -> @+len:U32 -> @+code:U32 -> @+first:U32 -> @+index:U32 -> Hl
def hl_loop source · line 274 · raw
@n:Nat -> @st:Hl -> Hl
def hd_of source · line 290 · raw
@rs:Pair(Array<U32>, U32) -> @cnt:Array<U32> -> @fast:Array<U32> -> @a:Array<U32> -> @+pos:U32 -> @+n:U32 -> @+buf:U32 -> @+bits:U32 -> @+len:U32 -> Hd
def hd_at source · line 294 · raw
@st:Hl -> @sym:Array<U32> -> @fast:Array<U32> -> @a:Array<U32> -> @+pos:U32 -> @+n:U32 -> @+bits:U32 -> Hd
def huf_walk source · line 299 · raw
@br:Br -> @h:Huf -> Hd
def hd_fast source · line 305 · raw
@br:Br -> @cnt:Array<U32> -> @sym:Array<U32> -> @fast:Array<U32> -> @+v:U32 -> Hd
def huf_fast_run source · line 311 · raw
@fast:Array<U32> -> @br:Br -> @cnt:Array<U32> -> @sym:Array<U32> -> @+v:U32 -> @hit:Bool -> Hd
def huf_fast_pick source · line 318 · raw
@r:Pair(Array<U32>, U32) -> @br:Br -> @cnt:Array<U32> -> @sym:Array<U32> -> Hd
def huf_fast_at source · line 323 · raw
@br:Br -> @h:Huf -> Hd
def huf_decode source · line 329 · raw
@br:Br -> @h:Huf -> Hd
def len_base source · line 338 · raw
@+c:U32 -> U32
def len_extra source · line 342 · raw
@+c:U32 -> U32
def dist_base source · line 345 · raw
@+c:U32 -> U32
def dist_extra source · line 349 · raw
@+c:U32 -> U32
def cl_order source · line 354 · raw
@+i:U32 -> U32
the order the code-length code lengths are sent in, five bits an entry, six entries a word
def fix_len source · line 358 · raw
@+i:U32 -> U32
the fixed literal/length lengths: 8 up to 143, 9 to 255, 7 to 279, 8 on
def fix_lens source · line 361 · raw
@n:Nat -> @a:Array<U32> -> @+i:U32 -> Array<U32>
def fixed_tables source · line 378 · raw
Hs
def inf_put_got source · line 386 · raw
@r:Pair(Array<U32>, U32) -> @+pos:U32 -> @+b:U32 -> Array<U32>
def inf_put source · line 390 · raw
@out:Array<U32> -> @+pos:U32 -> @+b:U32 -> Array<U32>
def inf_word_split source · line 393 · raw
@out:Array<U32> -> @+q:U32 -> @+v:U32 -> @+sh:U32 -> @split:Bool -> Array<U32>
def inf_word_got source · line 400 · raw
@r:Pair(Array<U32>, U32) -> @+pos:U32 -> @+q:U32 -> @+sh:U32 -> @+v:U32 -> Array<U32>
def inf_word source · line 404 · raw
@out:Array<U32> -> @+pos:U32 -> @+v:U32 -> Array<U32>
def stored_put source · line 409 · raw
@r:Pair(Array<U32>, U32) -> @+pos:U32 -> @+n:U32 -> @out:Array<U32> -> @+cap:U32 -> @+at:U32 -> @last:Bool -> Inf
def stored_byte source · line 413 · raw
@br:Br -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @last:Bool -> Inf
def stored_copy source · line 419 · raw
@n:Nat -> @st:Inf -> Inf
def stored_word source · line 426 · raw
@r:Pair(Array<U32>, U32) -> @+pos:U32 -> @+n:U32 -> @out:Array<U32> -> @+cap:U32 -> @+at:U32 -> @last:Bool -> Inf
def stored_word_at source · line 430 · raw
@br:Br -> @out:Array<U32> -> @+cap:U32 -> @+at:U32 -> @last:Bool -> Inf
def stored_words source · line 436 · raw
@n:Nat -> @st:Inf -> Inf
def stored_tail source · line 443 · raw
@st:Inf -> @+len:U32 -> Inf
def stored_room source · line 446 · raw
@oc:Pair(Array<U32>, U32) -> @br:Br -> @+pos:U32 -> @+len:U32 -> @last:Bool -> Inf
def stored_nlen source · line 450 · raw
@r:Pair(Br, U32) -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @+len:U32 -> @last:Bool -> Inf
def stored_len source · line 454 · raw
@r:Pair(Br, U32) -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @last:Bool -> Inf
def stored_block source · line 459 · raw
@st:Inf -> Inf
def copy_put source · line 475 · raw
@r:Pair(Array<U32>, U32) -> @+pos:U32 -> Cp
def copy_word source · line 479 · raw
@r:Pair(Array<U32>, U32) -> @+pos:U32 -> Cp
def copy_loop source · line 484 · raw
@n:Nat -> @st:Cp -> @+pos:U32 -> @+dist:U32 -> Cp
n bytes from dist back, one at a time (an overlap repeats the run)
def copy_words source · line 491 · raw
@n:Nat -> @st:Cp -> @+pos:U32 -> @+dist:U32 -> Cp
def copy_wide source · line 498 · raw
@+len:U32 -> @out:Array<U32> -> @+pos:U32 -> @+dist:U32 -> Cp
def copy_pick source · line 501 · raw
@+len:U32 -> @out:Array<U32> -> @+pos:U32 -> @+dist:U32 -> @wide:Bool -> Cp
def cp_out source · line 508 · raw
@st:Cp -> Array<U32>
def copy_room source · line 513 · raw
@oc:Pair(Array<U32>, U32) -> @br:Br -> @lit:Huf -> @dst:Huf -> @+pos:U32 -> @+len:U32 -> @+dist:U32 -> @last:Bool -> Cd
def emit_copy source · line 517 · raw
@br:Br -> @lit:Huf -> @dst:Huf -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @+len:U32 -> @+dist:U32 -> @last:Bool -> Cd
def dist_fin source · line 520 · raw
@r:Pair(Br, U32) -> @lit:Huf -> @dst:Huf -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @+len:U32 -> @+dbase:U32 -> @last:Bool -> Cd
def dist_sym source · line 524 · raw
@d:Hd -> @lit:Huf -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @+len:U32 -> @last:Bool -> Cd
def len_fin source · line 530 · raw
@r:Pair(Br, U32) -> @lit:Huf -> @dst:Huf -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @+lbase:U32 -> @last:Bool -> Cd
def len_sym source · line 534 · raw
@br:Br -> @lit:Huf -> @dst:Huf -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @+sym:U32 -> @last:Bool -> Cd
def lit_put source · line 539 · raw
@oc:Pair(Array<U32>, U32) -> @br:Br -> @lit:Huf -> @dst:Huf -> @+pos:U32 -> @+sym:U32 -> @last:Bool -> Cd
def sym_run source · line 544 · raw
@lit_:Bool -> @eob:Bool -> @br:Br -> @lit:Huf -> @dst:Huf -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @+sym:U32 -> @last:Bool -> Cd
a literal below 256, the end of block at 256, a length above
def sym_step source · line 553 · raw
@d:Hd -> @dst:Huf -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @last:Bool -> Cd
def code_step source · line 559 · raw
@st:Inf -> @hs:Hs -> Cd
def codes source · line 564 · raw
@n:Nat -> @st:Cd -> Cd
def cd_inf source · line 575 · raw
@st:Cd -> Inf
def huff_block source · line 581 · raw
@st:Inf -> @hs:Hs -> @+cap:U32 -> Inf
cap bounds the symbols: the output size plus room for a block's worth
def cl_put source · line 593 · raw
@r:Pair(Br, U32) -> @lens:Array<U32> -> @+i:U32 -> Dy
the code-length lengths, in cl_order
def cl_lens source · line 597 · raw
@n:Nat -> @st:Dy -> Dy
def rep_fill source · line 605 · raw
@n:Nat -> @lens:Array<U32> -> @+i:U32 -> @+v:U32 -> Array<U32>
fill v into lens[i..i+n)
def rl_put source · line 614 · raw
@r:Pair(Br, U32) -> @lens:Array<U32> -> @+i:U32 -> @+n:U32 -> @+v:U32 -> @+base:U32 -> Dy
a code-length symbol: 0-15 a length, 16 repeats prev 3-6 times, 17 gives 3-10 zeros, 18 11-138 zeros
def rl_run source · line 619 · raw
@len_:Bool -> @rep:Bool -> @z3:Bool -> @br:Br -> @lens:Array<U32> -> @+i:U32 -> @+n:U32 -> @+prev:U32 -> @+sym:U32 -> Dy
def dl_of source · line 634 · raw
@st:Dy -> @h:Huf -> Dl
def rl_sym source · line 641 · raw
@d:Hd -> @lens:Array<U32> -> @+i:U32 -> @+n:U32 -> @+prev:U32 -> Dl
def rl_step source · line 647 · raw
@st:Dy -> @h:Huf -> Dl
def rl_loop source · line 652 · raw
@fuel:Nat -> @st:Dl -> Dl
def dy_pair source · line 663 · raw
@dy:Dy -> Pair(Br, Array<U32>)
def dy_lens source · line 668 · raw
@st:Dl -> Pair(Br, Array<U32>)
def sp_put source · line 677 · raw
@r:Pair(Array<U32>, U32) -> @dst:Array<U32> -> @+i:U32 -> Sp
def sp_loop source · line 681 · raw
@n:Nat -> @st:Sp -> @+i:U32 -> @+off:U32 -> Sp
def sp_pair source · line 688 · raw
@st:Sp -> Pair(Array<U32>, Array<U32>)
def split_lens source · line 693 · raw
@+n:U32 -> @src:Array<U32> -> @dst:Array<U32> -> @+off:U32 -> Pair(Array<U32>, Array<U32>)
def dyn_dist source · line 696 · raw
@r:Pair(Array<U32>, Array<U32>) -> @br:Br -> @+nlit:U32 -> @+ndist:U32 -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @last:Bool -> Inf
def dyn_tables source · line 700 · raw
@r:Pair(Br, Array<U32>) -> @+nlit:U32 -> @+ndist:U32 -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @last:Bool -> Inf
def dyn_body source · line 704 · raw
@cl:Dy -> @+nlit:U32 -> @+ndist:U32 -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @last:Bool -> Inf
def dyn_hclen source · line 710 · raw
@r:Pair(Br, U32) -> @+nlit:U32 -> @+ndist:U32 -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @last:Bool -> Inf
def dyn_hdist source · line 714 · raw
@r:Pair(Br, U32) -> @+nlit:U32 -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @last:Bool -> Inf
def dyn_hlit source · line 718 · raw
@r:Pair(Br, U32) -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> @last:Bool -> Inf
def dyn_block source · line 722 · raw
@st:Inf -> Inf
def block_run source · line 730 · raw
@stored:Bool -> @fixed:Bool -> @st:Inf -> Inf
def block_head source · line 739 · raw
@r:Pair(Br, U32) -> @out:Array<U32> -> @+cap:U32 -> @+pos:U32 -> Inf
def block source · line 744 · raw
@st:Inf -> Inf
def blocks source · line 749 · raw
@n:Nat -> @st:Inf -> Inf
def inf_pack source · line 766 · raw
@st:Inf -> Pair(Array<U32>, U32)
def inflate source · line 774 · raw
@a:Array<U32> -> @+pos:U32 -> @+n:U32 -> @+out_n:U32 -> Pair(Array<U32>, U32)
the raw DEFLATE stream at byte pos of the n bytes of a, decoded into a fresh packed array of exactly out_n bytes (gzip's ISIZE says how many); answers that array and its byte count
def bw_flush source · line 789 · raw
@n:Nat -> @st:Bw -> Bw
def bw_put source · line 803 · raw
@st:Bw -> @+v:U32 -> @+k:U32 -> Bw
v's low k bits, least significant first
def rev_bits source · line 810 · raw
@n:Nat -> @+c:U32 -> @+acc:U32 -> U32
def bw_last source · line 817 · raw
@ob:0x365c60316ea66a6c80658fc03b4eeac5/words.Sink -> @+buf:U32 -> @some:Bool -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
def bw_fin source · line 824 · raw
@st:Bw -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
def base_of source · line 830 · raw
@dist:Bool -> @+c:U32 -> U32
def extra_of source · line 837 · raw
@dist:Bool -> @+c:U32 -> U32
def bump_put source · line 853 · raw
@r:Pair(Array<U32>, U32) -> @+i:U32 -> Array<U32>
def bump source · line 857 · raw
@a:Array<U32> -> @+i:U32 -> Array<U32>
def tk_w0 source · line 860 · raw
@+sym:U32 -> @+ex:U32 -> @+eb:U32 -> @+ds:U32 -> @+db:U32 -> U32
def ts_new source · line 868 · raw
Ts
def ts_put source · line 871 · raw
@tk:Array<U32> -> @+nt:U32 -> @+w0:U32 -> @+w1:U32 -> Array<U32>
def ts_lit source · line 875 · raw
@st:Ts -> @+b:U32 -> Pair(Ts, Bool)
a literal; the flag says the block is full
def ts_len source · line 881 · raw
@st:Ts -> @+len:U32 -> @+dist:U32 -> Pair(Ts, Bool)
def trev source · line 893 · raw
@l:List<&2, Tok> -> @acc:List<&2, Tok> -> List<&2, Tok>
def cf_of source · line 915 · raw
@+l:U32 -> Cf
def cf_slow source · line 922 · raw
@cf:Cf -> Bool
def mw_cmp source · line 936 · raw
@r:Pair(Array<U32>, U32) -> @+a:U32 -> @+b:U32 -> @+wa:U32 -> @+len:U32 -> @+maxlen:U32 -> Mw
def mw_b source · line 943 · raw
@r:Pair(Array<U32>, U32) -> @+a:U32 -> @+b:U32 -> @+len:U32 -> @+maxlen:U32 -> Mw
def mw_loop source · line 947 · raw
@fuel:Nat -> @st:Mw -> @+maxlen:U32 -> Mw
def mw_fin source · line 961 · raw
@st:Mw -> Pair(Array<U32>, U32)
def ix_put4 source · line 976 · raw
@r:Pair(Array<U32>, U32) -> @w:Array<U32> -> @prev:Array<U32> -> @+j:U32 -> @+h:U32 -> @+c3:U32 -> Ix
def ix_put3 source · line 981 · raw
@r:Pair(Array<U32>, U32) -> @w:Array<U32> -> @prev:Array<U32> -> @+j:U32 -> @+h:U32 -> @+g:U32 -> Ix
def ix_win source · line 987 · raw
@r:Pair(Array<U32>, U32) -> @hd:Array<U32> -> @prev:Array<U32> -> @+j:U32 -> Ix
multiplicative hashes of the four bytes at j and of their low three
def ix_go source · line 994 · raw
@w:Array<U32> -> @hd:Array<U32> -> @prev:Array<U32> -> @+j:U32 -> @ok:Bool -> Ix
def ins_at source · line 1002 · raw
@w:Array<U32> -> @hd:Array<U32> -> @prev:Array<U32> -> @+j:U32 -> @+n:U32 -> Ix
position j into both tables; nothing when fewer than 4 bytes remain
def ins_drop source · line 1005 · raw
@r:Ix -> In
def ins_loop source · line 1011 · raw
@fuel:Nat -> @st:In -> @+j:U32 -> @+n:U32 -> In
positions j.. into the tables
def ch_next source · line 1027 · raw
@rp:Pair(Array<U32>, U32) -> @w:Array<U32> -> @+first:U32 -> @+bl:U32 -> @+bd:U32 -> @+tail:U32 -> @+i:U32 -> @+nice:U32 -> @+left:U32 -> Ch
def ch_skip source · line 1032 · raw
@w:Array<U32> -> @prev:Array<U32> -> @+first:U32 -> @+bl:U32 -> @+bd:U32 -> @+tail:U32 -> @+c:U32 -> @+i:U32 -> @+nice:U32 -> @+left:U32 -> Ch
def ch_tail source · line 1035 · raw
@r:Pair(Array<U32>, U32) -> @prev:Array<U32> -> @+first:U32 -> @+l:U32 -> @+d:U32 -> @+c:U32 -> @+i:U32 -> @+nice:U32 -> @+left:U32 -> Ch
def ch_upd source · line 1040 · raw
@w:Array<U32> -> @prev:Array<U32> -> @+first:U32 -> @+l:U32 -> @+bl:U32 -> @+bd:U32 -> @+tail:U32 -> @+c:U32 -> @+d:U32 -> @+i:U32 -> @+nice:U32 -> @+left:U32 -> @better:Bool -> Ch
def ch_len source · line 1047 · raw
@r:Pair(Array<U32>, U32) -> @prev:Array<U32> -> @+first:U32 -> @+bl:U32 -> @+bd:U32 -> @+tail:U32 -> @+c:U32 -> @+d:U32 -> @+i:U32 -> @+nice:U32 -> @+left:U32 -> Ch
def ch_ext source · line 1052 · raw
@w:Array<U32> -> @prev:Array<U32> -> @+first:U32 -> @+bl:U32 -> @+bd:U32 -> @+tail:U32 -> @+c:U32 -> @+d:U32 -> @+i:U32 -> @+maxlen:U32 -> @+nice:U32 -> @+left:U32 -> @ok:Bool -> Ch
def ch_head source · line 1059 · raw
@r:Pair(Array<U32>, U32) -> @prev:Array<U32> -> @+first:U32 -> @+bl:U32 -> @+bd:U32 -> @+tail:U32 -> @+c:U32 -> @+d:U32 -> @+i:U32 -> @+maxlen:U32 -> @+nice:U32 -> @+left:U32 -> Ch
def ch_tq source · line 1063 · raw
@w:Array<U32> -> @prev:Array<U32> -> @+first:U32 -> @+bl:U32 -> @+bd:U32 -> @+tail:U32 -> @+c:U32 -> @+d:U32 -> @+i:U32 -> @+maxlen:U32 -> @+nice:U32 -> @+left:U32 -> @same:Bool -> Ch
def ch_tl source · line 1070 · raw
@r:Pair(Array<U32>, U32) -> @prev:Array<U32> -> @+first:U32 -> @+bl:U32 -> @+bd:U32 -> @+tail:U32 -> @+c:U32 -> @+d:U32 -> @+i:U32 -> @+maxlen:U32 -> @+nice:U32 -> @+left:U32 -> Ch
def ch_loop source · line 1074 · raw
@fuel:Nat -> @st:Ch -> @+i:U32 -> @+maxlen:U32 -> @+nice:U32 -> @+left:U32 -> Ch
def ch_begin source · line 1089 · raw
@r:Pair(Array<U32>, U32) -> @prev:Array<U32> -> @+first:U32 -> @+c3:U32 -> @+cand:U32 -> @+i:U32 -> @+n:U32 -> @+chain:U32 -> @+nice:U32 -> Ch
the 3-byte table's candidate makes a match of 3 when its three bytes agree
def ch_first source · line 1096 · raw
@r:Pair(Array<U32>, U32) -> @prev:Array<U32> -> @+c3:U32 -> @+cand:U32 -> @+i:U32 -> @+n:U32 -> @+chain:U32 -> @+nice:U32 -> Ch
def ch_gate source · line 1101 · raw
@w:Array<U32> -> @prev:Array<U32> -> @+i:U32 -> @+n:U32 -> @+cand:U32 -> @+c3:U32 -> @+chain:U32 -> @+nice:U32 -> @go:Bool -> Ch
def chain source · line 1110 · raw
@w:Array<U32> -> @prev:Array<U32> -> @+i:U32 -> @+n:U32 -> @+cand:U32 -> @+c3:U32 -> @+chain:U32 -> @+nice:U32 -> @search:Bool -> Ch
the walk from the 4-byte head cand after the 3-byte candidate c3; search says it is wanted at all
def too_far source · line 1114 · raw
@+l:U32 -> @+d:U32 -> U32
a match of 3 farther than 4096 back costs more than its literals
def lz_of source · line 1124 · raw
@r:Pair(Ts, Bool) -> @w:Array<U32> -> @hd:Array<U32> -> @prev:Array<U32> -> @+i:U32 -> @+n:U32 -> @+pl:U32 -> @+pd:U32 -> @+pend:Bool -> @+done:Bool -> Lz
def lz_match source · line 1129 · raw
@ht:In -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+len:U32 -> @+dist:U32 -> Lz
a match token; the pass resumes at i
def lz_lit source · line 1135 · raw
@r:Pair(Array<U32>, U32) -> @hd:Array<U32> -> @prev:Array<U32> -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+pl:U32 -> @+pd:U32 -> @+pend:Bool -> Lz
a literal token; the pass resumes at i holding (pl, pd)
def fa_ins source · line 1142 · raw
@ht:In -> @+i:U32 -> @+n:U32 -> @+cl:U32 -> @ins:Bool -> In
def fa_decide source · line 1149 · raw
@w:Array<U32> -> @hd:Array<U32> -> @prev:Array<U32> -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+cl:U32 -> @+cd:U32 -> @+maxins:U32 -> @hit:Bool -> Lz
def fa_found source · line 1156 · raw
@ch:Ch -> @hd:Array<U32> -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+maxins:U32 -> Lz
def fa_ht source · line 1163 · raw
@ht:In -> @+cand:U32 -> @+c3:U32 -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+cf:Cf -> Lz
def fa_ins_at source · line 1168 · raw
@r:Ix -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+cf:Cf -> Lz
def fa_step source · line 1173 · raw
@st:Lz -> @+cf:Cf -> Lz
def ins_stride source · line 1185 · raw
@fuel:Nat -> @st:In -> @+j:U32 -> @+n:U32 -> In
def sl_insert source · line 1192 · raw
@ht:In -> @+i:U32 -> @+n:U32 -> @+pl:U32 -> @+maxins:U32 -> @insert:Bool -> In
def sl_decide source · line 1199 · raw
@w:Array<U32> -> @hd:Array<U32> -> @prev:Array<U32> -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+pl:U32 -> @+pd:U32 -> @+cl:U32 -> @+cd:U32 -> @+maxins:U32 -> @pend:Bool -> @take:Bool -> Lz
def sl_found source · line 1208 · raw
@ch:Ch -> @hd:Array<U32> -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+pl:U32 -> @+pd:U32 -> @+maxins:U32 -> @pend:Bool -> Lz
def sl_ht source · line 1215 · raw
@ht:In -> @+cand:U32 -> @+c3:U32 -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+pl:U32 -> @+pd:U32 -> @pend:Bool -> @+cf:Cf -> Lz
def sl_ins_at source · line 1220 · raw
@r:Ix -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+pl:U32 -> @+pd:U32 -> @pend:Bool -> @+cf:Cf -> Lz
def sl_step source · line 1225 · raw
@st:Lz -> @+cf:Cf -> Lz
def lz_mode source · line 1232 · raw
@st:Lz -> @+cf:Cf -> @slow:Bool -> Lz
def lz_step source · line 1239 · raw
@st:Lz -> @+cf:Cf -> Lz
def lz_loop source · line 1243 · raw
@fuel:Nat -> @st:Lz -> @+cf:Cf -> Lz
until the block is full or the input done
def lk_put source · line 1265 · raw
@f0:Array<U32> -> @acc:List<&2, U32> -> @+f:U32 -> @+i:U32 -> @live:Bool -> Pair(Array<U32>, List<&2, U32>)
the live leaves as count << 9 | symbol, in symbol order
def lk_at source · line 1272 · raw
@r:Pair(Array<U32>, U32) -> @acc:List<&2, U32> -> @+i:U32 -> Pair(Array<U32>, List<&2, U32>)
def lk_loop source · line 1277 · raw
@n:Nat -> @st:Pair(Array<U32>, List<&2, U32>) -> @+i:U32 -> Pair(Array<U32>, List<&2, U32>)
def pk_sel source · line 1293 · raw
@fq:Array<U32> -> @par:Array<U32> -> @+h:U32 -> @t:List<&2, U32> -> @+qi:U32 -> @+cnt:U32 -> @+f:U32 -> @leaf:Bool -> Pk
def pk_cmp source · line 1300 · raw
@r:Pair(Array<U32>, U32) -> @par:Array<U32> -> @+h:U32 -> @t:List<&2, U32> -> @+qi:U32 -> @+cnt:U32 -> Pk
def pk_both source · line 1305 · raw
@fq:Array<U32> -> @par:Array<U32> -> @+h:U32 -> @t:List<&2, U32> -> @+qi:U32 -> @+cnt:U32 -> @q:Bool -> Pk
def pk_int source · line 1312 · raw
@r:Pair(Array<U32>, U32) -> @par:Array<U32> -> @+qi:U32 -> @+cnt:U32 -> Pk
def pk_merged source · line 1317 · raw
@fq:Array<U32> -> @par:Array<U32> -> @+qi:U32 -> @+cnt:U32 -> @q:Bool -> Pk
def pop source · line 1324 · raw
@st:Hq -> Pk
def mq_do source · line 1340 · raw
@q:Hq -> @+a:U32 -> @+fa:U32 -> @+b:U32 -> @+fb:U32 -> @ok:Bool -> Mq
def mq_join source · line 1348 · raw
@pb:Pk -> @+a:U32 -> @+fa:U32 -> Mq
def mq_go source · line 1354 · raw
@q:Hq -> @+a:U32 -> @+fa:U32 -> @ok:Bool -> Mq
def mq_first source · line 1361 · raw
@pa:Pk -> Mq
def mq_loop source · line 1367 · raw
@n:Nat -> @st:Mq -> Mq
def dq_put source · line 1383 · raw
@r:Pair(Array<U32>, U32) -> @par:Array<U32> -> @+k:U32 -> Dq
def dq_par source · line 1387 · raw
@r:Pair(Array<U32>, U32) -> @dep:Array<U32> -> @+k:U32 -> Dq
def dq_loop source · line 1392 · raw
@n:Nat -> @st:Dq -> @+k:U32 -> Dq
def ln_put source · line 1403 · raw
@r:Pair(Array<U32>, U32) -> @f0:Array<U32> -> @lens:Array<U32> -> @+i:U32 -> @+mx:U32 -> Ln
def ln_go source · line 1408 · raw
@f0:Array<U32> -> @dep:Array<U32> -> @lens:Array<U32> -> @+i:U32 -> @+mx:U32 -> @live:Bool -> Ln
def ln_at source · line 1415 · raw
@rf:Pair(Array<U32>, U32) -> @dep:Array<U32> -> @lens:Array<U32> -> @+i:U32 -> @+mx:U32 -> Ln
def ln_loop source · line 1419 · raw
@n:Nat -> @st:Ln -> @+i:U32 -> Ln
def hc_of source · line 1430 · raw
@ln:Ln -> @+limit:U32 -> Hc
def hc_dq source · line 1436 · raw
@dq:Dq -> @f0:Array<U32> -> @+n:U32 -> @+limit:U32 -> Hc
def hc_mq source · line 1441 · raw
@mq:Mq -> @f0:Array<U32> -> @+n:U32 -> @+limit:U32 -> Hc
def gr_pair source · line 1447 · raw
@st:0x365c60316ea66a6c80658fc03b4eeac5/words.Gr -> Pair(Array<U32>, Array<U32>)
def hc_lk source · line 1452 · raw
@r:Pair(Array<U32>, List<&2, U32>) -> @fq:Array<U32> -> @+n:U32 -> @+limit:U32 -> Hc
def hc_mg source · line 1456 · raw
@r:Pair(Array<U32>, Array<U32>) -> @+n:U32 -> @+limit:U32 -> Hc
def hc_once source · line 1460 · raw
@f0:Array<U32> -> @+n:U32 -> @+limit:U32 -> Hc
def hv_put source · line 1463 · raw
@r:Pair(Array<U32>, U32) -> @+i:U32 -> Array<U32>
def hv_loop source · line 1469 · raw
@n:Nat -> @a:Array<U32> -> @+i:U32 -> Array<U32>
counts halved, rounding up so live stays live
def hc_limit source · line 1476 · raw
@n:Nat -> @st:Hc -> @+sz:U32 -> @+limit:U32 -> Hc
def hc_lens source · line 1487 · raw
@st:Hc -> Array<U32>
def huff_lens source · line 1492 · raw
@f0:Array<U32> -> @+n:U32 -> @+limit:U32 -> Array<U32>
def nz_at source · line 1499 · raw
@r:Pair(Array<U32>, U32) -> @+c:U32 -> Nz
def nz_loop source · line 1503 · raw
@n:Nat -> @st:Nz -> @+i:U32 -> Nz
def nz_go source · line 1510 · raw
@a:Array<U32> -> @few:Bool -> Array<U32>
def nz_fix source · line 1517 · raw
@st:Nz -> Array<U32>
def two_live source · line 1522 · raw
@a:Array<U32> -> @+n:U32 -> Array<U32>
def nx_at source · line 1532 · raw
@rc:Pair(Array<U32>, U32) -> @next:Array<U32> -> @+l:U32 -> @+code:U32 -> Pair(Nx, U32)
def nx_loop source · line 1537 · raw
@n:Nat -> @st:Pair(Nx, U32) -> @+l:U32 -> Nx
def cc_skip source · line 1549 · raw
@lens:Array<U32> -> @codes:Array<U32> -> @ro:Pair(Array<U32>, U32) -> Cc
def cc_do source · line 1553 · raw
@lens:Array<U32> -> @+l:U32 -> @+i:U32 -> @codes:Array<U32> -> @ro:Pair(Array<U32>, U32) -> Cc
def cc_put source · line 1558 · raw
@lens:Array<U32> -> @+l:U32 -> @+i:U32 -> @codes:Array<U32> -> @ro:Pair(Array<U32>, U32) -> @live:Bool -> Cc
def cc_at source · line 1565 · raw
@rl:Pair(Array<U32>, U32) -> @next:Array<U32> -> @codes:Array<U32> -> @+i:U32 -> Cc
def cc_loop source · line 1570 · raw
@n:Nat -> @st:Cc -> @+i:U32 -> Cc
def cc_tb source · line 1581 · raw
@st:Cc -> Tb
def tb_nx source · line 1586 · raw
@st:Nx -> @lens:Array<U32> -> @+n:U32 -> Tb
def tb_cs source · line 1591 · raw
@st:Cs -> @+n:U32 -> Tb
def tb_of source · line 1596 · raw
@lens:Array<U32> -> @+n:U32 -> Tb
def tb_put source · line 1603 · raw
@r:Pair(Array<U32>, U32) -> @lens:Array<U32> -> @bw:Bw -> @+l:U32 -> Ew
def tb_at source · line 1607 · raw
@r:Pair(Array<U32>, U32) -> @codes:Array<U32> -> @bw:Bw -> @+sym:U32 -> Ew
def tb_code source · line 1612 · raw
@bw:Bw -> @tb:Tb -> @+sym:U32 -> Ew
def lx_at source · line 1627 · raw
@r:Pair(Array<U32>, U32) -> @+i:U32 -> @+last:U32 -> Lx
def lx_loop source · line 1631 · raw
@n:Nat -> @st:Lx -> @+i:U32 -> Lx
def lo_loop source · line 1639 · raw
@n:Nat -> @st:Lx -> @+i:U32 -> Lx
the same over cl_order, for HCLEN
def lx_of source · line 1646 · raw
@st:Lx -> @+lo:U32 -> Pair(Array<U32>, U32)
def used source · line 1652 · raw
@a:Array<U32> -> @+n:U32 -> @+lo:U32 -> Pair(Array<U32>, U32)
def used_ord source · line 1655 · raw
@a:Array<U32> -> @+lo:U32 -> Pair(Array<U32>, U32)
def ap_put source · line 1659 · raw
@r:Pair(Array<U32>, U32) -> @dst:Array<U32> -> @+i:U32 -> @+off:U32 -> Sp
dst[off + i] = src[i]
def ap_loop source · line 1663 · raw
@n:Nat -> @st:Sp -> @+i:U32 -> @+off:U32 -> Sp
def rpush source · line 1674 · raw
@st:Rt -> @+sym:U32 -> @+ex:U32 -> @+eb:U32 -> Rt
def zrun source · line 1682 · raw
@n:Nat -> @st:Rt -> @+r:U32 -> @b11:Bool -> @b3:Bool -> @b1:Bool -> Rt
a run of r zeros: 11-138 go as an 18, 3-10 as a 17, one as a zero; the flags say which the run allows
def lrun source · line 1700 · raw
@n:Nat -> @st:Rt -> @+l:U32 -> @+r:U32 -> @b3:Bool -> @b1:Bool -> Rt
r more copies of a length l already sent: 3-6 go as a 16, one sends l again
def run_go source · line 1714 · raw
@st:Rt -> @+l:U32 -> @+r:U32 -> @zero:Bool -> Rt
def run_emit source · line 1721 · raw
@st:Rt -> @+l:U32 -> @+r:U32 -> Rt
def rn_at source · line 1728 · raw
@rv:Pair(Array<U32>, U32) -> @+r:U32 -> @+i:U32 -> @+l:U32 -> @+total:U32 -> Rn
def rn_loop source · line 1733 · raw
@n:Nat -> @st:Rn -> @+i:U32 -> @+l:U32 -> @+total:U32 -> Rn
def re_of source · line 1749 · raw
@a:Array<U32> -> @rt:Rt -> @+i:U32 -> @+total:U32 -> Re
def re_run source · line 1754 · raw
@rn:Rn -> @toks:List<&2, Tok> -> @fc:Array<U32> -> @+i:U32 -> @+l:U32 -> @+total:U32 -> Re
def re_at source · line 1760 · raw
@r:Pair(Array<U32>, U32) -> @toks:List<&2, Tok> -> @fc:Array<U32> -> @+i:U32 -> @+total:U32 -> Re
def re_loop source · line 1765 · raw
@n:Nat -> @st:Re -> @+total:U32 -> Re
def hw_put source · line 1784 · raw
@r:Pair(Array<U32>, U32) -> @bw:Bw -> Hw
def hw_loop source · line 1788 · raw
@n:Nat -> @st:Hw -> @+k:U32 -> Hw
def ec_ex source · line 1795 · raw
@st:Ew -> @+ex:U32 -> @+eb:U32 -> Ew
def ec_tok source · line 1800 · raw
@t:Tok -> @st:Ew -> Ew
def ec_loop source · line 1805 · raw
@toks:List<&2, Tok> -> @st:Ew -> Ew
def bw_byte source · line 1817 · raw
@st:Bw -> @+b:U32 -> Bw
def bw_align source · line 1823 · raw
@st:Bw -> Bw
zeros to the next byte boundary
def em_dist source · line 1832 · raw
@st:Ew -> @lit:Tb -> @+dx:U32 -> @+db:U32 -> @tk:Array<U32> -> Em
def em_len source · line 1837 · raw
@st:Ew -> @dst:Tb -> @+ds:U32 -> @+dx:U32 -> @+db:U32 -> @tk:Array<U32> -> @islen:Bool -> Em
def em_tok source · line 1844 · raw
@+w0:U32 -> @+w1:U32 -> @bw:Bw -> @lit:Tb -> @dst:Tb -> @tk:Array<U32> -> Em
def em_w1 source · line 1848 · raw
@r:Pair(Array<U32>, U32) -> @bw:Bw -> @lit:Tb -> @dst:Tb -> @+w0:U32 -> Em
def em_w0 source · line 1852 · raw
@r:Pair(Array<U32>, U32) -> @bw:Bw -> @lit:Tb -> @dst:Tb -> @+j:U32 -> Em
def em_loop source · line 1856 · raw
@k:Nat -> @st:Em -> @+j:U32 -> Em
def em_fin source · line 1863 · raw
@st:Ew -> Bw
def em_eob source · line 1868 · raw
@st:Em -> Bw
def ct_dl source · line 1877 · raw
@r:Pair(Array<U32>, U32) -> @tk:Array<U32> -> @ll:Array<U32> -> @+bits:U32 -> @+db:U32 -> Ct
def ct_len source · line 1881 · raw
@tk:Array<U32> -> @ll:Array<U32> -> @dl:Array<U32> -> @+bits:U32 -> @+ds:U32 -> @+db:U32 -> @islen:Bool -> Ct
def ct_ll source · line 1888 · raw
@r:Pair(Array<U32>, U32) -> @tk:Array<U32> -> @dl:Array<U32> -> @+bits:U32 -> @+w0:U32 -> Ct
def ct_w0 source · line 1892 · raw
@r:Pair(Array<U32>, U32) -> @ll:Array<U32> -> @dl:Array<U32> -> @+bits:U32 -> Ct
def ct_loop source · line 1897 · raw
@k:Nat -> @st:Ct -> @+j:U32 -> Ct
def ct_swap source · line 1904 · raw
@r:Pair(Array<U32>, U32) -> @tk:Array<U32> -> @dl:Array<U32> -> @+bits:U32 -> @+db:U32 -> Ct
def ct_eob source · line 1908 · raw
@st:Ct -> Ct
def cr_at source · line 1917 · raw
@r:Pair(Array<U32>, U32) -> @+bits:U32 -> @+eb:U32 -> Cr
def cr_tok source · line 1921 · raw
@t:Tok -> @cl:Array<U32> -> @+bits:U32 -> Cr
def cr_loop source · line 1926 · raw
@l:List<&2, Tok> -> @st:Cr -> Cr
def cr_of source · line 1933 · raw
@st:Cr -> Pair(Array<U32>, U32)
def sb_put source · line 1948 · raw
@r:Pair(Array<U32>, U32) -> @bw:Bw -> Sb
def sb_copy source · line 1952 · raw
@n:Nat -> @st:Sb -> @+j:U32 -> Sb
def sb_word source · line 1959 · raw
@r:Pair(Array<U32>, U32) -> @bw:Bw -> Sb
def sb_words source · line 1965 · raw
@n:Nat -> @st:Sb -> @+j:U32 -> Sb
def sb_fast source · line 1972 · raw
@+len:U32 -> @st:Sb -> @+j:U32 -> Sb
def bw_reserve source · line 1975 · raw
@st:Bw -> @+n:U32 -> Bw
def sb_head source · line 1980 · raw
@st:Sb -> @+len:U32 -> @final:Bool -> Sb
def sb_loop source · line 1986 · raw
@m:Nat -> @st:Sb -> @+k:U32 -> @+start:U32 -> @+cov:U32 -> @+count:U32 -> @+final:Bool -> Sb
def sb_pair source · line 1995 · raw
@st:Sb -> Pair(Array<U32>, Bw)
def stored_out source · line 2000 · raw
@w:Array<U32> -> @bw:Bw -> @+start:U32 -> @+cov:U32 -> @final:Bool -> Pair(Array<U32>, Bw)
def df_9 source · line 2009 · raw
@bw:Bw -> @w:Array<U32> -> Pair(Array<U32>, Bw)
def df_8 source · line 2012 · raw
@tk:Array<U32> -> @+nt:U32 -> @lit:Tb -> @dst:Tb -> @ew:Ew -> @w:Array<U32> -> Pair(Array<U32>, Bw)
def df_7 source · line 2017 · raw
@tk:Array<U32> -> @+nt:U32 -> @ll:Array<U32> -> @dl:Array<U32> -> @ctoks:List<&2, Tok> -> @hw:Hw -> @w:Array<U32> -> Pair(Array<U32>, Bw)
def df_dyn source · line 2023 · raw
@tk:Array<U32> -> @+nt:U32 -> @ll:Array<U32> -> @dl:Array<U32> -> @ctoks:List<&2, Tok> -> @cl:Array<U32> -> @+hl:U32 -> @+hd:U32 -> @+hc:U32 -> @bw:Bw -> @w:Array<U32> -> @final:Bool -> Pair(Array<U32>, Bw)
BFINAL, BTYPE 10, then HLIT-257, HDIST-1, HCLEN-4 and the code-length lengths
def df_pick source · line 2026 · raw
@tk:Array<U32> -> @+nt:U32 -> @ll:Array<U32> -> @dl:Array<U32> -> @ctoks:List<&2, Tok> -> @cl:Array<U32> -> @+hl:U32 -> @+hd:U32 -> @+hc:U32 -> @bw:Bw -> @w:Array<U32> -> @+start:U32 -> @+cov:U32 -> @final:Bool -> @stored:Bool -> Pair(Array<U32>, Bw)
def df_cost source · line 2033 · raw
@ct:Ct -> @rc:Pair(Array<U32>, U32) -> @ctoks:List<&2, Tok> -> @+nt:U32 -> @+hl:U32 -> @+hd:U32 -> @+hc:U32 -> @bw:Bw -> @w:Array<U32> -> @+start:U32 -> @+cov:U32 -> @final:Bool -> Pair(Array<U32>, Bw)
def df_6 source · line 2040 · raw
@tk:Array<U32> -> @+nt:U32 -> @ll:Array<U32> -> @dl:Array<U32> -> @+ctoks:List<&2, Tok> -> @rc:Pair(Array<U32>, U32) -> @+hl:U32 -> @+hd:U32 -> @bw:Bw -> @w:Array<U32> -> @+start:U32 -> @+cov:U32 -> @final:Bool -> Pair(Array<U32>, Bw)
def df_5 source · line 2045 · raw
@tk:Array<U32> -> @+nt:U32 -> @ll:Array<U32> -> @dl:Array<U32> -> @re:Re -> @+hl:U32 -> @+hd:U32 -> @bw:Bw -> @w:Array<U32> -> @+start:U32 -> @+cov:U32 -> @final:Bool -> Pair(Array<U32>, Bw)
def df_4 source · line 2051 · raw
@tk:Array<U32> -> @+nt:U32 -> @ll:Array<U32> -> @sp:Sp -> @+hl:U32 -> @+hd:U32 -> @bw:Bw -> @w:Array<U32> -> @+start:U32 -> @+cov:U32 -> @final:Bool -> Pair(Array<U32>, Bw)
def df_3 source · line 2056 · raw
@tk:Array<U32> -> @+nt:U32 -> @sp:Sp -> @dl:Array<U32> -> @+hl:U32 -> @+hd:U32 -> @bw:Bw -> @w:Array<U32> -> @+start:U32 -> @+cov:U32 -> @final:Bool -> Pair(Array<U32>, Bw)
def df_2 source · line 2061 · raw
@tk:Array<U32> -> @+nt:U32 -> @rl:Pair(Array<U32>, U32) -> @rd:Pair(Array<U32>, U32) -> @bw:Bw -> @w:Array<U32> -> @+start:U32 -> @+cov:U32 -> @final:Bool -> Pair(Array<U32>, Bw)
def df_start source · line 2068 · raw
@tk:Array<U32> -> @+nt:U32 -> @fl:Array<U32> -> @fd:Array<U32> -> @bw:Bw -> @w:Array<U32> -> @+start:U32 -> @+cov:U32 -> @final:Bool -> @raw:Bool -> Pair(Array<U32>, Bw)
def df_1 source · line 2075 · raw
@ts:Ts -> @bw:Bw -> @w:Array<U32> -> @+iend:U32 -> @final:Bool -> Pair(Array<U32>, Bw)
def bk_next source · line 2090 · raw
@r:Pair(Array<U32>, Bw) -> @hd:Array<U32> -> @prev:Array<U32> -> @+i:U32 -> @+n:U32 -> @+pl:U32 -> @+pd:U32 -> @+pend:Bool -> @+done:Bool -> Bk
def bk_emit source · line 2094 · raw
@st:Lz -> @bw:Bw -> @+last:Bool -> Bk
def bk_loop source · line 2102 · raw
@fuel:Nat -> @st:Bk -> @+cf:Cf -> @+last:Bool -> Bk
def lz_drop source · line 2113 · raw
@lz:Lz -> @bw:Bw -> Bw
def bk_bw source · line 2118 · raw
@st:Bk -> Bw
def stored_empty source · line 2147 · raw
@bw:Bw -> Bw
an empty stored block: BFINAL 0, BTYPE 00, zeros to the byte, 0, 65535
def ck_fin source · line 2150 · raw
@bw:Bw -> @last:Bool -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
def ck_end source · line 2157 · raw
@st:Bk -> @last:Bool -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
def ck_go source · line 2162 · raw
@ht:In -> @+i0:U32 -> @+n:U32 -> @+cf:Cf -> @+last:Bool -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
the chunk's stream: the dictionary goes into the tables, the pass starts past it
def ck_run_at source · line 2168 · raw
@a:Array<U32> -> @+start:U32 -> @+n:U32 -> @+d:U32 -> @last:Bool -> @+cf:Cf -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
def ck_run source · line 2174 · raw
@ck:Ck -> @+cf:Cf -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
def par_tree source · line 2182 · raw
@t:Cq -> @+cf:Cf -> Parts
Bottom pairs fork ck_run directly. That gives the compiler a fork-free task to leave for the saturated work phase instead of compressing a leaf while the recursive par_tree task is still growing the frontier.
def lv_add source · line 2197 · raw
@r:Pair(Array<U32>, Array<U32>) -> @acc:List<&1, Cq> -> @+start:U32 -> @+n:U32 -> @+d:U32 -> @last:Bool -> Lv
def lv_list source · line 2201 · raw
@st:Lv -> List<&1, Cq>
def pair_node source · line 2207 · raw
@a:Cq -> @b:Cq -> Cq
neighbours paired up, until one tree is left
def pair_up source · line 2214 · raw
@l:List<&1, Cq> -> List<&1, Cq>
def pair_loop source · line 2223 · raw
@fuel:Nat -> @l:List<&1, Cq> -> @+count:U32 -> @single:Bool -> List<&1, Cq>
def tree_only source · line 2232 · raw
@t:List<&1, Cq> -> @h:Cq -> Cq
def tree_head source · line 2239 · raw
@l:List<&1, Cq> -> Cq
def batch_lv_loop source · line 2250 · raw
@m:Nat -> @st:Lv -> @+k:U32 -> @+count:U32 -> @+dict:U32 -> @+n:U32 -> @+final:Bool -> Lv
A bounded batch starts with dictionary bytes carried from the preceding batch, followed by four 248 KiB chunks per worker. At eight workers the input and worst-case output each stay near 8 MiB while the scheduler has enough jobs to balance files and compression ratios across workers.
def batch_chunks source · line 2261 · raw
@w:Array<U32> -> @+dict:U32 -> @+n:U32 -> @final:Bool -> Cq
def stored_bw source · line 2267 · raw
@r:Pair(Array<U32>, Bw) -> Bw
A compressed leaf already ends on a byte boundary. Keep the leaves separate so IO can write them in order without copying them into another Bend Array.
def deflate_batch_go source · line 2271 · raw
@w:Array<U32> -> @+dict:U32 -> @+n:U32 -> @+level:U32 -> @final:Bool -> @stored:Bool -> Parts
def compress source · line 2283 · raw
@w:Array<U32> -> @+dict:U32 -> @+n:U32 -> @+level:U32 -> @final:Bool -> Parts
the n bytes of w after its first dict bytes, which seed the matcher's window (32 KiB at most count), compressed at level 0-9 into a tree of Sinks that concatenate into one stream; final sets BFINAL on the last block, else the stream ends byte aligned so another can follow. w holds three spare zero words past dict + n.
def parts_list source · line 2286 · raw
@parts:Parts -> @rest:List<&1, 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink> -> List<&1, 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink>
def write_parts source · line 2293 · raw
@parts:List<&1, 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink> -> @+path:String -> @file:File -> IO(File)
def write source · line 2303 · raw
@parts:Parts -> @+path:String -> @file:File -> IO(File)
the parts, in order, to file