Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3716 +/- ##
=======================================
Coverage 92.94% 92.94%
=======================================
Files 16 16
Lines 2466 2466
=======================================
Hits 2292 2292
Misses 174 174 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
joshlf
left a comment
There was a problem hiding this comment.
Would it be possible to use Kani to completely prove the correctness of this fast path for usize? IIRC we were unable to do that for the full version of the algorithm.
|
@joshlf Unfortunately, not really. For this particular case, we can prove panic freedom (i.e., that we can merely call the method) and that |
This routine begins by rounding `bytes_len` down to the nearest multiple of `align` (thus computing the intermediary `max_total_bytes`), subtracting the offset of the trailing slice, and calculating how many elements (`elems`) fit in that space. Then, in an expensive computation involving `elems`, the element size, the trailing slice offset, `align`, the total `self_bytes` is computed. This commit observes that when the element size is no larger than the `align`, `self_bytes` is simply equal to `max_total_bytes`. For example, if `max_total_bytes` is 16 bytes, the header occupies 9 bytes and two 3-byte elements fit, they would occupy 15 bytes altogether, leaving 1 byte in excess. This excess must be smaller than one element, otherwise another element would fit. When `elem_size <= align`, the gap is smaller than `align` and trailing padding fills it exactly. gherrit-pr-id: G463fe47353c89d061e6458fa9c4bd19328a954a8
cc5799d to
6f00605
Compare
|
Obsoleted (for now) by #3659. |
This routine begins by rounding
bytes_lendown to the nearest multiple ofalign(thus computing the intermediarymax_total_bytes), subtracting theoffset of the trailing slice, and calculating how many elements (
elems) fit inthat space. Then, in an expensive computation involving
elems, the elementsize, the trailing slice offset,
align, the totalself_bytesis computed.This commit observes that when the element size is no larger than the
align,self_bytesis simply equal tomax_total_bytes. For example, ifmax_total_bytesis 16 bytes, the header occupies 9 bytes and two 3-byteelements fit, they would occupy 15 bytes altogether, leaving 1 byte in excess.
This excess must be smaller than one element, otherwise another element would
fit. When
elem_size <= align, the gap is smaller thanalignand trailingpadding fills it exactly.
validate_cast_and_convert_metadata#3716Latest Update: v4 — Compare vs v3
📚 Full Patch History
Links show the diff between the row version and the column version.
⬇️ Download this PR
Branch
git fetch origin refs/heads/G463fe47353c89d061e6458fa9c4bd19328a954a8 && git checkout -b pr-G463fe47353c89d061e6458fa9c4bd19328a954a8 FETCH_HEADCheckout
git fetch origin refs/heads/G463fe47353c89d061e6458fa9c4bd19328a954a8 && git checkout FETCH_HEADCherry Pick
git fetch origin refs/heads/G463fe47353c89d061e6458fa9c4bd19328a954a8 && git cherry-pick FETCH_HEADPull
Stacked PRs enabled by GHerrit.