about summary refs log tree commit diff
path: root/src/libstd/sys/unix/process/process_unix.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-08-11 16:00:09 -0700
committerAlex Crichton <alex@alexcrichton.com>2017-08-12 11:06:45 -0700
commit3a831653d06ceef975b80ef4e41ee0679b44c364 (patch)
treef924b61ef792a981b286ac8c9f191e6f5d6614a2 /src/libstd/sys/unix/process/process_unix.rs
parentfae60b36cb48b1d5827eaaee656f0ff1a6cc6894 (diff)
downloadrust-3a831653d06ceef975b80ef4e41ee0679b44c364.tar.gz
rust-3a831653d06ceef975b80ef4e41ee0679b44c364.zip
std: Unsafe-away runtime checks in `Vec`
The `RawVec` type has a number of invariants that it upholds throughout its
execution, and as a result many of the runtime checks imposed by using `Layout`
in a "raw" fashion aren't actually necessary. For example a `RawVec`'s capacity
is intended to always match the layout which "fits" the allocation, so we don't
need any runtime checks when retrieving the current `Layout` for a vector.
Consequently, this adds a safe `current_layout` function which internally uses
the `from_size_align_unchecked` function.

Along the same lines we know that most construction of new layouts will not
overflow. All allocations in `RawVec` are kept below `isize::MAX` and valid
alignments are also kept low enough that we're guaranteed that `Layout` for a
doubled vector will never overflow and will always succeed construction.
Consequently a few locations can use `from_size_align_unchecked` in addition
when constructing the *new* layout to allocate (or reallocate), which allows for
eliding some more runtime checks.

Overall this should significant improve performance for an important function,
`RawVec::double`. This commit removes four runtime jumps before `__rust_realloc`
is called, as well as one after it's called.
Diffstat (limited to 'src/libstd/sys/unix/process/process_unix.rs')
0 files changed, 0 insertions, 0 deletions