deflate.bend relies on unsafe/foreign
raw source on the hub · import gralha-deflate@0.1.0.0/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 865 · raw
Data
Tok@sym:U32 -> @ex:U32 -> @eb:U32 -> @ds:U32 -> @dx:U32 -> @db:U32 -> Tok
type Ts source · line 880 · 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 922 · raw
Data
Cf@good:U32 -> @lazy:U32 -> @nice:U32 -> @chain:U32 -> @slow:Bool -> Cf
type Mw source · line 942 · 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. 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 996 · raw
Type
the hash tables
In@w:Array<U32> -> @hd:Array<U32> -> @prev:Array<U32> -> In
type Ch source · line 1038 · raw
Type
the chain walk: the best length and distance so far, the input byte at the best length (read again only when the best changes), and the candidate to try; more says it is live, in the window, and worth trying
Ch@w:Array<U32> -> @prev:Array<U32> -> @head:U32 -> @bl:U32 -> @bd:U32 -> @x:U32 -> @cand:U32 -> @more:Bool -> Ch
type Lz source · line 1105 · 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 Sc source · line 1244 · raw
Type
the two lightest live nodes seen so far, 4294967295 for none
Sc@fq:Array<U32> -> @b1:U32 -> @f1:U32 -> @b2:U32 -> @f2:U32 -> Sc
type Mg source · line 1271 · raw
Type
the tree: node counts (0 once merged), parents, the node count; more says a merge happened
Mg@fq:Array<U32> -> @par:Array<U32> -> @cnt:U32 -> @more:Bool -> Mg
type Dp source · line 1302 · raw
Type
a leaf's depth: parents up to the root
Dp@par:Array<U32> -> @node:U32 -> @depth:U32 -> @more:Bool -> Dp
type Ln source · line 1330 · raw
Type
the lengths of the live leaves and the longest
Ln@f0:Array<U32> -> @par:Array<U32> -> @lens:Array<U32> -> @mx:U32 -> Ln
type Hc source · line 1357 · 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 1416 · 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 1449 · raw
Type
Nx@cnt:Array<U32> -> @next:Array<U32> -> Nx
type Cc source · line 1465 · raw
Type
codes[i] = next[len[i]]++ for live symbols
Cc@lens:Array<U32> -> @next:Array<U32> -> @codes:Array<U32> -> Cc
type Tb source · line 1497 · raw
Type
a code table: lengths and codes by symbol
Tb@lens:Array<U32> -> @codes:Array<U32> -> Tb
type Ew source · line 1519 · raw
Type
the writer with a table
Ew@bw:Bw -> @tb:Tb -> Ew
type Lx source · line 1543 · 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 1590 · 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 1644 · 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 1665 · 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 1700 · raw
Type
the code-length lengths, 3 bits each in cl_order
Hw@bw:Bw -> @a:Array<U32> -> Hw
type Em source · line 1748 · raw
Type
Em@bw:Bw -> @lit:Tb -> @dst:Tb -> @tk:Array<U32> -> Em
type Ct source · line 1793 · 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 1833 · raw
Type
the run-length tokens' cost under the code-length code
Cr@cl:Array<U32> -> @bits:U32 -> Cr
type Sb source · line 1864 · raw
Type
Sb@w:Array<U32> -> @bw:Bw -> Sb
type Bk source · line 2006 · raw
Type
Bk@lz:Lz -> @bw:Bw -> @fin:Bool -> Bk
type Ck source · line 2053 · raw
Type
Ck@a:Array<U32> -> @start:U32 -> @n:U32 -> @d:U32 -> @last:Bool -> Ck
type Cq source · line 2056 · raw
Type
CLeaf@ck:Ck -> Cq
CPair@l:Ck -> @r:Ck -> Cq
CNode@l:Cq -> @r:Cq -> Cq
type Parts source · line 2061 · raw
Type
OLeaf@ob:0x365c60316ea66a6c80658fc03b4eeac5/words.Sink -> Parts
ONode@l:Parts -> @r:Parts -> Parts
type Lv source · line 2113 · 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_code source · line 818 · raw
@st:Bw -> @+code:U32 -> @+k:U32 -> Bw
a Huffman code goes most significant bit first
def bw_last source · line 821 · raw
@ob:0x365c60316ea66a6c80658fc03b4eeac5/words.Sink -> @+buf:U32 -> @some:Bool -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
def bw_fin source · line 828 · raw
@st:Bw -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
def base_of source · line 834 · raw
@dist:Bool -> @+c:U32 -> U32
def extra_of source · line 841 · raw
@dist:Bool -> @+c:U32 -> U32
def code_of source · line 850 · raw
@n:Nat -> @+v:U32 -> @+c:U32 -> @stop:Bool -> @+dist:Bool -> U32
the code index for a length or a distance: the last base <= v; stop says the next base is already past v
def bump_put source · line 868 · raw
@r:Pair(Array<U32>, U32) -> @+i:U32 -> Array<U32>
def bump source · line 872 · raw
@a:Array<U32> -> @+i:U32 -> Array<U32>
def tk_w0 source · line 875 · raw
@+sym:U32 -> @+ex:U32 -> @+eb:U32 -> @+ds:U32 -> @+db:U32 -> U32
def ts_new source · line 883 · raw
Ts
def ts_put source · line 886 · raw
@tk:Array<U32> -> @+nt:U32 -> @+w0:U32 -> @+w1:U32 -> Array<U32>
def ts_lit source · line 890 · raw
@st:Ts -> @+b:U32 -> Pair(Ts, Bool)
a literal; the flag says the block is full
def ts_len source · line 896 · raw
@st:Ts -> @+len:U32 -> @+dist:U32 -> Pair(Ts, Bool)
def trev source · line 904 · raw
@l:List<&2, Tok> -> @acc:List<&2, Tok> -> List<&2, Tok>
def cf_of source · line 925 · raw
@+l:U32 -> Cf
def cf_slow source · line 932 · raw
@cf:Cf -> Bool
def mw_cmp source · line 945 · raw
@r:Pair(Array<U32>, U32) -> @+a:U32 -> @+b:U32 -> @+wa:U32 -> @+len:U32 -> @+maxlen:U32 -> Mw
def mw_b source · line 952 · raw
@r:Pair(Array<U32>, U32) -> @+a:U32 -> @+b:U32 -> @+len:U32 -> @+maxlen:U32 -> Mw
def mw_loop source · line 956 · raw
@fuel:Nat -> @st:Mw -> @+maxlen:U32 -> Mw
def mw_fin source · line 970 · raw
@st:Mw -> Pair(Array<U32>, U32)
def match_pick source · line 975 · raw
@w:Array<U32> -> @+i:U32 -> @+dist:U32 -> @+maxlen:U32 -> @+x:U32 -> @same:Bool -> Pair(Array<U32>, U32)
def match_head_b source · line 984 · raw
@r:Pair(Array<U32>, U32) -> @+head:U32 -> @+i:U32 -> @+dist:U32 -> @+maxlen:U32 -> Pair(Array<U32>, U32)
def match_at_head source · line 991 · raw
@w:Array<U32> -> @+head:U32 -> @+i:U32 -> @+dist:U32 -> @+n:U32 -> Pair(Array<U32>, U32)
the length of the match at i against i - dist, at most 258 and the bytes left. The current four-byte window is shared by the whole chain walk.
def in_hd source · line 999 · raw
@r:Pair(Array<U32>, U32) -> @w:Array<U32> -> @prev:Array<U32> -> @+j:U32 -> @+h:U32 -> Pair(In, U32)
def in_win source · line 1005 · raw
@r:Pair(Array<U32>, U32) -> @hd:Array<U32> -> @prev:Array<U32> -> @+j:U32 -> Pair(In, U32)
the hash of the three bytes at j, from one window
def ins_go source · line 1011 · raw
@w:Array<U32> -> @hd:Array<U32> -> @prev:Array<U32> -> @+j:U32 -> @ok:Bool -> Pair(In, U32)
def ins_at source · line 1020 · raw
@w:Array<U32> -> @hd:Array<U32> -> @prev:Array<U32> -> @+j:U32 -> @+n:U32 -> Pair(In, U32)
position j into the tables; answers the previous head (a position + 1, 0 for none), and 0 when fewer than 3 bytes remain
def ins_drop source · line 1023 · raw
@r:Pair(In, U32) -> In
def ins_loop source · line 1028 · raw
@fuel:Nat -> @st:In -> @+j:U32 -> @+n:U32 -> In
positions j.. into the tables
def ch_nx source · line 1041 · raw
@rp:Pair(Array<U32>, U32) -> @w:Array<U32> -> @+head:U32 -> @+bl:U32 -> @+bd:U32 -> @+x:U32 -> @+i:U32 -> @+nice:U32 -> @+left:U32 -> Ch
def ch_x source · line 1046 · raw
@r:Pair(Array<U32>, U32) -> @prev:Array<U32> -> @+head:U32 -> @+bl:U32 -> @+bd:U32 -> @+c:U32 -> @+i:U32 -> @+nice:U32 -> @+left:U32 -> Ch
def ch_upd source · line 1050 · raw
@w:Array<U32> -> @prev:Array<U32> -> @+head:U32 -> @+l:U32 -> @+bl:U32 -> @+bd:U32 -> @+c:U32 -> @+d:U32 -> @+i:U32 -> @+nice:U32 -> @+left:U32 -> @+x:U32 -> @better:Bool -> Ch
def ch_at source · line 1057 · raw
@r:Pair(Array<U32>, U32) -> @prev:Array<U32> -> @+head:U32 -> @+bl:U32 -> @+bd:U32 -> @+c:U32 -> @+d:U32 -> @+i:U32 -> @+nice:U32 -> @+left:U32 -> @+x:U32 -> Ch
def ch_go source · line 1064 · raw
@w:Array<U32> -> @prev:Array<U32> -> @+head:U32 -> @+bl:U32 -> @+bd:U32 -> @+c:U32 -> @+d:U32 -> @+i:U32 -> @+n:U32 -> @+nice:U32 -> @+left:U32 -> @+x:U32 -> @ok:Bool -> Ch
a candidate whose byte at the best length differs cannot do better: one compare there before the full one, as zlib does
def ch_q source · line 1071 · raw
@r:Pair(Array<U32>, U32) -> @prev:Array<U32> -> @+head:U32 -> @+bl:U32 -> @+bd:U32 -> @+c:U32 -> @+d:U32 -> @+i:U32 -> @+n:U32 -> @+nice:U32 -> @+left:U32 -> @+x:U32 -> Ch
def ch_loop source · line 1075 · raw
@fuel:Nat -> @st:Ch -> @+i:U32 -> @+n:U32 -> @+nice:U32 -> @+left:U32 -> Ch
def ch_start source · line 1088 · raw
@r:Pair(Array<U32>, U32) -> @prev:Array<U32> -> @+i:U32 -> @+n:U32 -> @+cand:U32 -> @+chain:U32 -> @+nice:U32 -> @search:Bool -> Ch
def chain source · line 1094 · raw
@w:Array<U32> -> @prev:Array<U32> -> @+i:U32 -> @+n:U32 -> @+cand:U32 -> @+chain:U32 -> @+nice:U32 -> @search:Bool -> Ch
the walk from head cand; search says it is wanted at all
def too_far source · line 1098 · raw
@+l:U32 -> @+d:U32 -> U32
a match of 3 farther than 4096 back costs more than its literals
def lz_of source · line 1108 · 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 1113 · 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 1119 · 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 1126 · raw
@ht:In -> @+i:U32 -> @+n:U32 -> @+cl:U32 -> @ins:Bool -> In
def fa_decide source · line 1133 · 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 1140 · raw
@ch:Ch -> @hd:Array<U32> -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+maxins:U32 -> Lz
def fa_ht source · line 1147 · raw
@ht:In -> @+cand:U32 -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+cf:Cf -> Lz
def fa_ins_at source · line 1152 · raw
@r:Pair(In, U32) -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+cf:Cf -> Lz
def fa_step source · line 1156 · raw
@st:Lz -> @+cf:Cf -> Lz
def ins_stride source · line 1168 · raw
@fuel:Nat -> @st:In -> @+j:U32 -> @+n:U32 -> In
def sl_insert source · line 1175 · raw
@ht:In -> @+i:U32 -> @+n:U32 -> @+pl:U32 -> @+maxins:U32 -> @insert:Bool -> In
def sl_decide source · line 1182 · 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 1191 · 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 1198 · raw
@ht:In -> @+cand:U32 -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+pl:U32 -> @+pd:U32 -> @pend:Bool -> @+cf:Cf -> Lz
def sl_ins_at source · line 1203 · raw
@r:Pair(In, U32) -> @ts:Ts -> @+i:U32 -> @+n:U32 -> @+pl:U32 -> @+pd:U32 -> @pend:Bool -> @+cf:Cf -> Lz
def sl_step source · line 1207 · raw
@st:Lz -> @+cf:Cf -> Lz
def lz_mode source · line 1214 · raw
@st:Lz -> @+cf:Cf -> @slow:Bool -> Lz
def lz_step source · line 1221 · raw
@st:Lz -> @+cf:Cf -> Lz
def lz_loop source · line 1225 · raw
@fuel:Nat -> @st:Lz -> @+cf:Cf -> Lz
until the block is full or the input done
def sc_take source · line 1247 · raw
@fq:Array<U32> -> @+j:U32 -> @+f:U32 -> @+b1:U32 -> @+f1:U32 -> @+b2:U32 -> @+f2:U32 -> @lt1:Bool -> @lt2:Bool -> Sc
def sc_at source · line 1256 · raw
@r:Pair(Array<U32>, U32) -> @+j:U32 -> @+b1:U32 -> @+f1:U32 -> @+b2:U32 -> @+f2:U32 -> Sc
def sc_loop source · line 1262 · raw
@n:Nat -> @st:Sc -> @+j:U32 -> Sc
def mg_do source · line 1274 · raw
@fq:Array<U32> -> @par:Array<U32> -> @+cnt:U32 -> @+b1:U32 -> @+f1:U32 -> @+b2:U32 -> @+f2:U32 -> @ok:Bool -> Mg
def mg_apply source · line 1281 · raw
@sc:Sc -> @par:Array<U32> -> @+cnt:U32 -> Mg
def mg_step source · line 1287 · raw
@fq:Array<U32> -> @par:Array<U32> -> @+cnt:U32 -> Mg
def mg_loop source · line 1290 · raw
@n:Nat -> @st:Mg -> Mg
def dp_at source · line 1305 · raw
@r:Pair(Array<U32>, U32) -> @+depth:U32 -> @+root:U32 -> Dp
def dp_loop source · line 1310 · raw
@n:Nat -> @st:Dp -> @+root:U32 -> Dp
def dp_pair source · line 1321 · raw
@st:Dp -> Pair(Array<U32>, U32)
def depth_of source · line 1326 · raw
@par:Array<U32> -> @+i:U32 -> @+root:U32 -> Pair(Array<U32>, U32)
def ln_put source · line 1333 · raw
@r:Pair(Array<U32>, U32) -> @f0:Array<U32> -> @lens:Array<U32> -> @+i:U32 -> @+mx:U32 -> Ln
def ln_go source · line 1338 · raw
@f0:Array<U32> -> @par:Array<U32> -> @lens:Array<U32> -> @+i:U32 -> @+root:U32 -> @+mx:U32 -> @live:Bool -> Ln
def ln_at source · line 1345 · raw
@rf:Pair(Array<U32>, U32) -> @par:Array<U32> -> @lens:Array<U32> -> @+i:U32 -> @+root:U32 -> @+mx:U32 -> Ln
def ln_loop source · line 1349 · raw
@n:Nat -> @st:Ln -> @+i:U32 -> @+root:U32 -> Ln
def hc_of source · line 1360 · raw
@ln:Ln -> @+limit:U32 -> Hc
def hc_ln source · line 1366 · raw
@mg:Mg -> @f0:Array<U32> -> @+n:U32 -> @+limit:U32 -> Hc
def gr_pair source · line 1371 · raw
@st:0x365c60316ea66a6c80658fc03b4eeac5/words.Gr -> Pair(Array<U32>, Array<U32>)
def hc_mg source · line 1376 · raw
@r:Pair(Array<U32>, Array<U32>) -> @+n:U32 -> @+limit:U32 -> Hc
def hc_once source · line 1380 · raw
@f0:Array<U32> -> @+n:U32 -> @+limit:U32 -> Hc
def hv_put source · line 1383 · raw
@r:Pair(Array<U32>, U32) -> @+i:U32 -> Array<U32>
def hv_loop source · line 1389 · raw
@n:Nat -> @a:Array<U32> -> @+i:U32 -> Array<U32>
counts halved, rounding up so live stays live
def hc_limit source · line 1396 · raw
@n:Nat -> @st:Hc -> @+sz:U32 -> @+limit:U32 -> Hc
def hc_lens source · line 1407 · raw
@st:Hc -> Array<U32>
def huff_lens source · line 1412 · raw
@f0:Array<U32> -> @+n:U32 -> @+limit:U32 -> Array<U32>
def nz_at source · line 1419 · raw
@r:Pair(Array<U32>, U32) -> @+c:U32 -> Nz
def nz_loop source · line 1423 · raw
@n:Nat -> @st:Nz -> @+i:U32 -> Nz
def nz_go source · line 1430 · raw
@a:Array<U32> -> @few:Bool -> Array<U32>
def nz_fix source · line 1437 · raw
@st:Nz -> Array<U32>
def two_live source · line 1442 · raw
@a:Array<U32> -> @+n:U32 -> Array<U32>
def nx_at source · line 1452 · raw
@rc:Pair(Array<U32>, U32) -> @next:Array<U32> -> @+l:U32 -> @+code:U32 -> Pair(Nx, U32)
def nx_loop source · line 1457 · raw
@n:Nat -> @st:Pair(Nx, U32) -> @+l:U32 -> Nx
def cc_skip source · line 1468 · raw
@lens:Array<U32> -> @codes:Array<U32> -> @ro:Pair(Array<U32>, U32) -> Cc
def cc_do source · line 1472 · raw
@lens:Array<U32> -> @+l:U32 -> @+i:U32 -> @codes:Array<U32> -> @ro:Pair(Array<U32>, U32) -> Cc
def cc_put source · line 1477 · raw
@lens:Array<U32> -> @+l:U32 -> @+i:U32 -> @codes:Array<U32> -> @ro:Pair(Array<U32>, U32) -> @live:Bool -> Cc
def cc_at source · line 1484 · raw
@rl:Pair(Array<U32>, U32) -> @next:Array<U32> -> @codes:Array<U32> -> @+i:U32 -> Cc
def cc_loop source · line 1489 · raw
@n:Nat -> @st:Cc -> @+i:U32 -> Cc
def cc_tb source · line 1500 · raw
@st:Cc -> Tb
def tb_nx source · line 1505 · raw
@st:Nx -> @lens:Array<U32> -> @+n:U32 -> Tb
def tb_cs source · line 1510 · raw
@st:Cs -> @+n:U32 -> Tb
def tb_of source · line 1515 · raw
@lens:Array<U32> -> @+n:U32 -> Tb
def tb_put source · line 1522 · raw
@r:Pair(Array<U32>, U32) -> @lens:Array<U32> -> @bw:Bw -> @+l:U32 -> Ew
def tb_at source · line 1526 · raw
@r:Pair(Array<U32>, U32) -> @codes:Array<U32> -> @bw:Bw -> @+sym:U32 -> Ew
def tb_code source · line 1531 · raw
@bw:Bw -> @tb:Tb -> @+sym:U32 -> Ew
def lx_at source · line 1546 · raw
@r:Pair(Array<U32>, U32) -> @+i:U32 -> @+last:U32 -> Lx
def lx_loop source · line 1550 · raw
@n:Nat -> @st:Lx -> @+i:U32 -> Lx
def lo_loop source · line 1558 · raw
@n:Nat -> @st:Lx -> @+i:U32 -> Lx
the same over cl_order, for HCLEN
def lx_of source · line 1565 · raw
@st:Lx -> @+lo:U32 -> Pair(Array<U32>, U32)
def used source · line 1571 · raw
@a:Array<U32> -> @+n:U32 -> @+lo:U32 -> Pair(Array<U32>, U32)
def used_ord source · line 1574 · raw
@a:Array<U32> -> @+lo:U32 -> Pair(Array<U32>, U32)
def ap_put source · line 1578 · raw
@r:Pair(Array<U32>, U32) -> @dst:Array<U32> -> @+i:U32 -> @+off:U32 -> Sp
dst[off + i] = src[i]
def ap_loop source · line 1582 · raw
@n:Nat -> @st:Sp -> @+i:U32 -> @+off:U32 -> Sp
def rpush source · line 1593 · raw
@st:Rt -> @+sym:U32 -> @+ex:U32 -> @+eb:U32 -> Rt
def zrun source · line 1601 · 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 1619 · 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 1633 · raw
@st:Rt -> @+l:U32 -> @+r:U32 -> @zero:Bool -> Rt
def run_emit source · line 1640 · raw
@st:Rt -> @+l:U32 -> @+r:U32 -> Rt
def rn_at source · line 1647 · raw
@rv:Pair(Array<U32>, U32) -> @+r:U32 -> @+i:U32 -> @+l:U32 -> @+total:U32 -> Rn
def rn_loop source · line 1652 · raw
@n:Nat -> @st:Rn -> @+i:U32 -> @+l:U32 -> @+total:U32 -> Rn
def re_of source · line 1668 · raw
@a:Array<U32> -> @rt:Rt -> @+i:U32 -> @+total:U32 -> Re
def re_run source · line 1673 · raw
@rn:Rn -> @toks:List<&2, Tok> -> @fc:Array<U32> -> @+i:U32 -> @+l:U32 -> @+total:U32 -> Re
def re_at source · line 1679 · raw
@r:Pair(Array<U32>, U32) -> @toks:List<&2, Tok> -> @fc:Array<U32> -> @+i:U32 -> @+total:U32 -> Re
def re_loop source · line 1684 · raw
@n:Nat -> @st:Re -> @+total:U32 -> Re
def hw_put source · line 1703 · raw
@r:Pair(Array<U32>, U32) -> @bw:Bw -> Hw
def hw_loop source · line 1707 · raw
@n:Nat -> @st:Hw -> @+k:U32 -> Hw
def ec_ex source · line 1714 · raw
@st:Ew -> @+ex:U32 -> @+eb:U32 -> Ew
def ec_tok source · line 1719 · raw
@t:Tok -> @st:Ew -> Ew
def ec_loop source · line 1724 · raw
@toks:List<&2, Tok> -> @st:Ew -> Ew
def bw_byte source · line 1736 · raw
@st:Bw -> @+b:U32 -> Bw
def bw_align source · line 1742 · raw
@st:Bw -> Bw
zeros to the next byte boundary
def em_dist source · line 1751 · raw
@st:Ew -> @lit:Tb -> @+dx:U32 -> @+db:U32 -> @tk:Array<U32> -> Em
def em_len source · line 1756 · raw
@st:Ew -> @dst:Tb -> @+ds:U32 -> @+dx:U32 -> @+db:U32 -> @tk:Array<U32> -> @islen:Bool -> Em
def em_tok source · line 1763 · raw
@+w0:U32 -> @+w1:U32 -> @bw:Bw -> @lit:Tb -> @dst:Tb -> @tk:Array<U32> -> Em
def em_w1 source · line 1767 · raw
@r:Pair(Array<U32>, U32) -> @bw:Bw -> @lit:Tb -> @dst:Tb -> @+w0:U32 -> Em
def em_w0 source · line 1771 · raw
@r:Pair(Array<U32>, U32) -> @bw:Bw -> @lit:Tb -> @dst:Tb -> @+j:U32 -> Em
def em_loop source · line 1775 · raw
@k:Nat -> @st:Em -> @+j:U32 -> Em
def em_fin source · line 1782 · raw
@st:Ew -> Bw
def em_eob source · line 1787 · raw
@st:Em -> Bw
def ct_dl source · line 1796 · raw
@r:Pair(Array<U32>, U32) -> @tk:Array<U32> -> @ll:Array<U32> -> @+bits:U32 -> @+db:U32 -> Ct
def ct_len source · line 1800 · raw
@tk:Array<U32> -> @ll:Array<U32> -> @dl:Array<U32> -> @+bits:U32 -> @+ds:U32 -> @+db:U32 -> @islen:Bool -> Ct
def ct_ll source · line 1807 · raw
@r:Pair(Array<U32>, U32) -> @tk:Array<U32> -> @dl:Array<U32> -> @+bits:U32 -> @+w0:U32 -> Ct
def ct_w0 source · line 1811 · raw
@r:Pair(Array<U32>, U32) -> @ll:Array<U32> -> @dl:Array<U32> -> @+bits:U32 -> Ct
def ct_loop source · line 1816 · raw
@k:Nat -> @st:Ct -> @+j:U32 -> Ct
def ct_swap source · line 1823 · raw
@r:Pair(Array<U32>, U32) -> @tk:Array<U32> -> @dl:Array<U32> -> @+bits:U32 -> @+db:U32 -> Ct
def ct_eob source · line 1827 · raw
@st:Ct -> Ct
def cr_at source · line 1836 · raw
@r:Pair(Array<U32>, U32) -> @+bits:U32 -> @+eb:U32 -> Cr
def cr_tok source · line 1840 · raw
@t:Tok -> @cl:Array<U32> -> @+bits:U32 -> Cr
def cr_loop source · line 1845 · raw
@l:List<&2, Tok> -> @st:Cr -> Cr
def cr_of source · line 1852 · raw
@st:Cr -> Pair(Array<U32>, U32)
def sb_put source · line 1867 · raw
@r:Pair(Array<U32>, U32) -> @bw:Bw -> Sb
def sb_copy source · line 1871 · raw
@n:Nat -> @st:Sb -> @+j:U32 -> Sb
def sb_word source · line 1878 · raw
@r:Pair(Array<U32>, U32) -> @bw:Bw -> Sb
def sb_words source · line 1884 · raw
@n:Nat -> @st:Sb -> @+j:U32 -> Sb
def sb_fast source · line 1891 · raw
@+len:U32 -> @st:Sb -> @+j:U32 -> Sb
def bw_reserve source · line 1894 · raw
@st:Bw -> @+n:U32 -> Bw
def sb_head source · line 1899 · raw
@st:Sb -> @+len:U32 -> @final:Bool -> Sb
def sb_loop source · line 1905 · raw
@m:Nat -> @st:Sb -> @+k:U32 -> @+start:U32 -> @+cov:U32 -> @+count:U32 -> @+final:Bool -> Sb
def sb_pair source · line 1914 · raw
@st:Sb -> Pair(Array<U32>, Bw)
def stored_out source · line 1919 · raw
@w:Array<U32> -> @bw:Bw -> @+start:U32 -> @+cov:U32 -> @final:Bool -> Pair(Array<U32>, Bw)
def df_9 source · line 1928 · raw
@bw:Bw -> @w:Array<U32> -> Pair(Array<U32>, Bw)
def df_8 source · line 1931 · raw
@tk:Array<U32> -> @+nt:U32 -> @lit:Tb -> @dst:Tb -> @ew:Ew -> @w:Array<U32> -> Pair(Array<U32>, Bw)
def df_7 source · line 1936 · 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 1942 · 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 1945 · 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 1952 · 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 1959 · 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 1964 · 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 1970 · 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 1975 · 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 1980 · 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 1987 · 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 1994 · raw
@ts:Ts -> @bw:Bw -> @w:Array<U32> -> @+iend:U32 -> @final:Bool -> Pair(Array<U32>, Bw)
def bk_next source · line 2009 · 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 2013 · raw
@st:Lz -> @bw:Bw -> @+last:Bool -> Bk
def bk_loop source · line 2021 · raw
@fuel:Nat -> @st:Bk -> @+cf:Cf -> @+last:Bool -> Bk
def lz_drop source · line 2032 · raw
@lz:Lz -> @bw:Bw -> Bw
def bk_bw source · line 2037 · raw
@st:Bk -> Bw
def stored_empty source · line 2066 · raw
@bw:Bw -> Bw
an empty stored block: BFINAL 0, BTYPE 00, zeros to the byte, 0, 65535
def ck_fin source · line 2069 · raw
@bw:Bw -> @last:Bool -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
def ck_end source · line 2076 · raw
@st:Bk -> @last:Bool -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
def ck_go source · line 2081 · 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 2087 · raw
@a:Array<U32> -> @+start:U32 -> @+n:U32 -> @+d:U32 -> @last:Bool -> @+cf:Cf -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
def ck_run source · line 2093 · raw
@ck:Ck -> @+cf:Cf -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink
def par_tree source · line 2101 · 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 2116 · 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 2120 · raw
@st:Lv -> List<&1, Cq>
def pair_node source · line 2126 · raw
@a:Cq -> @b:Cq -> Cq
neighbours paired up, until one tree is left
def pair_up source · line 2133 · raw
@l:List<&1, Cq> -> List<&1, Cq>
def pair_loop source · line 2142 · raw
@fuel:Nat -> @l:List<&1, Cq> -> @+count:U32 -> @single:Bool -> List<&1, Cq>
def tree_only source · line 2151 · raw
@t:List<&1, Cq> -> @h:Cq -> Cq
def tree_head source · line 2158 · raw
@l:List<&1, Cq> -> Cq
def batch_lv_loop source · line 2169 · 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 2180 · raw
@w:Array<U32> -> @+dict:U32 -> @+n:U32 -> @final:Bool -> Cq
def stored_bw source · line 2186 · 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 2190 · raw
@w:Array<U32> -> @+dict:U32 -> @+n:U32 -> @+level:U32 -> @final:Bool -> @stored:Bool -> Parts
def compress source · line 2202 · 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 2205 · raw
@parts:Parts -> @rest:List<&1, 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink> -> List<&1, 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink>
def write_parts source · line 2212 · raw
@parts:List<&1, 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink> -> @+path:String -> @file:File -> IO(File)
def write source · line 2222 · raw
@parts:Parts -> @+path:String -> @file:File -> IO(File)
the parts, in order, to file