From 09ed091fe3bf6a2faf2027847b788b7156c5f8af Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Thu, 16 Jan 2020 22:07:44 +1100 Subject: [PATCH] Rename skip / copy_n_etc to skip32 / copy_n32_etc --- internal/cgen/base/io-private.h | 53 ++++++++++---------- internal/cgen/builtin.go | 18 +++---- internal/cgen/data.go | 12 ++--- lang/builtin/builtin.go | 12 ++--- lang/check/bounds.go | 8 +-- lang/token/list.go | 28 +++++------ release/c/wuffs-unsupported-snapshot.c | 67 +++++++++++++------------- std/deflate/decode_deflate.wuffs | 2 +- std/deflate/decode_huffman_fast.wuffs | 30 ++++++------ std/deflate/decode_huffman_slow.wuffs | 6 +-- std/gif/decode_gif.wuffs | 24 ++++----- std/gzip/decode_gzip.wuffs | 6 +-- std/lzw/decode_lzw.wuffs | 6 +-- std/wbmp/decode_wbmp.wuffs | 2 +- 14 files changed, 138 insertions(+), 136 deletions(-) diff --git a/internal/cgen/base/io-private.h b/internal/cgen/base/io-private.h index 419ae577..83e8f892 100644 --- a/internal/cgen/base/io-private.h +++ b/internal/cgen/base/io-private.h @@ -33,11 +33,11 @@ wuffs_base__io__since(uint64_t mark, uint64_t index, uint8_t* ptr) { } static inline uint32_t // -wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_iop_w, - uint8_t* io1_w, - uint8_t* io2_w, - uint32_t length, - uint32_t distance) { +wuffs_base__io_writer__copy_n32_from_history(uint8_t** ptr_iop_w, + uint8_t* io1_w, + uint8_t* io2_w, + uint32_t length, + uint32_t distance) { if (!distance) { return 0; } @@ -55,12 +55,13 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_iop_w, // TODO: unrolling by 3 seems best for the std/deflate benchmarks, but that // is mostly because 3 is the minimum length for the deflate format. This // function implementation shouldn't overfit to that one format. Perhaps the - // copy_n_from_history Wuffs method should also take an unroll hint argument, - // and the cgen can look if that argument is the constant expression '3'. + // copy_n32_from_history Wuffs method should also take an unroll hint + // argument, and the cgen can look if that argument is the constant + // expression '3'. // - // See also wuffs_base__io_writer__copy_n_from_history_fast below. + // See also wuffs_base__io_writer__copy_n32_from_history_fast below. // - // Alternatively, or additionally, have a sloppy_copy_n_from_history method + // Alternatively, or additionally, have a sloppy_copy_n32_from_history method // that copies 8 bytes at a time, possibly writing more than length bytes? for (; n >= 3; n -= 3) { *p++ = *q++; @@ -74,18 +75,18 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_iop_w, return length; } -// wuffs_base__io_writer__copy_n_from_history_fast is like the -// wuffs_base__io_writer__copy_n_from_history function above, but has stronger -// pre-conditions. The caller needs to prove that: +// wuffs_base__io_writer__copy_n32_from_history_fast is like the +// wuffs_base__io_writer__copy_n32_from_history function above, but has +// stronger pre-conditions. The caller needs to prove that: // - distance > 0 // - distance <= (*ptr_iop_w - io1_w) // - length <= (io2_w - *ptr_iop_w) static inline uint32_t // -wuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_iop_w, - uint8_t* io1_w, - uint8_t* io2_w, - uint32_t length, - uint32_t distance) { +wuffs_base__io_writer__copy_n32_from_history_fast(uint8_t** ptr_iop_w, + uint8_t* io1_w, + uint8_t* io2_w, + uint32_t length, + uint32_t distance) { uint8_t* p = *ptr_iop_w; uint8_t* q = p - distance; uint32_t n = length; @@ -102,11 +103,11 @@ wuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_iop_w, } static inline uint32_t // -wuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w, - uint8_t* io2_w, - uint32_t length, - uint8_t** ptr_iop_r, - uint8_t* io2_r) { +wuffs_base__io_writer__copy_n32_from_reader(uint8_t** ptr_iop_w, + uint8_t* io2_w, + uint32_t length, + uint8_t** ptr_iop_r, + uint8_t* io2_r) { uint8_t* iop_w = *ptr_iop_w; size_t n = length; if (n > ((size_t)(io2_w - iop_w))) { @@ -141,10 +142,10 @@ wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w, } static inline uint32_t // -wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w, - uint8_t* io2_w, - uint32_t length, - wuffs_base__slice_u8 src) { +wuffs_base__io_writer__copy_n32_from_slice(uint8_t** ptr_iop_w, + uint8_t* io2_w, + uint32_t length, + wuffs_base__slice_u8 src) { uint8_t* iop_w = *ptr_iop_w; size_t n = src.len; if (n > length) { diff --git a/internal/cgen/builtin.go b/internal/cgen/builtin.go index fe8cc66c..e45b2322 100644 --- a/internal/cgen/builtin.go +++ b/internal/cgen/builtin.go @@ -176,7 +176,7 @@ func (g *gen) writeBuiltinIOReader(b *buffer, recv *a.Expr, method t.ID, args [] iopPrefix, name, io0Prefix, name, io0Prefix, name) return nil - case t.IDSkipFast: + case t.IDSkip32Fast: // Generate a two part expression using the comma operator: "(pointer // increment, return_empty_struct call)". The final part is a function // call (to a static inline function) instead of a struct literal, to @@ -218,12 +218,12 @@ func (g *gen) writeBuiltinIOWriter(b *buffer, recv *a.Expr, method t.ID, args [] } switch method { - case t.IDCopyNFromHistory, t.IDCopyNFromHistoryFast: + case t.IDCopyN32FromHistory, t.IDCopyN32FromHistoryFast: suffix := "" - if method == t.IDCopyNFromHistoryFast { + if method == t.IDCopyN32FromHistoryFast { suffix = "_fast" } - b.printf("wuffs_base__io_writer__copy_n_from_history%s(&%s%s, %s%s, %s%s", + b.printf("wuffs_base__io_writer__copy_n32_from_history%s(&%s%s, %s%s, %s%s", suffix, iopPrefix, name, io0Prefix, name, io2Prefix, name) for _, o := range args { b.writeb(',') @@ -234,13 +234,13 @@ func (g *gen) writeBuiltinIOWriter(b *buffer, recv *a.Expr, method t.ID, args [] b.writeb(')') return nil - case t.IDCopyNFromReader: + case t.IDCopyN32FromReader: readerName, err := g.ioRecvName(args[1].AsArg().Value()) if err != nil { return err } - b.printf("wuffs_base__io_writer__copy_n_from_reader(&%s%s, %s%s,", + b.printf("wuffs_base__io_writer__copy_n32_from_reader(&%s%s, %s%s,", iopPrefix, name, io2Prefix, name) if err := g.writeExpr(b, args[0].AsArg().Value(), depth); err != nil { return err @@ -253,8 +253,8 @@ func (g *gen) writeBuiltinIOWriter(b *buffer, recv *a.Expr, method t.ID, args [] iopPrefix, name, io2Prefix, name) return g.writeArgs(b, args, depth) - case t.IDCopyNFromSlice: - b.printf("wuffs_base__io_writer__copy_n_from_slice(&%s%s, %s%s,", + case t.IDCopyN32FromSlice: + b.printf("wuffs_base__io_writer__copy_n32_from_slice(&%s%s, %s%s,", iopPrefix, name, io2Prefix, name) return g.writeArgs(b, args, depth) @@ -583,7 +583,7 @@ func (g *gen) writeBuiltinQuestionCall(b *buffer, n *a.Expr, depth uint32) error b.printf(" = *iop_a_src++;\n") return nil - case t.IDSkip: + case t.IDSkip32: x := n.Args()[0].AsArg().Value() if cv := x.ConstValue(); cv != nil && cv.Cmp(one) == 0 { if err := g.writeCoroSuspPoint(b, false); err != nil { diff --git a/internal/cgen/data.go b/internal/cgen/data.go index b3a7a482..4981225b 100644 --- a/internal/cgen/data.go +++ b/internal/cgen/data.go @@ -166,12 +166,12 @@ const baseImagePublicH = "" + "" const baseIOPrivateH = "" + - "// ---------------- I/O\n\nstatic inline uint64_t //\nwuffs_base__io__count_since(uint64_t mark, uint64_t index) {\n if (index >= mark) {\n return index - mark;\n }\n return 0;\n}\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__io__since(uint64_t mark, uint64_t index, uint8_t* ptr) {\n if (index >= mark) {\n return wuffs_base__make_slice_u8(ptr + mark, index - mark);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_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 // copy_n_from_history Wuffs method should also take an unroll hint argument,\n // and the cgen can look if that argument is the constant expression '3'.\n //\n // See also wuffs_base__io_writer__copy_n_from_history_fast below.\n //\n // Alternatively, or additionally, have a sloppy_copy_n_from_history method\n // that copies 8 bytes at a time, possibly writing more than length bytes?\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_writer__copy_n_from_history_fast is like the\n// wuffs_base__io_writer__copy_n_from_history function above, but has stronger\n// pre-conditions. The caller needs to prove that:\n// - distance > " + - "0\n// - distance <= (*ptr_iop_w - io1_w)\n// - length <= (io2_w - *ptr_iop_w)\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_history_fast(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 uint8_t* q = p - distance;\n uint32_t n = length;\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\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w,\n uint8_t* io2_w,\n uint32_t length,\n uint8_t** ptr_iop_r,\n uint8_t* io2_r) {\n uint8_t* i" + - "op_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 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 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 uint32_t //\nwuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io2_w,\n uint32_t length,\n w" + - "uffs_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_reader__set(wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_r,\n uint8_t** ptr_io0_r,\n uint8_t** ptr_io1_r,\n 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\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__io_reader__take(uint8_t** ptr_iop_r, uint8_t* io2_r, uint64_t n) {\n if (n <= ((size_t)(io2_r - *ptr_i" + - "op_r))) {\n uint8_t* p = *ptr_iop_r;\n *ptr_iop_r += n;\n return wuffs_base__make_slice_u8(p, n);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\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" + + "// ---------------- I/O\n\nstatic inline uint64_t //\nwuffs_base__io__count_since(uint64_t mark, uint64_t index) {\n if (index >= mark) {\n return index - mark;\n }\n return 0;\n}\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__io__since(uint64_t mark, uint64_t index, uint8_t* ptr) {\n if (index >= mark) {\n return wuffs_base__make_slice_u8(ptr + mark, index - mark);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n32_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 // copy_n32_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__copy_n32_from_history_fast below.\n //\n // Alternatively, or additionally, have a sloppy_copy_n32_from_history method\n // that copies 8 bytes at a time, possibly writing more than length bytes?\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_writer__copy_n32_from_history_fast is like the\n// wuffs_base__io_writer__copy_n32_from_history function above, but has\n// stronger pre-conditions. The caller needs to prove" + + " that:\n// - distance > 0\n// - distance <= (*ptr_iop_w - io1_w)\n// - length <= (io2_w - *ptr_iop_w)\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n32_from_history_fast(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 uint8_t* q = p - distance;\n uint32_t n = length;\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\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n32_from_reader(uint8_t** ptr_iop_w,\n uint8_t* io2_w,\n uint32_t length,\n uint8_t** ptr_iop_r,\n " + + " 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 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 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 uint32_t //\nwuffs_base__io_writer__copy_n32_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_reader__set(wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_r,\n uint8_t** ptr_io0_r,\n uint8_t** ptr_io1_r,\n 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\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__io_reader__take(uint8_t** ptr_iop_r, uint8_t* io2" + + "_r, uint64_t n) {\n if (n <= ((size_t)(io2_r - *ptr_iop_r))) {\n uint8_t* p = *ptr_iop_r;\n *ptr_iop_r += n;\n return wuffs_base__make_slice_u8(p, n);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\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" + "" + "// ---------------- 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/lang/builtin/builtin.go b/lang/builtin/builtin.go index 473863fa..b6d9b81c 100644 --- a/lang/builtin/builtin.go +++ b/lang/builtin/builtin.go @@ -235,13 +235,13 @@ var Funcs = []string{ "io_reader.since(mark: u64) slice u8", "io_reader.take!(n: u64) slice u8", - "io_reader.skip?(n: u32)", + "io_reader.skip32?(n: u32)", // TODO: this should have explicit pre-conditions "actual <= worst_case" // and "worst_case <= available()". As an implementation restriction, we // also require that worst_case has a constant value. For now, that's all // implicitly checked (i.e. hard coded). - "io_reader.skip_fast!(actual: u32, worst_case: u32)", + "io_reader.skip32_fast!(actual: u32, worst_case: u32)", // ---- io_writer @@ -290,16 +290,16 @@ var Funcs = []string{ "io_writer.since(mark: u64) slice u8", "io_writer.copy_from_slice!(s: slice u8) u64", - "io_writer.copy_n_from_history!(n: u32, distance: u32) u32", - "io_writer.copy_n_from_reader!(n: u32, r: io_reader) u32", - "io_writer.copy_n_from_slice!(n: u32, s: slice u8) u32", + "io_writer.copy_n32_from_history!(n: u32, distance: u32) u32", + "io_writer.copy_n32_from_reader!(n: u32, r: io_reader) u32", + "io_writer.copy_n32_from_slice!(n: u32, s: slice u8) u32", // TODO: this should have explicit pre-conditions: // - n <= this.available() // - distance > 0 // - distance <= this.since_mark().length() // For now, that's all implicitly checked (i.e. hard coded). - "io_writer.copy_n_from_history_fast!(n: u32, distance: u32) u32", + "io_writer.copy_n32_from_history_fast!(n: u32, distance: u32) u32", // ---- status diff --git a/lang/check/bounds.go b/lang/check/bounds.go index 715814bd..17084c2b 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -1045,12 +1045,12 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (bounds, e return bounds{}, err } - } else if method == t.IDCopyNFromHistoryFast { - if err := q.canCopyNFromHistoryFast(recv, n.Args()); err != nil { + } else if method == t.IDCopyN32FromHistoryFast { + if err := q.canCopyN32FromHistoryFast(recv, n.Args()); err != nil { return bounds{}, err } - } else if method == t.IDSkipFast { + } else if method == t.IDSkip32Fast { args := n.Args() if len(args) != 2 { return bounds{}, fmt.Errorf("check: internal error: bad skip_fast arguments") @@ -1112,7 +1112,7 @@ func (q *checker) canUndoByte(recv *a.Expr) error { return fmt.Errorf("check: could not prove %s.can_undo_byte()", recv.Str(q.tm)) } -func (q *checker) canCopyNFromHistoryFast(recv *a.Expr, args []*a.Node) error { +func (q *checker) canCopyN32FromHistoryFast(recv *a.Expr, args []*a.Node) error { // As per cgen's io-private.h, there are three pre-conditions: // - n <= this.available() // - distance > 0 diff --git a/lang/token/list.go b/lang/token/list.go index 5cc39436..6fef5c33 100644 --- a/lang/token/list.go +++ b/lang/token/list.go @@ -492,15 +492,15 @@ const ( IDMark = ID(0x163) IDPosition = ID(0x164) IDSince = ID(0x165) - IDSkip = ID(0x166) - IDSkipFast = ID(0x167) + IDSkip32 = ID(0x166) + IDSkip32Fast = ID(0x167) IDTake = ID(0x168) - IDCopyFromSlice = ID(0x170) - IDCopyNFromHistory = ID(0x171) - IDCopyNFromHistoryFast = ID(0x172) - IDCopyNFromReader = ID(0x173) - IDCopyNFromSlice = ID(0x174) + IDCopyFromSlice = ID(0x170) + IDCopyN32FromHistory = ID(0x171) + IDCopyN32FromHistoryFast = ID(0x172) + IDCopyN32FromReader = ID(0x173) + IDCopyN32FromSlice = ID(0x174) // -------- 0x180 block. @@ -834,15 +834,15 @@ var builtInsByID = [nBuiltInIDs]string{ IDMark: "mark", IDPosition: "position", IDSince: "since", - IDSkip: "skip", - IDSkipFast: "skip_fast", + IDSkip32: "skip32", + IDSkip32Fast: "skip32_fast", IDTake: "take", - IDCopyFromSlice: "copy_from_slice", - IDCopyNFromHistory: "copy_n_from_history", - IDCopyNFromHistoryFast: "copy_n_from_history_fast", - IDCopyNFromReader: "copy_n_from_reader", - IDCopyNFromSlice: "copy_n_from_slice", + IDCopyFromSlice: "copy_from_slice", + IDCopyN32FromHistory: "copy_n32_from_history", + IDCopyN32FromHistoryFast: "copy_n32_from_history_fast", + IDCopyN32FromReader: "copy_n32_from_reader", + IDCopyN32FromSlice: "copy_n32_from_slice", // -------- 0x180 block. diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 51cc52af..e735950f 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -5069,11 +5069,11 @@ wuffs_base__io__since(uint64_t mark, uint64_t index, uint8_t* ptr) { } static inline uint32_t // -wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_iop_w, - uint8_t* io1_w, - uint8_t* io2_w, - uint32_t length, - uint32_t distance) { +wuffs_base__io_writer__copy_n32_from_history(uint8_t** ptr_iop_w, + uint8_t* io1_w, + uint8_t* io2_w, + uint32_t length, + uint32_t distance) { if (!distance) { return 0; } @@ -5091,12 +5091,13 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_iop_w, // TODO: unrolling by 3 seems best for the std/deflate benchmarks, but that // is mostly because 3 is the minimum length for the deflate format. This // function implementation shouldn't overfit to that one format. Perhaps the - // copy_n_from_history Wuffs method should also take an unroll hint argument, - // and the cgen can look if that argument is the constant expression '3'. + // copy_n32_from_history Wuffs method should also take an unroll hint + // argument, and the cgen can look if that argument is the constant + // expression '3'. // - // See also wuffs_base__io_writer__copy_n_from_history_fast below. + // See also wuffs_base__io_writer__copy_n32_from_history_fast below. // - // Alternatively, or additionally, have a sloppy_copy_n_from_history method + // Alternatively, or additionally, have a sloppy_copy_n32_from_history method // that copies 8 bytes at a time, possibly writing more than length bytes? for (; n >= 3; n -= 3) { *p++ = *q++; @@ -5110,18 +5111,18 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_iop_w, return length; } -// wuffs_base__io_writer__copy_n_from_history_fast is like the -// wuffs_base__io_writer__copy_n_from_history function above, but has stronger -// pre-conditions. The caller needs to prove that: +// wuffs_base__io_writer__copy_n32_from_history_fast is like the +// wuffs_base__io_writer__copy_n32_from_history function above, but has +// stronger pre-conditions. The caller needs to prove that: // - distance > 0 // - distance <= (*ptr_iop_w - io1_w) // - length <= (io2_w - *ptr_iop_w) static inline uint32_t // -wuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_iop_w, - uint8_t* io1_w, - uint8_t* io2_w, - uint32_t length, - uint32_t distance) { +wuffs_base__io_writer__copy_n32_from_history_fast(uint8_t** ptr_iop_w, + uint8_t* io1_w, + uint8_t* io2_w, + uint32_t length, + uint32_t distance) { uint8_t* p = *ptr_iop_w; uint8_t* q = p - distance; uint32_t n = length; @@ -5138,11 +5139,11 @@ wuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_iop_w, } static inline uint32_t // -wuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w, - uint8_t* io2_w, - uint32_t length, - uint8_t** ptr_iop_r, - uint8_t* io2_r) { +wuffs_base__io_writer__copy_n32_from_reader(uint8_t** ptr_iop_w, + uint8_t* io2_w, + uint32_t length, + uint8_t** ptr_iop_r, + uint8_t* io2_r) { uint8_t* iop_w = *ptr_iop_w; size_t n = length; if (n > ((size_t)(io2_w - iop_w))) { @@ -5177,10 +5178,10 @@ wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w, } static inline uint32_t // -wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w, - uint8_t* io2_w, - uint32_t length, - wuffs_base__slice_u8 src) { +wuffs_base__io_writer__copy_n32_from_slice(uint8_t** ptr_iop_w, + uint8_t* io2_w, + uint32_t length, + wuffs_base__slice_u8 src) { uint8_t* iop_w = *ptr_iop_w; size_t n = src.len; if (n > length) { @@ -7901,7 +7902,7 @@ wuffs_deflate__decoder__decode_uncompressed(wuffs_deflate__decoder* self, } v_length = ((v_length)&0xFFFF); while (true) { - v_n_copied = wuffs_base__io_writer__copy_n_from_reader( + v_n_copied = wuffs_base__io_writer__copy_n32_from_reader( &iop_a_dst, io2_a_dst, v_length, &iop_a_src, io2_a_src); if (v_length <= v_n_copied) { status = wuffs_base__make_status(NULL); @@ -8755,7 +8756,7 @@ label_0_continue:; } v_hdist = (self->private_impl.f_history_index - v_hdist); while (true) { - v_n_copied = wuffs_base__io_writer__copy_n_from_slice( + v_n_copied = wuffs_base__io_writer__copy_n32_from_slice( &iop_a_dst, io2_a_dst, v_hlen, wuffs_base__slice_u8__subslice_i( wuffs_base__make_slice_u8(self->private_data.f_history, @@ -8765,7 +8766,7 @@ label_0_continue:; goto label_1_break; } v_hlen -= v_n_copied; - wuffs_base__io_writer__copy_n_from_slice( + wuffs_base__io_writer__copy_n32_from_slice( &iop_a_dst, io2_a_dst, v_hlen, wuffs_base__make_slice_u8(self->private_data.f_history, 32768)); goto label_1_break; @@ -8781,7 +8782,7 @@ label_0_continue:; goto exit; } } - wuffs_base__io_writer__copy_n_from_history_fast( + wuffs_base__io_writer__copy_n32_from_history_fast( &iop_a_dst, io0_a_dst, io2_a_dst, v_length, (v_dist_minus_1 + 1)); goto label_2_break; } @@ -9126,7 +9127,7 @@ wuffs_deflate__decoder__decode_huffman_slow(wuffs_deflate__decoder* self, } v_hdist = (self->private_impl.f_history_index - v_hdist); while (true) { - v_n_copied = wuffs_base__io_writer__copy_n_from_slice( + v_n_copied = wuffs_base__io_writer__copy_n32_from_slice( &iop_a_dst, io2_a_dst, v_hlen, wuffs_base__slice_u8__subslice_i( wuffs_base__make_slice_u8(self->private_data.f_history, @@ -9150,7 +9151,7 @@ wuffs_deflate__decoder__decode_huffman_slow(wuffs_deflate__decoder* self, label_5_break:; if (v_hlen > 0) { while (true) { - v_n_copied = wuffs_base__io_writer__copy_n_from_slice( + v_n_copied = wuffs_base__io_writer__copy_n32_from_slice( &iop_a_dst, io2_a_dst, v_hlen, wuffs_base__slice_u8__subslice_i( wuffs_base__make_slice_u8(self->private_data.f_history, @@ -9172,7 +9173,7 @@ wuffs_deflate__decoder__decode_huffman_slow(wuffs_deflate__decoder* self, goto label_0_continue; } } - v_n_copied = wuffs_base__io_writer__copy_n_from_history( + v_n_copied = wuffs_base__io_writer__copy_n32_from_history( &iop_a_dst, io0_a_dst, io2_a_dst, v_length, (v_dist_minus_1 + 1)); if (v_length <= v_n_copied) { v_length = 0; diff --git a/std/deflate/decode_deflate.wuffs b/std/deflate/decode_deflate.wuffs index 429144ba..72cdc5b6 100644 --- a/std/deflate/decode_deflate.wuffs +++ b/std/deflate/decode_deflate.wuffs @@ -281,7 +281,7 @@ pri func decoder.decode_uncompressed?(dst: base.io_writer, src: base.io_reader) } length = length.low_bits(n: 16) while true { - n_copied = args.dst.copy_n_from_reader!(n: length, r: args.src) + n_copied = args.dst.copy_n32_from_reader!(n: length, r: args.src) if length <= n_copied { return ok } diff --git a/std/deflate/decode_huffman_fast.wuffs b/std/deflate/decode_huffman_fast.wuffs index 8ea84df9..9d7f460d 100644 --- a/std/deflate/decode_huffman_fast.wuffs +++ b/std/deflate/decode_huffman_fast.wuffs @@ -76,10 +76,10 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader) if n_bits < 15 { assert n_bits >= 0 // TODO: this shouldn't be necessary. bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 assert n_bits >= 15 } else { @@ -115,10 +115,10 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader) if n_bits < 15 { assert n_bits >= 0 // TODO: this shouldn't be necessary. bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 assert n_bits >= 15 } else { @@ -173,10 +173,10 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader) if n_bits < 15 { assert n_bits >= 0 // TODO: this shouldn't be necessary. bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 assert n_bits >= 15 } else { @@ -200,10 +200,10 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader) if n_bits < 15 { assert n_bits >= 0 // TODO: this shouldn't be necessary. bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 assert n_bits >= 15 } else { @@ -225,10 +225,10 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader) if n_bits < 15 { assert n_bits >= 0 // TODO: this shouldn't be necessary. bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 assert n_bits >= 15 } else { @@ -269,10 +269,10 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader) assert n_bits < 15 via "a < b: a < c; c <= b"(c: table_entry_n_bits) assert n_bits >= 0 // TODO: this shouldn't be necessary. bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 assert table_entry_n_bits <= n_bits via "a <= b: a <= c; c <= b"(c: 16) assert n_bits >= table_entry_n_bits via "a >= b: b <= a"() @@ -330,13 +330,13 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader) // TODO: copy_from_slice32 should probably update the // "args.dst.available() >= 258" fact. It should certainly // invalidate any fact that was "<=" instead of ">=". - n_copied = args.dst.copy_n_from_slice!( + n_copied = args.dst.copy_n32_from_slice!( n: hlen, s: this.history[hdist & 0x7FFF ..]) if hlen <= n_copied { break } hlen -= n_copied - args.dst.copy_n_from_slice!(n: hlen, s: this.history[..]) + args.dst.copy_n32_from_slice!(n: hlen, s: this.history[..]) break } @@ -359,7 +359,7 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader) assert (length as base.u64) <= args.dst.available() via "a <= b: a <= c; c <= b"(c: 258) // Copy from args.dst. - args.dst.copy_n_from_history_fast!(n: length, distance: (dist_minus_1 + 1)) + args.dst.copy_n32_from_history_fast!(n: length, distance: (dist_minus_1 + 1)) break } } diff --git a/std/deflate/decode_huffman_slow.wuffs b/std/deflate/decode_huffman_slow.wuffs index fb2fed00..73ede6de 100644 --- a/std/deflate/decode_huffman_slow.wuffs +++ b/std/deflate/decode_huffman_slow.wuffs @@ -226,7 +226,7 @@ pri func decoder.decode_huffman_slow?(dst: base.io_writer, src: base.io_reader) // Copy from hdist to the end of this.history. while true { - n_copied = args.dst.copy_n_from_slice!( + n_copied = args.dst.copy_n32_from_slice!( n: hlen, s: this.history[hdist & 0x7FFF ..]) if hlen <= n_copied { hlen = 0 @@ -245,7 +245,7 @@ pri func decoder.decode_huffman_slow?(dst: base.io_writer, src: base.io_reader) // Copy from the start of this.history, if we wrapped around. if hlen > 0 { while true { - n_copied = args.dst.copy_n_from_slice!( + n_copied = args.dst.copy_n32_from_slice!( n: hlen, s: this.history[hdist & 0x7FFF ..]) if hlen <= n_copied { hlen = 0 @@ -264,7 +264,7 @@ pri func decoder.decode_huffman_slow?(dst: base.io_writer, src: base.io_reader) } // Copy from args.dst. - n_copied = args.dst.copy_n_from_history!(n: length, distance: (dist_minus_1 + 1)) + n_copied = args.dst.copy_n32_from_history!(n: length, distance: (dist_minus_1 + 1)) if length <= n_copied { length = 0 break diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs index a08c4704..f433a4a8 100644 --- a/std/gif/decode_gif.wuffs +++ b/std/gif/decode_gif.wuffs @@ -253,7 +253,7 @@ pub func decoder.ack_metadata_chunk?(src: base.io_reader) { // metadata passed to the caller. this.metadata_chunk_length_value += 1 } else { - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) } this.metadata_io_position = args.src.position() ~sat+ this.metadata_chunk_length_value @@ -261,7 +261,7 @@ pub func decoder.ack_metadata_chunk?(src: base.io_reader) { } // Consume the '\x00' that means a zero-length block. - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) } this.call_sequence = 2 @@ -399,7 +399,7 @@ pri func decoder.skip_frame?(src: base.io_reader) { // Skip the optional Local Color Table, 3 bytes (RGB) per entry. flags = args.src.read_u8?() if (flags & 0x80) <> 0 { - args.src.skip?(n: (3 as base.u32) << (1 + (flags & 0x07))) + args.src.skip32?(n: (3 as base.u32) << (1 + (flags & 0x07))) } // Process the LZW literal width. @@ -516,7 +516,7 @@ pri func decoder.decode_lsd?(src: base.io_reader) { flags = args.src.read_u8?() background_color_index = args.src.read_u8?() // Ignore the Pixel Aspect Ratio byte. - args.src.skip?(n: 1) + args.src.skip32?(n: 1) // Read the optional Global Color Table. i = 0 @@ -598,7 +598,7 @@ pri func decoder.skip_blocks?(src: base.io_reader) { if block_size == 0 { return ok } - args.src.skip?(n: block_size as base.u32) + args.src.skip32?(n: block_size as base.u32) } } @@ -646,7 +646,7 @@ pri func decoder.decode_ae?(src: base.io_reader) { // // Other extensions include XMP metadata. if block_size <> 11 { - args.src.skip?(n: block_size as base.u32) + args.src.skip32?(n: block_size as base.u32) break } is_animexts = true @@ -668,12 +668,12 @@ pri func decoder.decode_ae?(src: base.io_reader) { // count. block_size = args.src.read_u8?() if block_size <> 3 { - args.src.skip?(n: block_size as base.u32) + args.src.skip32?(n: block_size as base.u32) break } c = args.src.read_u8?() if c <> 0x01 { - args.src.skip?(n: 2) + args.src.skip32?(n: 2) break } this.num_loops = args.src.read_u16le_as_u32?() @@ -703,7 +703,7 @@ pri func decoder.decode_ae?(src: base.io_reader) { yield? base."$short read" } this.metadata_chunk_length_value = args.src.peek_u8_as_u64() - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) this.metadata_fourcc_value = 0x49434350 // "ICCP" this.metadata_io_position = args.src.position() ~sat+ this.metadata_chunk_length_value this.call_sequence = 1 @@ -722,7 +722,7 @@ pri func decoder.decode_ae?(src: base.io_reader) { // metadata passed to the caller. this.metadata_chunk_length_value += 1 } else { - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) } this.metadata_fourcc_value = 0x584D5020 // "XMP " this.metadata_io_position = args.src.position() ~sat+ this.metadata_chunk_length_value @@ -962,7 +962,7 @@ pri func decoder.decode_id_part2?(dst: ptr base.pixel_buffer, src: base.io_reade break } block_size = args.src.peek_u8_as_u64() - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) } if decoder_workbuf_len_max_incl_worst_case > args.workbuf.length() { @@ -993,7 +993,7 @@ pri func decoder.decode_id_part2?(dst: ptr base.pixel_buffer, src: base.io_reade // Skip any trailing blocks. if need_block_size or (block_size > 0) { - args.src.skip?(n: block_size as base.u32) + args.src.skip32?(n: block_size as base.u32) this.skip_blocks?(src: args.src) } diff --git a/std/gzip/decode_gzip.wuffs b/std/gzip/decode_gzip.wuffs index 05dedd34..71675d4b 100644 --- a/std/gzip/decode_gzip.wuffs +++ b/std/gzip/decode_gzip.wuffs @@ -68,12 +68,12 @@ pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf } flags = args.src.read_u8?() // TODO: API for returning the header's MTIME field. - args.src.skip?(n: 6) + args.src.skip32?(n: 6) // Handle FEXTRA. if (flags & 0x04) <> 0 { xlen = args.src.read_u16le?() - args.src.skip?(n: xlen as base.u32) + args.src.skip32?(n: xlen as base.u32) } // Handle FNAME. @@ -102,7 +102,7 @@ pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf // Handle FHCRC. if (flags & 0x02) <> 0 { - args.src.skip?(n: 2) + args.src.skip32?(n: 2) } // Reserved flags bits must be zero. diff --git a/std/lzw/decode_lzw.wuffs b/std/lzw/decode_lzw.wuffs index 059b119e..b82e8d2a 100644 --- a/std/lzw/decode_lzw.wuffs +++ b/std/lzw/decode_lzw.wuffs @@ -159,7 +159,7 @@ pri func decoder.read_from!(src: base.io_reader) { // Read 4 bytes, using the "Variant 4" technique of // https://fgiesen.wordpress.com/2018/02/20/reading-bits-in-far-too-many-ways-part-2/ bits |= args.src.peek_u32le() ~mod<< n_bits - args.src.skip_fast!(actual: (31 - n_bits) >> 3, worst_case: 3) + args.src.skip32_fast!(actual: (31 - n_bits) >> 3, worst_case: 3) n_bits |= 24 assert width <= n_bits via "a <= b: a <= c; c <= b"(c: 12) assert n_bits >= width via "a >= b: b <= a"() @@ -168,7 +168,7 @@ pri func decoder.read_from!(src: base.io_reader) { break } else { bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 if n_bits >= width { // No-op. @@ -177,7 +177,7 @@ pri func decoder.read_from!(src: base.io_reader) { break } else { bits |= args.src.peek_u8_as_u32() << n_bits - args.src.skip_fast!(actual: 1, worst_case: 1) + args.src.skip32_fast!(actual: 1, worst_case: 1) n_bits += 8 assert width <= n_bits via "a <= b: a <= c; c <= b"(c: 12) assert n_bits >= width via "a >= b: b <= a"() diff --git a/std/wbmp/decode_wbmp.wuffs b/std/wbmp/decode_wbmp.wuffs index 442b3bdd..8c957bba 100644 --- a/std/wbmp/decode_wbmp.wuffs +++ b/std/wbmp/decode_wbmp.wuffs @@ -208,7 +208,7 @@ pri func decoder.skip_frame?(src: base.io_reader) { total_bytes = bytes_per_row * (this.height as base.u64) // TODO: total_bytes may be larger than UINT32_MAX. - args.src.skip?(n: (total_bytes & 0xFFFFFFFF) as base.u32) + args.src.skip32?(n: (total_bytes & 0xFFFFFFFF) as base.u32) this.seen_frame = true this.call_sequence = 2