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 #72228

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 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
e734e31
Small doc improvements.
Julian-Wollersberger Apr 25, 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
00dcb66
cmdline: Make target features individually overridable
petrochenkov May 10, 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
1be5d1e
Unified `unescape_{char,byte,str,byte_str,raw_str,raw_byte_str}` meth…
Julian-Wollersberger May 13, 2020
18cc63d
Unified `validate_{byte,str,raw_str,raw_byte_str}_escape` methods int…
Julian-Wollersberger May 13, 2020
43ae785
Replace some usages of the old `unescape_` functions in AST, clippy a…
Julian-Wollersberger May 13, 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
32606d7
Rollup merge of #69659 - CAD97:step-rework-take-3, r=Amanieu
RalfJung May 15, 2020
afe4b8a
Rollup merge of #71872 - nnethercote:less-aggressive-arena-growth, r=…
RalfJung May 15, 2020
1df77aa
Rollup merge of #72047 - Julian-Wollersberger:literal_error_reporting…
RalfJung May 15, 2020
5b56f76
Rollup merge of #72090 - RalfJung:rustc_driver-exit-code, r=oli-obk
RalfJung May 15, 2020
7dc2c01
Rollup merge of #72094 - petrochenkov:overfeature, r=nikic
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
10 changes: 9 additions & 1 deletion src/doc/rustc/src/codegen-options/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,15 @@ machine. Each target has a default base CPU.

Individual targets will support different features; this flag lets you control
enabling or disabling a feature. Each feature should be prefixed with a `+` to
enable it or `-` to disable it. Separate multiple features with commas.
enable it or `-` to disable it.

Features from multiple `-C target-feature` options are combined. \
Multiple features can be specified in a single option by separating them
with commas - `-C target-feature=+x,-y`. \
If some feature is specified more than once with both `+` and `-`,
then values passed later override values passed earlier. \
For example, `-C target-feature=+x,-y,+z -Ctarget-feature=-x,+y`
is equivalent to `-C target-feature=-x,+y,+z`.

To see the valid options and an example of use, run `rustc --print
target-features`.
Expand Down
39 changes: 26 additions & 13 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
//! of individual objects while the arena itself is still alive. The benefit
//! of an arena is very fast allocation; just a pointer bump.
//!
//! This crate implements `TypedArena`, a simple arena that can only hold
//! objects of a single type.
//! This crate implements several kinds of arena.

#![doc(
html_root_url = "https://doc.rust-lang.org/nightly/",
Expand Down Expand Up @@ -98,7 +97,13 @@ impl<T> TypedArenaChunk<T> {
}
}

// The arenas start with PAGE-sized chunks, and then each new chunk is twice as
// big as its predecessor, up until we reach HUGE_PAGE-sized chunks, whereupon
// we stop growing. This scales well, from arenas that are barely used up to
// arenas that are used for 100s of MiBs. Note also that the chosen sizes match
// the usual sizes of pages and huge pages on Linux.
const PAGE: usize = 4096;
const HUGE_PAGE: usize = 2 * 1024 * 1024;

impl<T> Default for TypedArena<T> {
/// Creates a new `TypedArena`.
Expand Down Expand Up @@ -211,6 +216,9 @@ impl<T> TypedArena<T> {
#[cold]
fn grow(&self, n: usize) {
unsafe {
// We need the element size in to convert chunk sizes (ranging from
// PAGE to HUGE_PAGE bytes) to element counts.
let elem_size = cmp::max(1, mem::size_of::<T>());
let mut chunks = self.chunks.borrow_mut();
let (chunk, mut new_capacity);
if let Some(last_chunk) = chunks.last_mut() {
Expand All @@ -221,18 +229,20 @@ impl<T> TypedArena<T> {
self.end.set(last_chunk.end());
return;
} else {
// If the previous chunk's capacity is less than HUGE_PAGE
// bytes, then this chunk will be least double the previous
// chunk's size.
new_capacity = last_chunk.storage.capacity();
loop {
if new_capacity < HUGE_PAGE / elem_size {
new_capacity = new_capacity.checked_mul(2).unwrap();
if new_capacity >= currently_used_cap + n {
break;
}
}
}
} else {
let elem_size = cmp::max(1, mem::size_of::<T>());
new_capacity = cmp::max(n, PAGE / elem_size);
new_capacity = PAGE / elem_size;
}
// Also ensure that this chunk can fit `n`.
new_capacity = cmp::max(n, new_capacity);

chunk = TypedArenaChunk::<T>::new(new_capacity);
self.ptr.set(chunk.start());
self.end.set(chunk.end());
Expand Down Expand Up @@ -347,17 +357,20 @@ impl DroplessArena {
self.end.set(last_chunk.end());
return;
} else {
// If the previous chunk's capacity is less than HUGE_PAGE
// bytes, then this chunk will be least double the previous
// chunk's size.
new_capacity = last_chunk.storage.capacity();
loop {
if new_capacity < HUGE_PAGE {
new_capacity = new_capacity.checked_mul(2).unwrap();
if new_capacity >= used_bytes + needed_bytes {
break;
}
}
}
} else {
new_capacity = cmp::max(needed_bytes, PAGE);
new_capacity = PAGE;
}
// Also ensure that this chunk can fit `needed_bytes`.
new_capacity = cmp::max(needed_bytes, new_capacity);

chunk = TypedArenaChunk::<u8>::new(new_capacity);
self.ptr.set(chunk.start());
self.end.set(chunk.end());
Expand Down
Loading