Skip to content

Commit 30edb88

Browse files
committed
---
yaml --- r: 72686 b: refs/heads/dist-snap c: aca2a00 h: refs/heads/master v: v3
1 parent 7826750 commit 30edb88

File tree

352 files changed

+8487
-16697
lines changed

Some content is hidden

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

352 files changed

+8487
-16697
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 6cb273ed4efb6724b1c713c3ac35d14e52999fb1
10+
refs/heads/dist-snap: aca2a00fb4cf2ec182cb7802194813c5dd6bbf27
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/Makefile.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ endif
110110
ifdef SAVE_TEMPS
111111
CFG_RUSTC_FLAGS += --save-temps
112112
endif
113-
ifdef ASM_COMMENTS
114-
CFG_RUSTC_FLAGS += -z asm-comments
115-
endif
116113
ifdef TIME_PASSES
117114
CFG_RUSTC_FLAGS += -Z time-passes
118115
endif

branches/dist-snap/doc/rust.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,8 +1467,8 @@ A complete list of the built-in language items follows:
14671467
: Elements can be subtracted.
14681468
`mul`
14691469
: Elements can be multiplied.
1470-
`quot`
1471-
: Elements have a quotient operation.
1470+
`div`
1471+
: Elements have a division operation.
14721472
`rem`
14731473
: Elements have a remainder operation.
14741474
`neg`
@@ -1857,7 +1857,7 @@ The default meaning of the operators on standard types is given here.
18571857
Calls the `mul` method on the `core::ops::Mul` trait.
18581858
`/`
18591859
: Quotient.
1860-
Calls the `quot` method on the `core::ops::Quot` trait.
1860+
Calls the `div` method on the `core::ops::Div` trait.
18611861
`%`
18621862
: Remainder.
18631863
Calls the `rem` method on the `core::ops::Rem` trait.
@@ -2393,7 +2393,7 @@ variables in the arm's block, and control enters the block.
23932393
An example of an `match` expression:
23942394

23952395

2396-
~~~~ {.xfail-test}
2396+
~~~~
23972397
# fn process_pair(a: int, b: int) { }
23982398
# fn process_ten() { }
23992399

