Rename __bco to _fast

This commit is contained in:
Nigel Tao committed 2018-07-08 21:10:40 +10:00
1 parent 13284015cb
commit 8a449fa92e
13 files changed
+61 -61

No files matched your search

@@ -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,
+1 -1
View File
@@ -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",
+5 -5
View File
@@ -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 = "" +
+5 -5
View File
@@ -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,
+5 -5
View File
@@ -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,
+5 -5
View File
@@ -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,
+6 -6
View File
@@ -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;
+5 -5
View File
@@ -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,
+5 -5
View File
@@ -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,
+5 -5
View File
@@ -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,
+5 -5
View File
@@ -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,
+7 -7
View File
@@ -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.
+2 -2
View File
@@ -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?