Skip to content

Commit d72b94a

Browse files
author
Julian Orth
committed
---
yaml --- r: 131022 b: refs/heads/try c: d34992e h: refs/heads/master v: v3
1 parent 9fa5dca commit d72b94a

File tree

229 files changed

+5572
-9383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+5572
-9383
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 9c68679f2ebd5b165694e9346e4ad96a3e32aceb
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6faa4f33a42de32579e02a8d030db920d360e2b5
5-
refs/heads/try: 5c3987985e919a47826dd5d68a7cf1b50c8837cf
5+
refs/heads/try: d34992ecbabc8c7e5e7edc82ec0e2caa083c5517
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/compiletest/runtest.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,10 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
15771577

15781578
// codegen tests (vs. clang)
15791579

1580+
fn make_o_name(config: &Config, testfile: &Path) -> Path {
1581+
output_base_name(config, testfile).with_extension("o")
1582+
}
1583+
15801584
fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
15811585
if suffix.len() == 0 {
15821586
(*p).clone()
@@ -1592,13 +1596,14 @@ fn compile_test_and_save_bitcode(config: &Config, props: &TestProps,
15921596
// FIXME (#9639): This needs to handle non-utf8 paths
15931597
let link_args = vec!("-L".to_string(),
15941598
aux_dir.as_str().unwrap().to_string());
1595-
let llvm_args = vec!("--emit=bc,obj".to_string(),
1596-
"--crate-type=lib".to_string());
1599+
let llvm_args = vec!("--emit=obj".to_string(),
1600+
"--crate-type=lib".to_string(),
1601+
"-C".to_string(),
1602+
"save-temps".to_string());
15971603
let args = make_compile_args(config,
15981604
props,
15991605
link_args.append(llvm_args.as_slice()),
1600-
|a, b| ThisDirectory(output_base_name(a, b).dir_path()),
1601-
testfile);
1606+
|a, b| ThisFile(make_o_name(a, b)), testfile);
16021607
compose_and_run_compiler(config, props, testfile, args, None)
16031608
}
16041609

branches/try/src/doc/complement-lang-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ We want to maintain the option to parametrize at runtime. We may eventually chan
8383

8484
## Why aren't values type-parametric? Why only items?
8585

86-
Doing so would make type inference much more complex, and require the implementation strategy of runtime parameterization.
86+
Doing so would make type inference much more complex, and require the implementation strategy of runtime parametrization.
8787

8888
## Why are enumerations nominal and closed?
8989

branches/try/src/doc/guide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ but also working properly. And printing information to the screen is a pretty
116116
common thing to do.
117117

118118
The first thing that we need to do is make a file to put our code in. I like
119-
to make a `projects` directory in my home directory, and keep all my projects
119+
to make a projects directory in my home directory, and keep all my projects
120120
there. Rust does not care where your code lives.
121121

122122
This actually leads to one other concern we should address: this tutorial will
@@ -765,7 +765,7 @@ This is a deliberate design decision. While full-program inference is possible,
765765
languages which have it, like Haskell, often suggest that documenting your
766766
types explicitly is a best-practice. We agree that forcing functions to declare
767767
types while allowing for inference inside of function bodies is a wonderful
768-
sweet spot between full inference and no inference.
768+
compromise between full inference and no inference.
769769

770770
What about returning a value? Here's a function that adds one to an integer:
771771

@@ -1808,7 +1808,7 @@ our code in this file. We'll talk about multiple-file projects later on in the
18081808
guide.
18091809

18101810
Before we move on, let me show you one more Cargo command: `run`. `cargo run`
1811-
is kind of like `cargo build`, but it also then runs the produced executable.
1811+
is kind of like `cargo build`, but it also then runs the produced exectuable.
18121812
Try it out:
18131813