branches/dist-snap/mk/clean.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ clean-misc:
4848
$(Q)rm -f $(RUSTLLVM_LIB_OBJS) $(RUSTLLVM_OBJS_OBJS) $(RUSTLLVM_DEF)
4949
$(Q)rm -Rf $(DOCS)
5050
$(Q)rm -Rf $(GENERATED)
51-
$(Q)rm -f tmp/*.log tmp/*.rc tmp/*.rs tmp/*.ok
51+
$(Q)rm -f tmp/*
5252
$(Q)rm -Rf rust-stage0-*.tar.bz2 $(PKG_NAME)-*.tar.gz dist
5353
$(Q)rm -Rf $(foreach ext, \
5454
html aux cp fn ky log pdf pg toc tp vr cps, \

branches/dist-snap/src/compiletest/compiletest.rc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,3 @@ pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn {
223223
let testfile = testfile.to_str();
224224
test::DynTestFn(|| runtest::run(config, testfile))
225225
}
226-
227-
// Local Variables:
228-
// fill-column: 78;
229-
// indent-tabs-mode: nil
230-
// c-basic-offset: 4
231-
// buffer-file-coding-system: utf-8-unix
232-
// End:
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env python
2+
# xfail-license
3+
4+
# This creates the tables used for distributions implemented using the
5+
# ziggurat algorithm in `core::rand::distributions;`. They are
6+
# (basically) the tables as used in the ZIGNOR variant (Doornik 2005).
7+
# They are changed rarely, so the generated file should be checked in
8+
# to git.
9+
#
10+
# It creates 3 tables: X as in the paper, F which is f(x_i), and
11+
# F_DIFF which is f(x_i) - f(x_{i-1}). The latter two are just cached
12+
# values which is not done in that paper (but is done in other
13+
# variants). Note that the adZigR table is unnecessary because of
14+
# algebra.
15+
#
16+
# It is designed to be compatible with Python 2 and 3.
17+
18+
from math import exp, sqrt, log, floor
19+
import random
20+
21+
# The order should match the return value of `tables`
22+
TABLE_NAMES = ['X', 'F', 'F_DIFF']
23+
24+
# The actual length of the table is 1 more, to stop
25+
# index-out-of-bounds errors. This should match the bitwise operation
26+
# to find `i` in `zigurrat` in `libstd/rand/mod.rs`. Also the *_R and
27+
# *_V constants below depend on this value.
28+
TABLE_LEN = 256
29+
30+
# equivalent to `zigNorInit` in Doornik2005, but generalised to any
31+
# distribution. r = dR, v = dV, f = probability density function,
32+
# f_inv = inverse of f
33+
def tables(r, v, f, f_inv):
34+
# compute the x_i
35+
xvec = [0]*(TABLE_LEN+1)
36+
37+
xvec[0] = v / f(r)
38+
xvec[1] = r
39+
40+
for i in range(2, TABLE_LEN):
41+
last = xvec[i-1]
42+
xvec[i] = f_inv(v / last + f(last))
43+
44+
# cache the f's
45+
fvec = [0]*(TABLE_LEN+1)
46+
fdiff = [0]*(TABLE_LEN+1)
47+
for i in range(TABLE_LEN+1):
48+
fvec[i] = f(xvec[i])
49+
if i > 0:
50+
fdiff[i] = fvec[i] - fvec[i-1]
51+
52+
return xvec, fvec, fdiff
53+
54+
# Distributions
55+
# N(0, 1)
56+
def norm_f(x):
57+
return exp(-x*x/2.0)
58+
def norm_f_inv(y):
59+
return sqrt(-2.0*log(y))
60+
61+
NORM_R = 3.6541528853610088
62+
NORM_V = 0.00492867323399
63+
64+
NORM = tables(NORM_R, NORM_V,
65+
norm_f, norm_f_inv)
66+
67+
# Exp(1)
68+
def exp_f(x):
69+
return exp(-x)
70+
def exp_f_inv(y):
71+
return -log(y)
72+
73+
EXP_R = 7.69711747013104972
74+
EXP_V = 0.0039496598225815571993
75+
76+
EXP = tables(EXP_R, EXP_V,
77+
exp_f, exp_f_inv)
78+
79+
80+
# Output the tables/constants/types
81+
82+
def render_static(name, type, value):
83+
# no space or
84+
return 'pub static %s: %s =%s;\n' % (name, type, value)
85+
86+
# static `name`: [`type`, .. `len(values)`] =
87+
# [values[0], ..., values[3],
88+
# values[4], ..., values[7],
89+
# ... ];
90+
def render_table(name, values):
91+
rows = []
92+
# 4 values on each row
93+
for i in range(0, len(values), 4):
94+
row = values[i:i+4]
95+
rows.append(', '.join('%.18f' % f for f in row))
96+
97+
rendered = '\n [%s]' % ',\n '.join(rows)
98+
return render_static(name, '[f64, .. %d]' % len(values), rendered)
99+
100+
101+
with open('ziggurat_tables.rs', 'w') as f:
102+
f.write('''// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
103+
// file at the top-level directory of this distribution and at
104+
// http://rust-lang.org/COPYRIGHT.
105+
//
106+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
107+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
108+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
109+
// option. This file may not be copied, modified, or distributed
110+
// except according to those terms.
111+
112+
// Tables for distributions which are sampled using the ziggurat
113+
// algorithm. Autogenerated by `ziggurat_tables.py`.
114+
115+
pub type ZigTable = &\'static [f64, .. %d];
116+
''' % (TABLE_LEN + 1))
117+
for name, tables, r in [('NORM', NORM, NORM_R),
118+
('EXP', EXP, EXP_R)]:
119+
f.write(render_static('ZIG_%s_R' % name, 'f64', ' %.18f' % r))
120+
for (tabname, table) in zip(TABLE_NAMES, tables):
121+
f.write(render_table('ZIG_%s_%s' % (name, tabname), table))

branches/dist-snap/src/libcore/cell.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn empty_cell<T>() -> Cell<T> {
4242
pub impl<T> Cell<T> {
4343
/// Yields the value, failing if the cell is empty.
4444
fn take(&self) -> T {
45-
let self = unsafe { transmute_mut(self) };
45+
let mut self = unsafe { transmute_mut(self) };
4646
if self.is_empty() {
4747
fail!(~"attempt to take an empty cell");
4848
}
@@ -54,7 +54,7 @@ pub impl<T> Cell<T> {
5454
5555
/// Returns the value, failing if the cell is full.
5656
fn put_back(&self, value: T) {
57-
let self = unsafe { transmute_mut(self) };
57+
let mut self = unsafe { transmute_mut(self) };
5858
if !self.is_empty() {
5959
fail!(~"attempt to put a value back into a full cell");
6060
}

branches/dist-snap/src/libcore/char.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Utilities for manipulating the char type
1212
13+
#[cfg(notest)]
1314
use cmp::Ord;
1415
use option::{None, Option, Some};
1516
use str;

branches/dist-snap/src/libcore/cleanup.rs

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use ptr::mut_null;
1515
use repr::BoxRepr;
1616
use sys::TypeDesc;
1717
use cast::transmute;
18-
use unstable::lang::clear_task_borrow_list;
1918

2019
#[cfg(notest)] use ptr::to_unsafe_ptr;
2120

@@ -127,29 +126,22 @@ struct AnnihilateStats {
127126
n_bytes_freed: uint
128127
}
129128

130-
unsafe fn each_live_alloc(read_next_before: bool,
131-
f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) {
132-
//! Walks the internal list of allocations
133-
129+
unsafe fn each_live_alloc(f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) {
134130
use managed;
135131

136132
let task: *Task = transmute(rustrt::rust_get_task());
137133
let box = (*task).boxed_region.live_allocs;
138134
let mut box: *mut BoxRepr = transmute(copy box);
139135
while box != mut_null() {
140-
let next_before = transmute(copy (*box).header.next);
136+
let next = transmute(copy (*box).header.next);
141137
let uniq =
142138
(*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE;
143139

144140
if ! f(box, uniq) {
145141
break
146142
}
147143

148-
if read_next_before {
149-
box = next_before;
150-
} else {
151-
box = transmute(copy (*box).header.next);
152-
}
144+
box = next
153145
}
154146
}
155147

@@ -167,8 +159,7 @@ fn debug_mem() -> bool {
167159
#[cfg(notest)]
168160
#[lang="annihilate"]
169161
pub unsafe fn annihilate() {
170-
use unstable::lang::{local_free};
171-
use unstable::lang;
162+
use unstable::lang::local_free;
172163
use io::WriterUtil;
173164
use io;
174165
use libc;
@@ -181,51 +172,28 @@ pub unsafe fn annihilate() {
181172
n_bytes_freed: 0
182173
};
183174

184-
// Quick hack: we need to free this list upon task exit, and this
185-
// is a convenient place to do it.
186-
clear_task_borrow_list();
187-
188175
// Pass 1: Make all boxes immortal.
189-
//
190-
// In this pass, nothing gets freed, so it does not matter whether
191-
// we read the next field before or after the callback.
192-
for each_live_alloc(true) |box, uniq| {
176+
for each_live_alloc |box, uniq| {
193177
stats.n_total_boxes += 1;
194178
if uniq {
195-
lang::debug_mem("Managed-uniq: ", &*box);
196179
stats.n_unique_boxes += 1;
197180
} else {
198-
lang::debug_mem("Immortalizing: ", &*box);
199181
(*box).header.ref_count = managed::raw::RC_IMMORTAL;
200182
}
201183
}
202184

203185
// Pass 2: Drop all boxes.
204-
//
205-
// In this pass, unique-managed boxes may get freed, but not
206-
// managed boxes, so we must read the `next` field *after* the
207-
// callback, as the original value may have been freed.
208-
for each_live_alloc(false) |box, uniq| {
186+
for each_live_alloc |box, uniq| {
209187
if !uniq {
210-
lang::debug_mem("Invoking tydesc/glue on: ", &*box);
211188
let tydesc: *TypeDesc = transmute(copy (*box).header.type_desc);
212189
let drop_glue: DropGlue = transmute(((*tydesc).drop_glue, 0));
213-
lang::debug_mem("Box data: ", &(*box).data);
214-
lang::debug_mem("Type descriptor: ", tydesc);
215190
drop_glue(to_unsafe_ptr(&tydesc), transmute(&(*box).data));
216-
lang::debug_mem("Dropped ", &*box);
217191
}
218192
}
219193

220194
// Pass 3: Free all boxes.
221-
//
222-
// In this pass, managed boxes may get freed (but not
223-
// unique-managed boxes, though I think that none of those are
224-
// left), so we must read the `next` field before, since it will
225-
// not be valid after.
226-
for each_live_alloc(true) |box, uniq| {
195+
for each_live_alloc |box, uniq| {
227196
if !uniq {
228-
lang::debug_mem("About to free: ", &*box);
229197
stats.n_bytes_freed +=
230198
(*((*box).header.type_desc)).size
231199
+ sys::size_of::<BoxRepr>();

branches/dist-snap/src/libcore/comm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ impl<T: Owned> Selectable for Port<T> {
205205
fn header(&self) -> *PacketHeader {
206206
unsafe {
207207
match self.endp {
208-
Some(ref endp) => endp.header(),
209-
None => fail!(~"peeking empty stream")
208+
Some(ref endp) => endp.header(),
209+
None => fail!(~"peeking empty stream")
210210
}
211211
}
212212
}

branches/dist-snap/src/libcore/container.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,42 @@ pub trait Mutable: Container {
2525
fn clear(&mut self);
2626
}
2727

28+
#[cfg(stage0)]
29+
pub trait Map<K, V>: Mutable {
30+
/// Return true if the map contains a value for the specified key
31+
fn contains_key(&self, key: &K) -> bool;
32+
33+
// Visits all keys and values
34+
fn each(&self, f: &fn(&K, &V) -> bool);
35+
36+
/// Visit all keys
37+
fn each_key(&self, f: &fn(&K) -> bool);
38+
39+
/// Visit all values
40+
fn each_value(&self, f: &fn(&V) -> bool);
41+
42+
/// Iterate over the map and mutate the contained values
43+
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool);
44+
45+
/// Return a reference to the value corresponding to the key
46+
fn find(&self, key: &K) -> Option<&'self V>;
47+
48+
/// Return a mutable reference to the value corresponding to the key
49+
fn find_mut(&mut self, key: &K) -> Option<&'self mut V>;
50+
51+
/// Insert a key-value pair into the map. An existing value for a
52+
/// key is replaced by the new value. Return true if the key did
53+
/// not already exist in the map.
54+
fn insert(&mut self, key: K, value: V) -> bool;
55+
56+
/// Remove a key-value pair from the map. Return true if the key
57+
/// was present in the map, otherwise false.
58+
fn remove(&mut self, key: &K) -> bool;
59+
}
60+
61+
#[cfg(stage1)]
62+
#[cfg(stage2)]
63+
#[cfg(stage3)]
2864
pub trait Map<K, V>: Mutable {
2965
/// Return true if the map contains a value for the specified key
3066
fn contains_key(&self, key: &K) -> bool;

0 commit comments

Comments
 (0)