diff --git a/cmd/wuffs-c/internal/cgen/base/base-private.h b/cmd/wuffs-c/internal/cgen/base/base-private.h index f728e5bb..dec9a489 100644 --- a/cmd/wuffs-c/internal/cgen/base/base-private.h +++ b/cmd/wuffs-c/internal/cgen/base/base-private.h @@ -539,7 +539,7 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( // 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'. // - // See also wuffs_base__io_writer__copy_n_from_history__bco below. + // See also wuffs_base__io_writer__copy_n_from_history_fast below. // // Alternatively, or additionally, have a sloppy_copy_n_from_history method // that copies 8 bytes at a time, possibly writing more than length bytes? @@ -555,13 +555,13 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( return length; } -// wuffs_base__io_writer__copy_n_from_history__bco is a Bounds Check Optimized -// version of the wuffs_base__io_writer__copy_n_from_history function above. -// The caller needs to prove that: +// 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: // - distance > 0 // - distance <= (*ptr_ptr - start) // - length <= (end - *ptr_ptr) -static inline uint32_t wuffs_base__io_writer__copy_n_from_history__bco( +static inline uint32_t wuffs_base__io_writer__copy_n_from_history_fast( uint8_t** ptr_ptr, uint8_t* start, uint8_t* end, diff --git a/cmd/wuffs-c/internal/cgen/builtin.go b/cmd/wuffs-c/internal/cgen/builtin.go index 5a8d2b08..627a0a3c 100644 --- a/cmd/wuffs-c/internal/cgen/builtin.go +++ b/cmd/wuffs-c/internal/cgen/builtin.go @@ -172,7 +172,7 @@ func (g *gen) writeBuiltinIOWriter(b *buffer, recv *a.Expr, method t.ID, args [] case t.IDCopyNFromHistory: bco := "" if bcoHack { - bco = "__bco" + bco = "_fast" } b.printf("wuffs_base__io_writer__copy_n_from_history%s("+ "&ioptr_dst, %sdst.private_impl.bounds[0], iobounds1_dst", diff --git a/cmd/wuffs-c/internal/cgen/data.go b/cmd/wuffs-c/internal/cgen/data.go index cdd7d1c9..19bcbf50 100644 --- a/cmd/wuffs-c/internal/cgen/data.go +++ b/cmd/wuffs-c/internal/cgen/data.go @@ -133,11 +133,11 @@ const basePrivateH = "" + "" + "// ---------------- I/O\n\nstatic inline bool wuffs_base__io_buffer__is_valid(wuffs_base__io_buffer buf) {\n return (buf.ptr || (buf.len == 0)) && (buf.len >= buf.wi) &&\n (buf.wi >= buf.ri);\n}\n\nstatic inline bool wuffs_base__io_reader__is_eof(wuffs_base__io_reader o) {\n wuffs_base__io_buffer* buf = o.private_impl.buf;\n return buf && buf->closed && (buf->ptr + buf->wi == o.private_impl.bounds[1]);\n}\n\nstatic inline bool wuffs_base__io_reader__is_valid(wuffs_base__io_reader o) {\n wuffs_base__io_buffer* buf = o.private_impl.buf;\n // Note: if making this function public (i.e. moving it to base-header.h), it\n // also needs to allow NULL (i.e. implicit, callee-calculated) bounds.\n return buf ? ((buf->ptr <= o.private_impl.bounds[0]) &&\n (o.private_impl.bounds[0] <= o.private_impl.bounds[1]) &&\n (o.private_impl.bounds[1] <= buf->ptr + buf->len))\n : ((o.private_impl.bounds[0] == NULL) &&\n (o.private_impl.bounds[1] == NULL));\n}\n\nstatic inline bool wuf" + "fs_base__io_writer__is_valid(wuffs_base__io_writer o) {\n wuffs_base__io_buffer* buf = o.private_impl.buf;\n // Note: if making this function public (i.e. moving it to base-header.h), it\n // also needs to allow NULL (i.e. implicit, callee-calculated) bounds.\n return buf ? ((buf->ptr <= o.private_impl.bounds[0]) &&\n (o.private_impl.bounds[0] <= o.private_impl.bounds[1]) &&\n (o.private_impl.bounds[1] <= buf->ptr + buf->len))\n : ((o.private_impl.bounds[0] == NULL) &&\n (o.private_impl.bounds[1] == NULL));\n}\n\nstatic inline uint32_t wuffs_base__io_writer__copy_n_from_history(\n uint8_t** ptr_ptr,\n uint8_t* start,\n uint8_t* end,\n uint32_t length,\n uint32_t distance) {\n if (!distance) {\n return 0;\n }\n uint8_t* ptr = *ptr_ptr;\n if ((size_t)(ptr - start) < (size_t)(distance)) {\n return 0;\n }\n start = ptr - distance;\n size_t n = end - ptr;\n if ((size_t)(length) > n) {\n length = n;\n } else {\n n = 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__bco 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 *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n }\n for (; n; n--) {\n *ptr++ = *start++;\n }\n *ptr_ptr = ptr;\n return length;\n}\n\n// wuffs_base__io_writer__copy_n_from_history__bco is a Bounds Check Optimized\n// version of the wuffs_base__io_writer__copy_n_from_history function above.\n// The caller needs to prove that:\n// - distance > 0\n// - distance <= (*ptr_pt" + - "r - start)\n// - length <= (end - *ptr_ptr)\nstatic inline uint32_t wuffs_base__io_writer__copy_n_from_history__bco(\n uint8_t** ptr_ptr,\n uint8_t* start,\n uint8_t* end,\n uint32_t length,\n uint32_t distance) {\n uint8_t* ptr = *ptr_ptr;\n start = ptr - distance;\n uint32_t n = length;\n for (; n >= 3; n -= 3) {\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n }\n for (; n; n--) {\n *ptr++ = *start++;\n }\n *ptr_ptr = ptr;\n return length;\n}\n\nstatic inline uint32_t wuffs_base__io_writer__copy_n_from_reader(\n uint8_t** ptr_ioptr_w,\n uint8_t* iobounds1_w,\n uint32_t length,\n uint8_t** ptr_ioptr_r,\n uint8_t* iobounds1_r) {\n uint8_t* ioptr_w = *ptr_ioptr_w;\n size_t n = length;\n if (n > ((size_t)(iobounds1_w - ioptr_w))) {\n n = iobounds1_w - ioptr_w;\n }\n uint8_t* ioptr_r = *ptr_ioptr_r;\n if (n > ((size_t)(iobounds1_r - ioptr_r))) {\n n = iobounds1_r - ioptr_r;\n }\n if (n > 0) {\n memmove(ioptr_w, ioptr_r, n);\n *ptr_ioptr_w += n;\n *ptr_iop" + - "tr_r += n;\n }\n return n;\n}\n\nstatic inline uint64_t wuffs_base__io_writer__copy_from_slice(\n uint8_t** ptr_ioptr_w,\n uint8_t* iobounds1_w,\n wuffs_base__slice_u8 src) {\n uint8_t* ioptr_w = *ptr_ioptr_w;\n size_t n = src.len;\n if (n > ((size_t)(iobounds1_w - ioptr_w))) {\n n = iobounds1_w - ioptr_w;\n }\n if (n > 0) {\n memmove(ioptr_w, src.ptr, n);\n *ptr_ioptr_w += n;\n }\n return n;\n}\n\nstatic inline uint32_t wuffs_base__io_writer__copy_n_from_slice(\n uint8_t** ptr_ioptr_w,\n uint8_t* iobounds1_w,\n uint32_t length,\n wuffs_base__slice_u8 src) {\n uint8_t* ioptr_w = *ptr_ioptr_w;\n size_t n = src.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(iobounds1_w - ioptr_w))) {\n n = iobounds1_w - ioptr_w;\n }\n if (n > 0) {\n memmove(ioptr_w, src.ptr, n);\n *ptr_ioptr_w += n;\n }\n return n;\n}\n\nstatic inline wuffs_base__empty_struct wuffs_base__io_reader__set_limit(\n wuffs_base__io_reader* o,\n uint8_t* ioptr_r,\n uint64_t limit) {\n if (o && (((size_t)(o->pri" + - "vate_impl.bounds[1] - ioptr_r)) > limit)) {\n o->private_impl.bounds[1] = ioptr_r + limit;\n }\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct wuffs_base__io_reader__set_mark(\n wuffs_base__io_reader* o,\n uint8_t* mark) {\n o->private_impl.bounds[0] = mark;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct wuffs_base__io_writer__set(\n wuffs_base__io_writer* o,\n wuffs_base__io_buffer* b,\n uint8_t** ioptr1_ptr,\n uint8_t** ioptr2_ptr,\n wuffs_base__slice_u8 s) {\n b->ptr = s.ptr;\n b->len = s.len;\n b->wi = 0;\n b->ri = 0;\n b->closed = false;\n o->private_impl.buf = b;\n o->private_impl.bounds[0] = s.ptr;\n o->private_impl.bounds[1] = s.ptr + s.len;\n *ioptr1_ptr = s.ptr;\n *ioptr2_ptr = s.ptr + s.len;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct wuffs_base__io_writer__set_mark(\n wuffs_base__io_writer* o,\n uint8_t* mark) {\n o->private_impl.bounds[0] = mark;\n return ((wuffs_base_" + - "_empty_struct){});\n}\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n#endif // WUFFS_INCLUDE_GUARD__BASE_PRIVATE\n" + + " 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 *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n }\n for (; n; n--) {\n *ptr++ = *start++;\n }\n *ptr_ptr = ptr;\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_" + + "ptr - start)\n// - length <= (end - *ptr_ptr)\nstatic inline uint32_t wuffs_base__io_writer__copy_n_from_history_fast(\n uint8_t** ptr_ptr,\n uint8_t* start,\n uint8_t* end,\n uint32_t length,\n uint32_t distance) {\n uint8_t* ptr = *ptr_ptr;\n start = ptr - distance;\n uint32_t n = length;\n for (; n >= 3; n -= 3) {\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n }\n for (; n; n--) {\n *ptr++ = *start++;\n }\n *ptr_ptr = ptr;\n return length;\n}\n\nstatic inline uint32_t wuffs_base__io_writer__copy_n_from_reader(\n uint8_t** ptr_ioptr_w,\n uint8_t* iobounds1_w,\n uint32_t length,\n uint8_t** ptr_ioptr_r,\n uint8_t* iobounds1_r) {\n uint8_t* ioptr_w = *ptr_ioptr_w;\n size_t n = length;\n if (n > ((size_t)(iobounds1_w - ioptr_w))) {\n n = iobounds1_w - ioptr_w;\n }\n uint8_t* ioptr_r = *ptr_ioptr_r;\n if (n > ((size_t)(iobounds1_r - ioptr_r))) {\n n = iobounds1_r - ioptr_r;\n }\n if (n > 0) {\n memmove(ioptr_w, ioptr_r, n);\n *ptr_ioptr_w += n;\n *ptr_i" + + "optr_r += n;\n }\n return n;\n}\n\nstatic inline uint64_t wuffs_base__io_writer__copy_from_slice(\n uint8_t** ptr_ioptr_w,\n uint8_t* iobounds1_w,\n wuffs_base__slice_u8 src) {\n uint8_t* ioptr_w = *ptr_ioptr_w;\n size_t n = src.len;\n if (n > ((size_t)(iobounds1_w - ioptr_w))) {\n n = iobounds1_w - ioptr_w;\n }\n if (n > 0) {\n memmove(ioptr_w, src.ptr, n);\n *ptr_ioptr_w += n;\n }\n return n;\n}\n\nstatic inline uint32_t wuffs_base__io_writer__copy_n_from_slice(\n uint8_t** ptr_ioptr_w,\n uint8_t* iobounds1_w,\n uint32_t length,\n wuffs_base__slice_u8 src) {\n uint8_t* ioptr_w = *ptr_ioptr_w;\n size_t n = src.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(iobounds1_w - ioptr_w))) {\n n = iobounds1_w - ioptr_w;\n }\n if (n > 0) {\n memmove(ioptr_w, src.ptr, n);\n *ptr_ioptr_w += n;\n }\n return n;\n}\n\nstatic inline wuffs_base__empty_struct wuffs_base__io_reader__set_limit(\n wuffs_base__io_reader* o,\n uint8_t* ioptr_r,\n uint64_t limit) {\n if (o && (((size_t)(o->p" + + "rivate_impl.bounds[1] - ioptr_r)) > limit)) {\n o->private_impl.bounds[1] = ioptr_r + limit;\n }\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct wuffs_base__io_reader__set_mark(\n wuffs_base__io_reader* o,\n uint8_t* mark) {\n o->private_impl.bounds[0] = mark;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct wuffs_base__io_writer__set(\n wuffs_base__io_writer* o,\n wuffs_base__io_buffer* b,\n uint8_t** ioptr1_ptr,\n uint8_t** ioptr2_ptr,\n wuffs_base__slice_u8 s) {\n b->ptr = s.ptr;\n b->len = s.len;\n b->wi = 0;\n b->ri = 0;\n b->closed = false;\n o->private_impl.buf = b;\n o->private_impl.bounds[0] = s.ptr;\n o->private_impl.bounds[1] = s.ptr + s.len;\n *ioptr1_ptr = s.ptr;\n *ioptr2_ptr = s.ptr + s.len;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct wuffs_base__io_writer__set_mark(\n wuffs_base__io_writer* o,\n uint8_t* mark) {\n o->private_impl.bounds[0] = mark;\n return ((wuffs_bas" + + "e__empty_struct){});\n}\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n#endif // WUFFS_INCLUDE_GUARD__BASE_PRIVATE\n" + "" const baseImplC = "" + diff --git a/gen/c/base.c b/gen/c/base.c index 91a3cd69..fd32a553 100644 --- a/gen/c/base.c +++ b/gen/c/base.c @@ -2291,7 +2291,7 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( // 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'. // - // See also wuffs_base__io_writer__copy_n_from_history__bco below. + // See also wuffs_base__io_writer__copy_n_from_history_fast below. // // Alternatively, or additionally, have a sloppy_copy_n_from_history method // that copies 8 bytes at a time, possibly writing more than length bytes? @@ -2307,13 +2307,13 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( return length; } -// wuffs_base__io_writer__copy_n_from_history__bco is a Bounds Check Optimized -// version of the wuffs_base__io_writer__copy_n_from_history function above. -// The caller needs to prove that: +// 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: // - distance > 0 // - distance <= (*ptr_ptr - start) // - length <= (end - *ptr_ptr) -static inline uint32_t wuffs_base__io_writer__copy_n_from_history__bco( +static inline uint32_t wuffs_base__io_writer__copy_n_from_history_fast( uint8_t** ptr_ptr, uint8_t* start, uint8_t* end, diff --git a/gen/c/std/adler32.c b/gen/c/std/adler32.c index eee8be2f..ef22f931 100644 --- a/gen/c/std/adler32.c +++ b/gen/c/std/adler32.c @@ -2359,7 +2359,7 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( // 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'. // - // See also wuffs_base__io_writer__copy_n_from_history__bco below. + // See also wuffs_base__io_writer__copy_n_from_history_fast below. // // Alternatively, or additionally, have a sloppy_copy_n_from_history method // that copies 8 bytes at a time, possibly writing more than length bytes? @@ -2375,13 +2375,13 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( return length; } -// wuffs_base__io_writer__copy_n_from_history__bco is a Bounds Check Optimized -// version of the wuffs_base__io_writer__copy_n_from_history function above. -// The caller needs to prove that: +// 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: // - distance > 0 // - distance <= (*ptr_ptr - start) // - length <= (end - *ptr_ptr) -static inline uint32_t wuffs_base__io_writer__copy_n_from_history__bco( +static inline uint32_t wuffs_base__io_writer__copy_n_from_history_fast( uint8_t** ptr_ptr, uint8_t* start, uint8_t* end, diff --git a/gen/c/std/crc32.c b/gen/c/std/crc32.c index 77b305a3..eaacbe8b 100644 --- a/gen/c/std/crc32.c +++ b/gen/c/std/crc32.c @@ -2360,7 +2360,7 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( // 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'. // - // See also wuffs_base__io_writer__copy_n_from_history__bco below. + // See also wuffs_base__io_writer__copy_n_from_history_fast below. // // Alternatively, or additionally, have a sloppy_copy_n_from_history method // that copies 8 bytes at a time, possibly writing more than length bytes? @@ -2376,13 +2376,13 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( return length; } -// wuffs_base__io_writer__copy_n_from_history__bco is a Bounds Check Optimized -// version of the wuffs_base__io_writer__copy_n_from_history function above. -// The caller needs to prove that: +// 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: // - distance > 0 // - distance <= (*ptr_ptr - start) // - length <= (end - *ptr_ptr) -static inline uint32_t wuffs_base__io_writer__copy_n_from_history__bco( +static inline uint32_t wuffs_base__io_writer__copy_n_from_history_fast( uint8_t** ptr_ptr, uint8_t* start, uint8_t* end, diff --git a/gen/c/std/deflate.c b/gen/c/std/deflate.c index 42d9662f..7862ffca 100644 --- a/gen/c/std/deflate.c +++ b/gen/c/std/deflate.c @@ -2453,7 +2453,7 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( // 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'. // - // See also wuffs_base__io_writer__copy_n_from_history__bco below. + // See also wuffs_base__io_writer__copy_n_from_history_fast below. // // Alternatively, or additionally, have a sloppy_copy_n_from_history method // that copies 8 bytes at a time, possibly writing more than length bytes? @@ -2469,13 +2469,13 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( return length; } -// wuffs_base__io_writer__copy_n_from_history__bco is a Bounds Check Optimized -// version of the wuffs_base__io_writer__copy_n_from_history function above. -// The caller needs to prove that: +// 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: // - distance > 0 // - distance <= (*ptr_ptr - start) // - length <= (end - *ptr_ptr) -static inline uint32_t wuffs_base__io_writer__copy_n_from_history__bco( +static inline uint32_t wuffs_base__io_writer__copy_n_from_history_fast( uint8_t** ptr_ptr, uint8_t* start, uint8_t* end, @@ -4168,7 +4168,7 @@ label_0_continue:; goto exit; } } - wuffs_base__io_writer__copy_n_from_history__bco( + wuffs_base__io_writer__copy_n_from_history_fast( &ioptr_dst, a_dst.private_impl.bounds[0], iobounds1_dst, v_length, (v_dist_minus_1 + 1)); goto label_2_break; diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index 9f08fa98..b3fafd13 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -2615,7 +2615,7 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( // 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'. // - // See also wuffs_base__io_writer__copy_n_from_history__bco below. + // See also wuffs_base__io_writer__copy_n_from_history_fast below. // // Alternatively, or additionally, have a sloppy_copy_n_from_history method // that copies 8 bytes at a time, possibly writing more than length bytes? @@ -2631,13 +2631,13 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( return length; } -// wuffs_base__io_writer__copy_n_from_history__bco is a Bounds Check Optimized -// version of the wuffs_base__io_writer__copy_n_from_history function above. -// The caller needs to prove that: +// 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: // - distance > 0 // - distance <= (*ptr_ptr - start) // - length <= (end - *ptr_ptr) -static inline uint32_t wuffs_base__io_writer__copy_n_from_history__bco( +static inline uint32_t wuffs_base__io_writer__copy_n_from_history_fast( uint8_t** ptr_ptr, uint8_t* start, uint8_t* end, diff --git a/gen/c/std/gzip.c b/gen/c/std/gzip.c index 78bd901a..3e2f091f 100644 --- a/gen/c/std/gzip.c +++ b/gen/c/std/gzip.c @@ -2660,7 +2660,7 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( // 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'. // - // See also wuffs_base__io_writer__copy_n_from_history__bco below. + // See also wuffs_base__io_writer__copy_n_from_history_fast below. // // Alternatively, or additionally, have a sloppy_copy_n_from_history method // that copies 8 bytes at a time, possibly writing more than length bytes? @@ -2676,13 +2676,13 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( return length; } -// wuffs_base__io_writer__copy_n_from_history__bco is a Bounds Check Optimized -// version of the wuffs_base__io_writer__copy_n_from_history function above. -// The caller needs to prove that: +// 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: // - distance > 0 // - distance <= (*ptr_ptr - start) // - length <= (end - *ptr_ptr) -static inline uint32_t wuffs_base__io_writer__copy_n_from_history__bco( +static inline uint32_t wuffs_base__io_writer__copy_n_from_history_fast( uint8_t** ptr_ptr, uint8_t* start, uint8_t* end, diff --git a/gen/c/std/lzw.c b/gen/c/std/lzw.c index b006c620..aa90265d 100644 --- a/gen/c/std/lzw.c +++ b/gen/c/std/lzw.c @@ -2391,7 +2391,7 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( // 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'. // - // See also wuffs_base__io_writer__copy_n_from_history__bco below. + // See also wuffs_base__io_writer__copy_n_from_history_fast below. // // Alternatively, or additionally, have a sloppy_copy_n_from_history method // that copies 8 bytes at a time, possibly writing more than length bytes? @@ -2407,13 +2407,13 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( return length; } -// wuffs_base__io_writer__copy_n_from_history__bco is a Bounds Check Optimized -// version of the wuffs_base__io_writer__copy_n_from_history function above. -// The caller needs to prove that: +// 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: // - distance > 0 // - distance <= (*ptr_ptr - start) // - length <= (end - *ptr_ptr) -static inline uint32_t wuffs_base__io_writer__copy_n_from_history__bco( +static inline uint32_t wuffs_base__io_writer__copy_n_from_history_fast( uint8_t** ptr_ptr, uint8_t* start, uint8_t* end, diff --git a/gen/c/std/zlib.c b/gen/c/std/zlib.c index 28206ddd..ef068752 100644 --- a/gen/c/std/zlib.c +++ b/gen/c/std/zlib.c @@ -2657,7 +2657,7 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( // 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'. // - // See also wuffs_base__io_writer__copy_n_from_history__bco below. + // See also wuffs_base__io_writer__copy_n_from_history_fast below. // // Alternatively, or additionally, have a sloppy_copy_n_from_history method // that copies 8 bytes at a time, possibly writing more than length bytes? @@ -2673,13 +2673,13 @@ static inline uint32_t wuffs_base__io_writer__copy_n_from_history( return length; } -// wuffs_base__io_writer__copy_n_from_history__bco is a Bounds Check Optimized -// version of the wuffs_base__io_writer__copy_n_from_history function above. -// The caller needs to prove that: +// 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: // - distance > 0 // - distance <= (*ptr_ptr - start) // - length <= (end - *ptr_ptr) -static inline uint32_t wuffs_base__io_writer__copy_n_from_history__bco( +static inline uint32_t wuffs_base__io_writer__copy_n_from_history_fast( uint8_t** ptr_ptr, uint8_t* start, uint8_t* end, diff --git a/lang/builtin/builtin.go b/lang/builtin/builtin.go index 3beee512..58bd658f 100644 --- a/lang/builtin/builtin.go +++ b/lang/builtin/builtin.go @@ -158,8 +158,8 @@ var Funcs = []string{ "io_reader.read_u64be?()(ret u64)", "io_reader.read_u64le?()(ret u64)", - // TODO: these should have an explicit precondition "available() >= N". For - // now, that's implicitly checked (i.e. hard coded). + // TODO: these should have an explicit pre-condition "available() >= N". + // For now, that's implicitly checked (i.e. hard coded). // // The io_reader has peek_etc methods and skip_fast, not read_etc_fast, // because we sometimes advance the pointer by less than what's read. See @@ -188,9 +188,9 @@ var Funcs = []string{ "io_reader.skip?(n u32)()", - // TODO: this should have explicit preconditions "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 + // 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)()", @@ -212,8 +212,8 @@ var Funcs = []string{ "io_writer.write_u64be?(x u64)()", "io_writer.write_u64le?(x u64)()", - // TODO: these should have an explicit precondition "available() >= N". For - // now, that's implicitly checked (i.e. hard coded). + // TODO: these should have an explicit pre-condition "available() >= N". + // For now, that's implicitly checked (i.e. hard coded). // // The io_writer has write_fast_etc methods, not poke_etc and skip_fast, // because skip_fast could leave uninitialized bytes in the io_buffer. diff --git a/lang/check/bounds.go b/lang/check/bounds.go index 84b50331..4daaeb01 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -976,7 +976,7 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (a.Bounds, actual := args[0].AsArg().Value() worstCase := args[1].AsArg().Value() if err := q.proveBinaryOp(t.IDXBinaryLessEq, actual, worstCase); err == errFailed { - return a.Bounds{}, fmt.Errorf("check: could not prove skip_fast precondition: %s <= %s", + return a.Bounds{}, fmt.Errorf("check: could not prove skip_fast pre-condition: %s <= %s", actual.Str(q.tm), worstCase.Str(q.tm)) } else if err != nil { return a.Bounds{}, err @@ -997,7 +997,7 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (a.Bounds, if ok, err := q.optimizeIOMethodAdvance(recv, advance, update); err != nil { return a.Bounds{}, err } else if !ok { - return a.Bounds{}, fmt.Errorf("check: could not prove %s precondition: %s.available() >= %v", + return a.Bounds{}, fmt.Errorf("check: could not prove %s pre-condition: %s.available() >= %v", method.Str(q.tm), recv.Str(q.tm), advance) } // TODO: drop other recv-related facts?