Auto merge of #51630 - joshlf:map-split-perf, r=dtolnay

Optimize RefCell refcount tracking

Address the performance concern raised in https://github.com/rust-lang/rust/pull/51466#issuecomment-398255276

cc @dtolnay  @nnethercote @rust-lang/wg-compiler-performance

cc @RalfJung @jhjourdan for soundness concerns

Can somebody kick off a perf run on this? I'm not sure how that's done, but I understand it has to be started manually.

The idea of this change is to switch to representing mutable refcount as values below 0 to eliminate some branching that was required with the old algorithm.
This commit is contained in:
bors 2018-06-28 13:23:07 +00:00
commit 5d95db34a4
5 changed files with 40 additions and 34 deletions

View file

@ -19,5 +19,5 @@ fn assert<T: UnwindSafe + ?Sized>() {}
fn main() {
assert::<Rc<RefCell<i32>>>();
//~^ ERROR the type `std::cell::UnsafeCell<i32>` may contain interior mutability and a
//~| ERROR the type `std::cell::UnsafeCell<usize>` may contain interior mutability and a
//~| ERROR the type `std::cell::UnsafeCell<isize>` may contain interior mutability and a
}

View file

@ -19,5 +19,5 @@ fn assert<T: UnwindSafe + ?Sized>() {}
fn main() {
assert::<Arc<RefCell<i32>>>();
//~^ ERROR the type `std::cell::UnsafeCell<i32>` may contain interior mutability and a
//~| ERROR the type `std::cell::UnsafeCell<usize>` may contain interior mutability and a
//~| ERROR the type `std::cell::UnsafeCell<isize>` may contain interior mutability and a
}

View file

@ -18,5 +18,5 @@ fn assert<T: UnwindSafe + ?Sized>() {}
fn main() {
assert::<&RefCell<i32>>();
//~^ ERROR the type `std::cell::UnsafeCell<i32>` may contain interior mutability and a
//~| ERROR the type `std::cell::UnsafeCell<usize>` may contain interior mutability and a
//~| ERROR the type `std::cell::UnsafeCell<isize>` may contain interior mutability and a
}

View file

@ -18,5 +18,5 @@ fn assert<T: UnwindSafe + ?Sized>() {}
fn main() {
assert::<*mut RefCell<i32>>();
//~^ ERROR the type `std::cell::UnsafeCell<i32>` may contain interior mutability and a
//~| ERROR the type `std::cell::UnsafeCell<usize>` may contain interior mutability and a
//~| ERROR the type `std::cell::UnsafeCell<isize>` may contain interior mutability and a
}