18141814
```{notrust,ignore}

branches/try/src/doc/rust.md

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ On `struct`s:
19541954

19551955
- `repr` - specifies the representation to use for this struct. Takes a list
19561956
of options. The currently accepted ones are `C` and `packed`, which may be
1957-
combined. `C` will use a C ABI compatible struct layout, and `packed` will
1957+
combined. `C` will use a C ABI comptible struct layout, and `packed` will
19581958
remove any padding between fields (note that this is very fragile and may
19591959
break platforms which require aligned access).
19601960

@@ -2221,8 +2221,8 @@ These types help drive the compiler's analysis
22212221
: This type does not implement "copy", even if eligible
22222222
* `no_send_bound`
22232223
: This type does not implement "send", even if eligible
2224-
* `no_sync_bound`
2225-
: This type does not implement "sync", even if eligible
2224+
* `no_share_bound`
2225+
: This type does not implement "share", even if eligible
22262226
* `eh_personality`
22272227
: ___Needs filling in___
22282228
* `exchange_free`
@@ -2367,7 +2367,7 @@ One can indicate the stability of an API using the following attributes:
23672367
These levels are directly inspired by
23682368
[Node.js' "stability index"](http://nodejs.org/api/documentation.html).
23692369

2370-
Stability levels are inherited, so an item's stability attribute is the
2370+
Stability levels are inherited, so an items's stability attribute is the
23712371
default stability for everything nested underneath it.
23722372

23732373
There are lints for disallowing items marked with certain levels: `deprecated`,
@@ -2444,7 +2444,7 @@ The currently implemented features of the reference compiler are:
24442444

24452445
* `concat_idents` - Allows use of the `concat_idents` macro, which is in many
24462446
ways insufficient for concatenating identifiers, and may
2447-
be removed entirely for something more wholesome.
2447+
be removed entirely for something more wholsome.
24482448

24492449
* `default_type_params` - Allows use of default type parameters. The future of
24502450
this feature is uncertain.
@@ -3604,7 +3604,7 @@ of the type.[^structtype]
36043604

36053605
New instances of a `struct` can be constructed with a [struct expression](#structure-expressions).
36063606

3607-
The memory layout of a `struct` is undefined by default to allow for compiler optimizations like
3607+
The memory layout of a `struct` is undefined by default to allow for compiler optimziations like
36083608
field reordering, but it can be fixed with the `#[repr(...)]` attribute.
36093609
In either case, fields may be given in any order in a corresponding struct *expression*;
36103610
the resulting `struct` value will always have the same memory layout.
@@ -3668,17 +3668,32 @@ let a: List<int> = Cons(7, box Cons(13, box Nil));
36683668

36693669
All pointers in Rust are explicit first-class values.
36703670
They can be copied, stored into data structures, and returned from functions.
3671-
There are two varieties of pointer in Rust:
3671+
There are four varieties of pointer in Rust:
3672+
3673+
* Owning pointers (`Box`)
3674+
: These point to owned heap allocations (or "boxes") in the shared, inter-task heap.
3675+
Each owned box has a single owning pointer; pointer and pointee retain a 1:1 relationship at all times.
3676+
Owning pointers are written `Box<content>`,
3677+
for example `Box<int>` means an owning pointer to an owned box containing an integer.
3678+
Copying an owned box is a "deep" operation:
3679+
it involves allocating a new owned box and copying the contents of the old box into the new box.
3680+
Releasing an owning pointer immediately releases its corresponding owned box.
36723681

36733682
* References (`&`)
36743683
: These point to memory _owned by some other value_.
3675-
A reference type is written `&type` for some lifetime-variable `f`,
3676-
or just `&'a type` when you need an explicit lifetime.
3684+
References arise by (automatic) conversion from owning pointers, managed pointers,
3685+
or by applying the borrowing operator `&` to some other value,
3686+
including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries).
3687+
A borrow expression is written `&content`.
3688+
3689+
A reference type is written `&'f type` for some lifetime-variable `f`,
3690+
or just `&type` when the lifetime can be elided;
3691+
for example `&int` means a reference to an integer.
36773692
Copying a reference is a "shallow" operation:
36783693
it involves only copying the pointer itself.
36793694
Releasing a reference typically has no effect on the value it points to,
3680-
with the exception of temporary values, which are released when the last
3681-
reference to them is released.
3695+
with the exception of temporary values,
3696+
which are released when the last reference to them is released.
36823697

36833698
* Raw pointers (`*`)
36843699
: Raw pointers are pointers without safety or liveness guarantees.
@@ -3691,9 +3706,6 @@ There are two varieties of pointer in Rust:
36913706
they exist to support interoperability with foreign code,
36923707
and writing performance-critical or low-level functions.
36933708

3694-
The standard library contains addtional 'smart pointer' types beyond references
3695-
and raw pointers.
3696-
36973709
### Function types
36983710

36993711
The function type constructor `fn` forms new function types.
@@ -4202,7 +4214,7 @@ be ignored in favor of only building the artifacts specified by command line.
42024214
purpose of this output type is to create a static library containing all of
42034215
the local crate's code along with all upstream dependencies. The static
42044216
library is actually a `*.a` archive on linux and osx and a `*.lib` file on
4205-
windows. This format is recommended for use in situations such as linking
4217+
windows. This format is recommended for use in situtations such as linking
42064218
Rust code into an existing non-Rust application because it will not have
42074219
dynamic dependencies on other Rust code.
42084220

