Skip to content

Commit 86162a9

Browse files
committed
---
yaml --- r: 236114 b: refs/heads/stable c: fd13bdf h: refs/heads/master v: v3
1 parent ce01770 commit 86162a9

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: b53406f8241edb45eb962795da99cb2cf73d8c1a
32+
refs/heads/stable: fd13bdf626a50b5b21afbbe87806dc346f8ea9d7
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/doc/tarpl/vec-alloc.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ like the standard library as much as possible, so we'll just kill the whole
6161
program.
6262

6363
We said we don't want to use intrinsics, so doing *exactly* what `std` does is
64-
out. `std::rt::util::abort` actually exists, but it takes a message to print,
65-
which will probably allocate. Also it's still unstable. Instead, we'll call
66-
`std::process::exit` with some random number.
64+
out. Instead, we'll call `std::process::exit` with some random number.
6765

6866
```rust
6967
fn oom() {
@@ -78,7 +76,7 @@ if cap == 0:
7876
allocate()
7977
cap = 1
8078
else:
81-
reallocate
79+
reallocate()
8280
cap *= 2
8381
```
8482

@@ -109,7 +107,7 @@ the same location in memory, the operations need to be done to the same value,
109107
and they can't just be merged afterwards.
110108

111109
When you use GEP inbounds, you are specifically telling LLVM that the offsets
112-
you're about to do are within the bounds of a single allocated entity. The
110+
you're about to do are within the bounds of a single "allocated" entity. The
113111
ultimate payoff being that LLVM can assume that if two pointers are known to
114112
point to two disjoint objects, all the offsets of those pointers are *also*
115113
known to not alias (because you won't just end up in some random place in
@@ -162,7 +160,8 @@ elements. This is a runtime no-op because every element takes up no space,
162160
and it's fine to pretend that there's infinite zero-sized types allocated
163161
at `0x01`. No allocator will ever allocate that address, because they won't
164162
allocate `0x00` and they generally allocate to some minimal alignment higher
165-
than a byte.
163+
than a byte. Also generally the whole first page of memory is
164+
protected from being allocated anyway (a whole 4k, on many platforms).
166165

167166
However what about for positive-sized types? That one's a bit trickier. In
168167
principle, you can argue that offsetting by 0 gives LLVM no information: either

branches/stable/src/doc/tarpl/vec-drain.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl<T> Vec<T> {
8383
pub fn into_iter(self) -> IntoIter<T> {
8484
unsafe {
8585
let iter = RawValIter::new(&self);
86+
8687
let buf = ptr::read(&self.buf);
8788
mem::forget(self);
8889
@@ -112,7 +113,7 @@ pub struct Drain<'a, T: 'a> {
112113
113114
impl<'a, T> Iterator for Drain<'a, T> {
114115
type Item = T;
115-
fn next(&mut self) -> Option<T> { self.iter.next_back() }
116+
fn next(&mut self) -> Option<T> { self.iter.next() }
116117
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
117118
}
118119

branches/stable/src/doc/tarpl/vec-layout.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
% Layout
22

3-
First off, we need to come up with the struct layout. Naively we want this
4-
design:
3+
First off, we need to come up with the struct layout. A Vec has three parts:
4+
a pointer to the allocation, the size of the allocation, and the number of
5+
elements that have been initialized.
6+
7+
Naively, this means we just want this design:
58

69
```rust
710
pub struct Vec<T> {

branches/stable/src/doc/tarpl/vec-raw.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
% RawVec
22

33
We've actually reached an interesting situation here: we've duplicated the logic
4-
for specifying a buffer and freeing its memory. Now that we've implemented it
5-
and identified *actual* logic duplication, this is a good time to perform some
6-
logic compression.
4+
for specifying a buffer and freeing its memory in Vec and IntoIter. Now that
5+
we've implemented it and identified *actual* logic duplication, this is a good
6+
time to perform some logic compression.
77

88
We're going to abstract out the `(ptr, cap)` pair and give them the logic for
99
allocating, growing, and freeing:
@@ -64,7 +64,7 @@ impl<T> Drop for RawVec<T> {
6464
}
6565
```
6666

67-
And change vec as follows:
67+
And change Vec as follows:
6868

6969
```rust,ignore
7070
pub struct Vec<T> {

branches/stable/src/doc/tarpl/vec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bit nicer or efficient because intrinsics are permanently unstable. Although
1212
many intrinsics *do* become stabilized elsewhere (`std::ptr` and `str::mem`
1313
consist of many intrinsics).
1414

15-
Ultimately this means out implementation may not take advantage of all
15+
Ultimately this means our implementation may not take advantage of all
1616
possible optimizations, though it will be by no means *naive*. We will
1717
definitely get into the weeds over nitty-gritty details, even
1818
when the problem doesn't *really* merit it.

0 commit comments

Comments
 (0)