Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #72226

Closed
wants to merge 26 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b70e7fd
Add inherent impls for unchecked math intrinsics
CAD97 Feb 3, 2020
2fcfd23
Redesign the Step trait
CAD97 Feb 18, 2020
f34322d
Adjust Step::forward_checked docs for large types
CAD97 Mar 14, 2020
c400f75
Miri interning: replace ICEs by proper errors, make intern_shallow ty…
RalfJung Apr 29, 2020
8e48a30
remove some dead code, and assert we do not swallow allocating errors
RalfJung Apr 29, 2020
ff39457
avoid raising interpreter errors from interning
RalfJung Apr 29, 2020
d3b2e1f
fmt
RalfJung Apr 29, 2020
a06740c
Typo
RalfJung Apr 29, 2020
e73ee41
rebase fallout
RalfJung May 4, 2020
23d880b
rustc_driver: factor out computing the exit code
RalfJung May 10, 2020
51e466d
rustc_driver::main: more informative return type
RalfJung May 10, 2020
5e35493
cargo update -p serde_derive
Xanewok May 5, 2020
403a9d0
cargo update -p failure_derive
Xanewok May 5, 2020
8c6e568
cargo update -p pest_generator
Xanewok May 5, 2020
3bdaced
cargo update -p derive-new
Xanewok May 5, 2020
e26f35d
rustbook: Bump mdbook dependency
Xanewok May 5, 2020
9111d8b
Fix the new capacity measurement in arenas.
nnethercote May 4, 2020
40d4868
Be less aggressive with `DroplessArena`/`TypedArena` growth.
nnethercote May 4, 2020
cef616b
Improve comments in iter::Step
CAD97 May 13, 2020
90b1961
Improve Step::forward/backward for optimization
CAD97 May 13, 2020
d53068e
improve step_integer_impls macro
CAD97 May 14, 2020
41f701a
Rollup merge of #69659 - CAD97:step-rework-take-3, r=Amanieu
RalfJung May 15, 2020
79ae6ee
Rollup merge of #71665 - RalfJung:miri-intern-no-ice, r=oli-obk
RalfJung May 15, 2020
201aa12
Rollup merge of #71872 - nnethercote:less-aggressive-arena-growth, r=…
RalfJung May 15, 2020
ae17c19
Rollup merge of #71919 - Xanewok:bump-syn-1, r=Mark-Simulacrum
RalfJung May 15, 2020
7d01ffc
Rollup merge of #72090 - RalfJung:rustc_driver-exit-code, r=oli-obk
RalfJung May 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve Step::forward/backward for optimization
The previous definition did not optimize down to a single add operation,
but this version does appear to.
CAD97 committed May 13, 2020
commit 90b196129b85b5b2ae795e9bd621b95d7bec17b4
26 changes: 12 additions & 14 deletions src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
@@ -202,26 +202,24 @@ macro_rules! step_identical_methods {

#[inline]
fn forward(start: Self, n: usize) -> Self {
match Self::forward_checked(start, n) {
Some(result) => result,
None => {
let result = Add::add(start, n as Self);
// add one modular cycle to ensure overflow occurs
Add::add(Add::add(result as $u, $u::MAX), 1) as Self
}
// In debug builds, trigger a panic on overflow.
// This should optimize completely out in release builds.
if Self::forward_checked(start, n).is_none() {
let _ = Add::add(Self::MAX, 1);
}
// Do wrapping math to allow e.g. `Step::forward(-128u8, 255)`.
start.wrapping_add(n as Self) as Self
}

#[inline]
fn backward(start: Self, n: usize) -> Self {
match Self::backward_checked(start, n) {
Some(result) => result,
None => {
let result = Sub::sub(start, n as Self);
// sub one modular cycle to ensure overflow occurs
Sub::sub(Sub::sub(result as $u, $u::MAX), 1) as Self
}
// In debug builds, trigger a panic on overflow.
// This should optimize completely out in release builds.
if Self::backward_checked(start, n).is_none() {
let _ = Sub::sub(Self::MIN, 1);
}
// Do wrapping math to allow e.g. `Step::backward(127u8, 255)`.
start.wrapping_sub(n as Self) as Self
}
};
}