branches/try/src/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
// except according to those terms.
1010

1111
#[cfg(rustdoc)]
12-
extern crate "rustdoc" as this;
12+
extern crate this = "rustdoc";
1313

1414
#[cfg(rustc)]
15-
extern crate "rustc" as this;
15+
extern crate this = "rustc";
1616

1717
fn main() { this::main() }

branches/try/src/liballoc/heap.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use core::ptr::RawPtr;
1616
#[cfg(not(test))] use core::raw;
17-
#[cfg(stage0, not(test))] use util;
17+
#[cfg(not(test))] use util;
1818

1919
/// Returns a pointer to `size` bytes of memory.
2020
///
@@ -119,7 +119,7 @@ unsafe fn exchange_free(ptr: *mut u8, size: uint, align: uint) {
119119
}
120120

121121
// FIXME: #7496
122-
#[cfg(stage0, not(test))]
122+
#[cfg(not(test))]
123123
#[lang="closure_exchange_malloc"]
124124
#[inline]
125125
#[allow(deprecated)]
@@ -134,21 +134,6 @@ unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint,
134134
alloc as *mut u8
135135
}
136136

137-
// FIXME: #7496
138-
#[cfg(not(stage0), not(test))]
139-
#[lang="closure_exchange_malloc"]
140-
#[inline]
141-
#[allow(deprecated)]
142-
unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint,
143-
align: uint) -> *mut u8 {
144-
let p = allocate(size, align);
145-
146-
let alloc = p as *mut raw::Box<()>;
147-
(*alloc).drop_glue = drop_glue;
148-
149-
alloc as *mut u8
150-
}
151-
152137
#[cfg(jemalloc)]
153138
mod imp {
154139
use core::option::{None, Option};

branches/try/src/libarena/lib.rs

Lines changed: 47 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,17 @@ use std::mem;
3939
use std::num;
4040
use std::ptr;
4141
use std::rc::Rc;
42-
use std::rt::heap::{allocate, deallocate};
42+
use std::rt::heap::allocate;
4343

4444
// The way arena uses arrays is really deeply awful. The arrays are
4545
// allocated, and have capacities reserved, but the fill for the array
4646
// will always stay at 0.
4747
#[deriving(Clone, PartialEq)]
4848
struct Chunk {
49-
data: Rc<RefCell<Vec<u8>>>,
49+
data: Rc<RefCell<Vec<u8> >>,
5050
fill: Cell<uint>,
5151
is_copy: Cell<bool>,
5252
}
53-
5453
impl Chunk {
5554
fn capacity(&self) -> uint {
5655
self.data.borrow().capacity()
@@ -358,37 +357,38 @@ pub struct TypedArena<T> {
358357
end: Cell<*const T>,
359358

360359
/// A pointer to the first arena segment.
361-
first: RefCell<*mut TypedArenaChunk<T>>,
360+
first: RefCell<TypedArenaChunkRef<T>>,
362361
}
362+
type TypedArenaChunkRef<T> = Option<Box<TypedArenaChunk<T>>>;
363363

364364
struct TypedArenaChunk<T> {
365365
/// Pointer to the next arena segment.
366-
next: *mut TypedArenaChunk<T>,
366+
next: TypedArenaChunkRef<T>,
367367

368368
/// The number of elements that this chunk can hold.
369369
capacity: uint,
370370

371371
// Objects follow here, suitably aligned.
372372
}
373373

374-
fn calculate_size<T>(capacity: uint) -> uint {
375-
let mut size = mem::size_of::<TypedArenaChunk<T>>();
376-
size = round_up(size, mem::min_align_of::<T>());
377-
let elem_size = mem::size_of::<T>();
378-
let elems_size = elem_size.checked_mul(&capacity).unwrap();
379-
size = size.checked_add(&elems_size).unwrap();
380-
size
381-
}
382-
383374
impl<T> TypedArenaChunk<T> {
384375
#[inline]
385-
unsafe fn new(next: *mut TypedArenaChunk<T>, capacity: uint)
386-
-> *mut TypedArenaChunk<T> {
387-
let size = calculate_size::<T>(capacity);
388-
let chunk = allocate(size, mem::min_align_of::<TypedArenaChunk<T>>())
389-
as *mut TypedArenaChunk<T>;
390-
(*chunk).next = next;
391-
(*chunk).capacity = capacity;
376+
fn new(next: Option<Box<TypedArenaChunk<T>>>, capacity: uint)
377+
-> Box<TypedArenaChunk<T>> {
378+
let mut size = mem::size_of::<TypedArenaChunk<T>>();
379+
size = round_up(size, mem::min_align_of::<T>());
380+
let elem_size = mem::size_of::<T>();
381+
let elems_size = elem_size.checked_mul(&capacity).unwrap();
382+
size = size.checked_add(&elems_size).unwrap();
383+
384+
let mut chunk = unsafe {
385+
let chunk = allocate(size, mem::min_align_of::<TypedArenaChunk<T>>());
386+
let mut chunk: Box<TypedArenaChunk<T>> = mem::transmute(chunk);
387+
ptr::write(&mut chunk.next, next);
388+
chunk
389+
};
390+
391+
chunk.capacity = capacity;
392392
chunk
393393
}
394394

@@ -406,13 +406,14 @@ impl<T> TypedArenaChunk<T> {
406406
}
407407

408408
// Destroy the next chunk.
409-
let next = self.next;
410-
let size = calculate_size::<T>(self.capacity);
411-
deallocate(self as *mut TypedArenaChunk<T> as *mut u8, size,
412-
mem::min_align_of::<TypedArenaChunk<T>>());
413-
if next.is_not_null() {
414-
let capacity = (*next).capacity;
415-
(*next).destroy(capacity);
409+
let next_opt = mem::replace(&mut self.next, None);
410+
match next_opt {
411+
None => {}
412+
Some(mut next) => {
413+
// We assume that the next chunk is completely filled.
414+
let capacity = next.capacity;
415+
next.destroy(capacity)
416+
}
416417
}
417418
}
418419

@@ -447,13 +448,11 @@ impl<T> TypedArena<T> {
447448
/// objects.
448449
#[inline]
449450
pub fn with_capacity(capacity: uint) -> TypedArena<T> {
450-
unsafe {
451-
let chunk = TypedArenaChunk::<T>::new(ptr::mut_null(), capacity);
452-
TypedArena {
453-
ptr: Cell::new((*chunk).start() as *const T),
454-
end: Cell::new((*chunk).end() as *const T),
455-
first: RefCell::new(chunk),
456-
}
451+
let chunk = TypedArenaChunk::<T>::new(None, capacity);
452+
TypedArena {
453+
ptr: Cell::new(chunk.start() as *const T),
454+
end: Cell::new(chunk.end() as *const T),
455+
first: RefCell::new(Some(chunk)),
457456
}
458457
}
459458

@@ -477,28 +476,26 @@ impl<T> TypedArena<T> {
477476
/// Grows the arena.
478477
#[inline(never)]
479478
fn grow(&self) {
480-
unsafe {
481-
let chunk = *self.first.borrow_mut();
482-
let new_capacity = (*chunk).capacity.checked_mul(&2).unwrap();
483-
let chunk = TypedArenaChunk::<T>::new(chunk, new_capacity);
484-
self.ptr.set((*chunk).start() as *const T);
485-
self.end.set((*chunk).end() as *const T);
486-
*self.first.borrow_mut() = chunk
487-
}
479+
let chunk = self.first.borrow_mut().take().unwrap();
480+
let new_capacity = chunk.capacity.checked_mul(&2).unwrap();
481+
let chunk = TypedArenaChunk::<T>::new(Some(chunk), new_capacity);
482+
self.ptr.set(chunk.start() as *const T);
483+
self.end.set(chunk.end() as *const T);
484+
*self.first.borrow_mut() = Some(chunk)
488485
}
489486
}
490487

491488
#[unsafe_destructor]
492489
impl<T> Drop for TypedArena<T> {
493490
fn drop(&mut self) {
494-
unsafe {
495-
// Determine how much was filled.
496-
let start = self.first.borrow().as_ref().unwrap().start() as uint;
497-
let end = self.ptr.get() as uint;
498-
let diff = (end - start) / mem::size_of::<T>();
491+
// Determine how much was filled.
492+
let start = self.first.borrow().as_ref().unwrap().start() as uint;
493+
let end = self.ptr.get() as uint;
494+
let diff = (end - start) / mem::size_of::<T>();
499495

500-
// Pass that to the `destroy` method.
501-
(**self.first.borrow_mut()).destroy(diff)
496+
// Pass that to the `destroy` method.
497+
unsafe {
498+
self.first.borrow_mut().as_mut().unwrap().destroy(diff)
502499
}
503500
}
504501
}

0 commit comments

Comments
 (0)