From 28a54baa19a01b3b616f9becf2ab9af17f8e4ccf Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 15 Aug 2021 08:30:13 +1000 Subject: [PATCH] Add io_bind history_position arg --- internal/cgen/base/io-private.h | 10 ++++---- internal/cgen/data/data.go | 6 ++--- internal/cgen/liveness.go | 5 ++++ internal/cgen/statement.go | 4 ++++ lang/ast/ast.go | 19 ++++++++------- lang/check/bounds.go | 5 ++++ lang/check/type.go | 10 ++++++++ lang/parse/parse.go | 32 +++++++++++++++++++++++++- release/c/wuffs-unsupported-snapshot.c | 16 ++++++++----- std/gif/decode_gif.wuffs | 2 +- std/png/decode_png.wuffs | 2 +- 11 files changed, 87 insertions(+), 24 deletions(-) diff --git a/internal/cgen/base/io-private.h b/internal/cgen/base/io-private.h index c275fee5..5c63b268 100644 --- a/internal/cgen/base/io-private.h +++ b/internal/cgen/base/io-private.h @@ -117,11 +117,12 @@ wuffs_base__io_reader__set(wuffs_base__io_buffer* b, const uint8_t** ptr_io0_r, const uint8_t** ptr_io1_r, const uint8_t** ptr_io2_r, - wuffs_base__slice_u8 data) { + wuffs_base__slice_u8 data, + uint64_t history_position) { b->data = data; b->meta.wi = data.len; b->meta.ri = 0; - b->meta.pos = 0; + b->meta.pos = history_position; b->meta.closed = false; *ptr_iop_r = data.ptr; @@ -355,11 +356,12 @@ wuffs_base__io_writer__set(wuffs_base__io_buffer* b, uint8_t** ptr_io0_w, uint8_t** ptr_io1_w, uint8_t** ptr_io2_w, - wuffs_base__slice_u8 data) { + wuffs_base__slice_u8 data, + uint64_t history_position) { b->data = data; b->meta.wi = 0; b->meta.ri = 0; - b->meta.pos = 0; + b->meta.pos = history_position; b->meta.closed = false; *ptr_iop_w = data.ptr; diff --git a/internal/cgen/data/data.go b/internal/cgen/data/data.go index e9b14a20..01fe95f9 100644 --- a/internal/cgen/data/data.go +++ b/internal/cgen/data/data.go @@ -223,7 +223,7 @@ const BaseIOPrivateH = "" + "" + "// --------\n\nstatic inline void //\nwuffs_base__io_reader__limit(const uint8_t** ptr_io2_r,\n const uint8_t* iop_r,\n uint64_t limit) {\n if (((uint64_t)(*ptr_io2_r - iop_r)) > limit) {\n *ptr_io2_r = iop_r + limit;\n }\n}\n\nstatic inline uint32_t //\nwuffs_base__io_reader__limited_copy_u32_to_slice(const uint8_t** ptr_iop_r,\n const uint8_t* io2_r,\n uint32_t length,\n wuffs_base__slice_u8 dst) {\n const uint8_t* iop_r = *ptr_iop_r;\n size_t n = dst.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(io2_r - iop_r))) {\n n = (size_t)(io2_r - iop_r);\n }\n if (n > 0) {\n memmove(dst.ptr, iop_r, n);\n *ptr_iop_r += n;\n }\n return (uint32_t)(n);\n}\n\n// wuffs_base__io_reader__match7 returns whether the io_reader's upcoming bytes\n// start with the given prefix (up to 7 bytes long). It is peek-like, not\n" + "// read-like, in that there are no side-effects.\n//\n// The low 3 bits of a hold the prefix length, n.\n//\n// The high 56 bits of a hold the prefix itself, in little-endian order. The\n// first prefix byte is in bits 8..=15, the second prefix byte is in bits\n// 16..=23, etc. The high (8 * (7 - n)) bits are ignored.\n//\n// There are three possible return values:\n// - 0 means success.\n// - 1 means inconclusive, equivalent to \"$short read\".\n// - 2 means failure.\nstatic inline uint32_t //\nwuffs_base__io_reader__match7(const uint8_t* iop_r,\n const uint8_t* io2_r,\n wuffs_base__io_buffer* r,\n uint64_t a) {\n uint32_t n = a & 7;\n a >>= 8;\n if ((io2_r - iop_r) >= 8) {\n uint64_t x = wuffs_base__peek_u64le__no_bounds_check(iop_r);\n uint32_t shift = 8 * (8 - n);\n return ((a << shift) == (x << shift)) ? 0 : 2;\n }\n for (; n > 0; n--) {\n if (iop_r >= io2_r) {\n return (r && r->meta.closed) ? 2 : 1;\n } else if (*iop_" + - "r != ((uint8_t)(a))) {\n return 2;\n }\n iop_r++;\n a >>= 8;\n }\n return 0;\n}\n\nstatic inline wuffs_base__io_buffer* //\nwuffs_base__io_reader__set(wuffs_base__io_buffer* b,\n const uint8_t** ptr_iop_r,\n const uint8_t** ptr_io0_r,\n const uint8_t** ptr_io1_r,\n const uint8_t** ptr_io2_r,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = data.len;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n *ptr_iop_r = data.ptr;\n *ptr_io0_r = data.ptr;\n *ptr_io1_r = data.ptr;\n *ptr_io2_r = data.ptr + data.len;\n\n return b;\n}\n\n" + + "r != ((uint8_t)(a))) {\n return 2;\n }\n iop_r++;\n a >>= 8;\n }\n return 0;\n}\n\nstatic inline wuffs_base__io_buffer* //\nwuffs_base__io_reader__set(wuffs_base__io_buffer* b,\n const uint8_t** ptr_iop_r,\n const uint8_t** ptr_io0_r,\n const uint8_t** ptr_io1_r,\n const uint8_t** ptr_io2_r,\n wuffs_base__slice_u8 data,\n uint64_t history_position) {\n b->data = data;\n b->meta.wi = data.len;\n b->meta.ri = 0;\n b->meta.pos = history_position;\n b->meta.closed = false;\n\n *ptr_iop_r = data.ptr;\n *ptr_io0_r = data.ptr;\n *ptr_io1_r = data.ptr;\n *ptr_io2_r = data.ptr + data.len;\n\n return b;\n}\n\n" + "" + "// --------\n\nstatic inline uint64_t //\nwuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io2_w,\n wuffs_base__slice_u8 src) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > ((size_t)(io2_w - iop_w))) {\n n = (size_t)(io2_w - iop_w);\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += n;\n }\n return (uint64_t)(n);\n}\n\nstatic inline void //\nwuffs_base__io_writer__limit(uint8_t** ptr_io2_w,\n uint8_t* iop_w,\n uint64_t limit) {\n if (((uint64_t)(*ptr_io2_w - iop_w)) > limit) {\n *ptr_io2_w = iop_w + limit;\n }\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__limited_copy_u32_from_history(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint8_t* io2_w,\n uint32_t length,\n " + " uint32_t distance) {\n if (!distance) {\n return 0;\n }\n uint8_t* p = *ptr_iop_w;\n if ((size_t)(p - io1_w) < (size_t)(distance)) {\n return 0;\n }\n uint8_t* q = p - distance;\n size_t n = (size_t)(io2_w - p);\n if ((size_t)(length) > n) {\n length = (uint32_t)(n);\n } else {\n n = (size_t)(length);\n }\n // TODO: unrolling by 3 seems best for the std/deflate benchmarks, but that\n // is mostly because 3 is the minimum length for the deflate format. This\n // function implementation shouldn't overfit to that one format. Perhaps the\n // limited_copy_u32_from_history Wuffs method should also take an unroll hint\n // argument, and the cgen can look if that argument is the constant\n // expression '3'.\n //\n // See also wuffs_base__io_writer__limited_copy_u32_from_history_fast below.\n for (; n >= 3; n -= 3) {\n *p++ = *q++;\n *p++ = *q++;\n *p++ = *q++;\n }\n for (; n; n--) {\n *p++ = *q++;\n }\n *ptr_iop_w = p;\n return length;\n}\n\n// wuffs_base__io_w" + @@ -231,8 +231,8 @@ const BaseIOPrivateH = "" + "ance_1_fast\n// copies the previous byte (the one immediately before *ptr_iop_w), copying 8\n// byte chunks at a time. Each chunk contains 8 repetitions of the same byte.\n//\n// In terms of number of bytes copied, length is rounded up to a multiple of 8.\n// As a special case, a zero length rounds up to 8 (even though 0 is already a\n// multiple of 8), since there is always at least one 8 byte chunk copied.\n//\n// In terms of advancing *ptr_iop_w, length is not rounded up.\n//\n// The caller needs to prove that:\n// - (length + 8) <= (io2_w - *ptr_iop_w)\n// - distance == 1\n// - distance <= (*ptr_iop_w - io1_w)\nstatic inline uint32_t //\nwuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_distance_1_fast(\n uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint8_t* io2_w,\n uint32_t length,\n uint32_t distance) {\n uint8_t* p = *ptr_iop_w;\n uint64_t x = p[-1];\n x |= x << 8;\n x |= x << 16;\n x |= x << 32;\n uint32_t n = length;\n while (1) {\n wuffs_base__poke_u64le__no_bounds_check(" + "p, x);\n if (n <= 8) {\n p += n;\n break;\n }\n p += 8;\n n -= 8;\n }\n *ptr_iop_w = p;\n return length;\n}\n\n// wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_fast is\n// like the wuffs_base__io_writer__limited_copy_u32_from_history_fast function\n// above, but copies 8 byte chunks at a time.\n//\n// In terms of number of bytes copied, length is rounded up to a multiple of 8.\n// As a special case, a zero length rounds up to 8 (even though 0 is already a\n// multiple of 8), since there is always at least one 8 byte chunk copied.\n//\n// In terms of advancing *ptr_iop_w, length is not rounded up.\n//\n// The caller needs to prove that:\n// - (length + 8) <= (io2_w - *ptr_iop_w)\n// - distance >= 8\n// - distance <= (*ptr_iop_w - io1_w)\nstatic inline uint32_t //\nwuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_fast(\n uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint8_t* io2_w,\n uint32_t length,\n uint32_t distance) {\n uint8_t* p = *ptr_iop_w;\n u" + "int8_t* q = p - distance;\n uint32_t n = length;\n while (1) {\n memcpy(p, q, 8);\n if (n <= 8) {\n p += n;\n break;\n }\n p += 8;\n q += 8;\n n -= 8;\n }\n *ptr_iop_w = p;\n return length;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__limited_copy_u32_from_reader(uint8_t** ptr_iop_w,\n uint8_t* io2_w,\n uint32_t length,\n const uint8_t** ptr_iop_r,\n const uint8_t* io2_r) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = length;\n if (n > ((size_t)(io2_w - iop_w))) {\n n = (size_t)(io2_w - iop_w);\n }\n const uint8_t* iop_r = *ptr_iop_r;\n if (n > ((size_t)(io2_r - iop_r))) {\n n = (size_t)(io2_r - iop_r);\n }\n if (n > 0) {\n memmove(iop_w, iop_r, n);\n *ptr_iop_w += n;\n *ptr_iop_r += n;\n }\n return (uint32_t)(n);\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__limited_co" + - "py_u32_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io2_w,\n uint32_t length,\n wuffs_base__slice_u8 src) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(io2_w - iop_w))) {\n n = (size_t)(io2_w - iop_w);\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += n;\n }\n return (uint32_t)(n);\n}\n\nstatic inline wuffs_base__io_buffer* //\nwuffs_base__io_writer__set(wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_w,\n uint8_t** ptr_io0_w,\n uint8_t** ptr_io1_w,\n uint8_t** ptr_io2_w,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = 0;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n *ptr_iop_w = data.ptr;\n *ptr_io0_w = data.ptr;\n *ptr_io1_" + - "w = data.ptr;\n *ptr_io2_w = data.ptr + data.len;\n\n return b;\n}\n\n" + + "py_u32_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io2_w,\n uint32_t length,\n wuffs_base__slice_u8 src) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(io2_w - iop_w))) {\n n = (size_t)(io2_w - iop_w);\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += n;\n }\n return (uint32_t)(n);\n}\n\nstatic inline wuffs_base__io_buffer* //\nwuffs_base__io_writer__set(wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_w,\n uint8_t** ptr_io0_w,\n uint8_t** ptr_io1_w,\n uint8_t** ptr_io2_w,\n wuffs_base__slice_u8 data,\n uint64_t history_position) {\n b->data = data;\n b->meta.wi = 0;\n b->meta.ri = 0;\n b->meta.pos = history_position;\n b->meta.closed = " + + "false;\n\n *ptr_iop_w = data.ptr;\n *ptr_io0_w = data.ptr;\n *ptr_io1_w = data.ptr;\n *ptr_io2_w = data.ptr + data.len;\n\n return b;\n}\n\n" + "" + "// ---------------- I/O (Utility)\n\n#define wuffs_base__utility__empty_io_reader wuffs_base__empty_io_reader\n#define wuffs_base__utility__empty_io_writer wuffs_base__empty_io_writer\n" + "" diff --git a/internal/cgen/liveness.go b/internal/cgen/liveness.go index 1f77c77d..0247607b 100644 --- a/internal/cgen/liveness.go +++ b/internal/cgen/liveness.go @@ -331,6 +331,11 @@ func (h *livenessHelper) doIOBind(r livenesses, n *a.IOBind, depth uint32) error if err := h.doExpr(r, n.Arg1()); err != nil { return err } + if histPos := n.HistoryPosition(); histPos != nil { + if err := h.doExpr(r, n.HistoryPosition()); err != nil { + return err + } + } return h.doBlock(r, n.Body(), depth) } diff --git a/internal/cgen/statement.go b/internal/cgen/statement.go index d843a384..283c8795 100644 --- a/internal/cgen/statement.go +++ b/internal/cgen/statement.go @@ -343,6 +343,10 @@ func (g *gen) writeStatementIOBind(b *buffer, n *a.IOBind, depth uint32) error { if err := g.writeExpr(b, n.Arg1(), false, 0); err != nil { return err } + b.writes(",\n") + if err := g.writeExpr(b, n.HistoryPosition(), false, 0); err != nil { + return err + } b.writes(");\n") } else { diff --git a/lang/ast/ast.go b/lang/ast/ast.go index 39665f8b..8512e49d 100644 --- a/lang/ast/ast.go +++ b/lang/ast/ast.go @@ -583,26 +583,29 @@ func NewField(flags Flags, name t.ID, xType *TypeExpr) *Field { } } -// IOBind is "io_bind (io:LHS, data:MHS) { List2 }" or "io_limit (io:LHS, -// limit:MHS) { List2 }": +// IOBind is "io_bind (io:LHS, data:MHS, history_position:RHS) { List2 }" or +// "io_limit (io:LHS, limit:MHS) { List2 }": // - ID0: // - LHS: // - MHS: +// - RHS: // - List2: body type IOBind Node -func (n *IOBind) AsNode() *Node { return (*Node)(n) } -func (n *IOBind) Keyword() t.ID { return n.id0 } -func (n *IOBind) IO() *Expr { return n.lhs.AsExpr() } -func (n *IOBind) Arg1() *Expr { return n.mhs.AsExpr() } -func (n *IOBind) Body() []*Node { return n.list2 } +func (n *IOBind) AsNode() *Node { return (*Node)(n) } +func (n *IOBind) Keyword() t.ID { return n.id0 } +func (n *IOBind) IO() *Expr { return n.lhs.AsExpr() } +func (n *IOBind) Arg1() *Expr { return n.mhs.AsExpr() } +func (n *IOBind) HistoryPosition() *Expr { return n.rhs.AsExpr() } +func (n *IOBind) Body() []*Node { return n.list2 } -func NewIOBind(keyword t.ID, io *Expr, arg1 *Expr, body []*Node) *IOBind { +func NewIOBind(keyword t.ID, io *Expr, arg1 *Expr, historyPosition *Expr, body []*Node) *IOBind { return &IOBind{ kind: KIOBind, id0: keyword, lhs: io.AsNode(), mhs: arg1.AsNode(), + rhs: historyPosition.AsNode(), list2: body, } } diff --git a/lang/check/bounds.go b/lang/check/bounds.go index 390f33b1..4806066f 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -258,6 +258,11 @@ func (q *checker) bcheckStatement(n *a.Node) error { if _, err := q.bcheckExpr(n.Arg1(), 0); err != nil { return err } + if histPos := n.HistoryPosition(); histPos != nil { + if _, err := q.bcheckExpr(histPos, 0); err != nil { + return err + } + } if err := q.bcheckBlock(n.Body()); err != nil { return err } diff --git a/lang/check/type.go b/lang/check/type.go index d515bc1f..31153886 100644 --- a/lang/check/type.go +++ b/lang/check/type.go @@ -171,6 +171,16 @@ func (q *checker) tcheckStatement(n *a.Node) error { n.Keyword().Str(q.tm), n.Arg1().Str(q.tm), typ.Str(q.tm), arg1Typ.Str(q.tm)) } + if n.Keyword() == t.IDIOBind { + if err := q.tcheckExpr(n.HistoryPosition(), 0); err != nil { + return err + } + if typ := n.HistoryPosition().MType(); !typ.IsIdeal() && !typ.EqIgnoringRefinements(typeExprU64) { + return fmt.Errorf("check: %s expression %q, of type %q, does not have type %q", + n.Keyword().Str(q.tm), n.HistoryPosition().Str(q.tm), typ.Str(q.tm), typeExprU64.Str(q.tm)) + } + } + for _, o := range n.Body() { // TODO: prohibit jumps (breaks, continues), rets (returns, yields) // and retry-calling ? methods while inside an io_bind body. diff --git a/lang/parse/parse.go b/lang/parse/parse.go index 5e3a0195..c99fe101 100644 --- a/lang/parse/parse.go +++ b/lang/parse/parse.go @@ -1123,6 +1123,36 @@ func (p *parser) parseIOBindNode() (*a.Node, error) { io.Str(p.tm), p.filename, p.line()) } + histPos := (*a.Expr)(nil) + if keyword == t.IDIOBind { + if x := p.peek1(); x != t.IDComma { + got := p.tm.ByID(x) + return nil, fmt.Errorf(`parse: expected ",", got %q at %s:%d`, got, p.filename, p.line()) + } + p.src = p.src[1:] + + if x := p.peek1(); x != t.IDHistoryPosition { + got := p.tm.ByID(x) + return nil, fmt.Errorf(`parse: expected "history_position", got %q at %s:%d`, got, p.filename, p.line()) + } + p.src = p.src[1:] + + if x := p.peek1(); x != t.IDColon { + got := p.tm.ByID(x) + return nil, fmt.Errorf(`parse: expected ":", got %q at %s:%d`, got, p.filename, p.line()) + } + p.src = p.src[1:] + + histPos, err = p.parseExpr() + if err != nil { + return nil, err + } + if histPos.Effect() != 0 { + return nil, fmt.Errorf(`parse: argument %q is not effect-free at %s:%d`, + io.Str(p.tm), p.filename, p.line()) + } + } + if x := p.peek1(); x != t.IDCloseParen { got := p.tm.ByID(x) return nil, fmt.Errorf(`parse: expected ")", got %q at %s:%d`, got, p.filename, p.line()) @@ -1134,7 +1164,7 @@ func (p *parser) parseIOBindNode() (*a.Node, error) { return nil, err } - return a.NewIOBind(keyword, io, arg1, body).AsNode(), nil + return a.NewIOBind(keyword, io, arg1, histPos, body).AsNode(), nil } func (p *parser) parseIf() (*a.If, error) { diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 11d5e6dd..b2deb118 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -10463,11 +10463,12 @@ wuffs_base__io_reader__set(wuffs_base__io_buffer* b, const uint8_t** ptr_io0_r, const uint8_t** ptr_io1_r, const uint8_t** ptr_io2_r, - wuffs_base__slice_u8 data) { + wuffs_base__slice_u8 data, + uint64_t history_position) { b->data = data; b->meta.wi = data.len; b->meta.ri = 0; - b->meta.pos = 0; + b->meta.pos = history_position; b->meta.closed = false; *ptr_iop_r = data.ptr; @@ -10701,11 +10702,12 @@ wuffs_base__io_writer__set(wuffs_base__io_buffer* b, uint8_t** ptr_io0_w, uint8_t** ptr_io1_w, uint8_t** ptr_io2_w, - wuffs_base__slice_u8 data) { + wuffs_base__slice_u8 data, + uint64_t history_position) { b->data = data; b->meta.wi = 0; b->meta.ri = 0; - b->meta.pos = 0; + b->meta.pos = history_position; b->meta.closed = false; *ptr_iop_w = data.ptr; @@ -30518,7 +30520,8 @@ wuffs_gif__decoder__decode_id_part2( wuffs_base__slice_u8__subslice_ij(wuffs_base__make_slice_u8(self->private_data.f_compressed, 4096), self->private_impl.f_compressed_ri, - self->private_impl.f_compressed_wi)); + self->private_impl.f_compressed_wi), + 0); v_mark = ((uint64_t)(iop_v_r - io0_v_r)); { u_r.meta.ri = ((size_t)(iop_v_r - u_r.data.ptr)); @@ -37792,7 +37795,8 @@ wuffs_png__decoder__decode_pass( &io2_v_w, wuffs_base__slice_u8__subslice_ij(a_workbuf, self->private_impl.f_workbuf_wi, - self->private_impl.f_pass_workbuf_length)); + self->private_impl.f_pass_workbuf_length), + self->private_impl.f_workbuf_wi); { const uint8_t *o_1_io2_a_src = io2_a_src; wuffs_base__io_reader__limit(&io2_a_src, iop_a_src, diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs index 2c8cce14..0adb79e1 100644 --- a/std/gif/decode_gif.wuffs +++ b/std/gif/decode_gif.wuffs @@ -929,7 +929,7 @@ pri func decoder.decode_id_part2?(dst: ptr base.pixel_buffer, src: base.io_reade if (this.compressed_ri > this.compressed_wi) or (this.compressed_wi > 4096) { return "#internal error: inconsistent ri/wi" } - io_bind (io: r, data: this.compressed[this.compressed_ri .. this.compressed_wi]) { + io_bind (io: r, data: this.compressed[this.compressed_ri .. this.compressed_wi], history_position: 0) { mark = r.mark() lzw_status =? this.lzw.transform_io?( dst: this.util.empty_io_writer(), src: r, workbuf: this.util.empty_slice_u8()) diff --git a/std/png/decode_png.wuffs b/std/png/decode_png.wuffs index 41680d19..8882311e 100644 --- a/std/png/decode_png.wuffs +++ b/std/png/decode_png.wuffs @@ -574,7 +574,7 @@ pri func decoder.decode_pass?(src: base.io_reader, workbuf: slice base.u8) { this.pass_workbuf_length > args.workbuf.length()) { return base."#bad workbuf length" } - io_bind (io: w, data: args.workbuf[this.workbuf_wi .. this.pass_workbuf_length]) { + io_bind (io: w, data: args.workbuf[this.workbuf_wi .. this.pass_workbuf_length], history_position: this.workbuf_wi) { io_limit (io: args.src, limit: this.chunk_length) { w_mark = w.mark() r_mark = args.src.mark()