Skip to content

Commit 8f16eba

Browse files
committed
---
yaml --- r: 30521 b: refs/heads/incoming c: 62b51d9 h: refs/heads/master i: 30519: 0ae2038 v: v3
1 parent 1e9b2b6 commit 8f16eba

File tree

13 files changed

+81
-60
lines changed

13 files changed

+81
-60
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 1faa288a362e781b77527f2dd59193be605286f0
9+
refs/heads/incoming: 62b51d9152e3289c8054792035ea63088247fead
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/cargo/cargo.rs

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use std::{map, json, tempfile, term, sort, getopts};
1313
use map::HashMap;
1414
use to_str::to_str;
1515
use getopts::{optflag, optopt, opt_present};
16-
use dvec::DVec;
1716

1817
type package = {
1918
name: ~str,
@@ -61,7 +60,7 @@ type source = @{
6160
mut method: ~str,
6261
mut key: Option<~str>,
6362
mut keyfp: Option<~str>,
64-
packages: DVec<package>
63+
mut packages: ~[mut package]
6564
};
6665

6766
type cargo = {
@@ -449,7 +448,7 @@ fn parse_source(name: ~str, j: json::Json) -> source {
449448
mut method: method,
450449
mut key: key,
451450
mut keyfp: keyfp,
452-
packages: DVec() };
451+
mut packages: ~[mut] };
453452
}
454453
_ => fail ~"needed dict value in source"
455454
};
@@ -559,14 +558,14 @@ fn load_one_source_package(src: source, p: map::HashMap<~str, json::Json>) {
559558
versions: ~[]
560559
};
561560

562-
match src.packages.position(|pkg| pkg.uuid == uuid) {
563-
Some(idx) => {
564-
src.packages.set_elt(idx, newpkg);
565-
log(debug, ~" updated package: " + src.name + ~"/" + name);
566-
}
567-
None => {
568-
src.packages.push(newpkg);
569-
}
561+
match vec::position(src.packages, |pkg| pkg.uuid == uuid) {
562+
Some(idx) => {
563+
src.packages[idx] = newpkg;
564+
log(debug, ~" updated package: " + src.name + ~"/" + name);
565+
}
566+
None => {
567+
vec::grow(src.packages, 1u, newpkg);
568+
}
570569
}
571570
572571
log(debug, ~" loaded package: " + src.name + ~"/" + name);
@@ -714,7 +713,10 @@ fn configure(opts: options) -> cargo {
714713

715714
fn for_each_package(c: cargo, b: fn(source, package)) {
716715
for c.sources.each_value |v| {
717-
for v.packages.each |p| {
716+
// FIXME (#2280): this temporary shouldn't be
717+
// necessary, but seems to be, for borrowing.
718+
let pks = copy v.packages;
719+
for vec::each(pks) |p| {
718720
b(v, p);
719721
}
720722
}
@@ -946,28 +948,30 @@ fn install_named(c: cargo, wd: &Path, name: ~str) {
946948

947949
fn install_uuid_specific(c: cargo, wd: &Path, src: ~str, uuid: ~str) {
948950
match c.sources.find(src) {
949-
Some(s) => {
950-
for s.packages.each |p| {
951-
if p.uuid == uuid {
952-
install_package(c, src, wd, p);
953-
return;
954-
}
955-
}
956-
}
957-
_ => ()
951+
Some(s) => {
952+
let packages = copy s.packages;
953+
if vec::any(packages, |p| {
954+
if p.uuid == uuid {
955+
install_package(c, src, wd, p);
956+
true
957+
} else { false }
958+
}) { return; }
959+
}
960+
_ => ()
958961
}
959962
error(~"can't find package: " + src + ~"/" + uuid);
960963
}
961964

962965
fn install_named_specific(c: cargo, wd: &Path, src: ~str, name: ~str) {
963966
match c.sources.find(src) {
964967
Some(s) => {
965-
for s.packages.each |p| {
968+
let packages = copy s.packages;
969+
if vec::any(packages, |p| {
966970
if p.name == name {
967971
install_package(c, src, wd, p);
968-
return;
969-
}
970-
}
972+
true
973+
} else { false }
974+
}) { return; }
971975
}
972976
_ => ()
973977
}
@@ -1496,7 +1500,8 @@ fn print_pkg(s: source, p: package) {
14961500
fn print_source(s: source) {
14971501
info(s.name + ~" (" + s.url + ~")");
14981502

1499-
let pks = sort::merge_sort(sys::shape_lt, s.packages.get());
1503+
let unsorted_pks = s.packages; // to prevent illegal borrow?
1504+
let pks = sort::merge_sort(sys::shape_lt, unsorted_pks);
15001505
let l = vec::len(pks);
15011506

15021507
print(io::with_str_writer(|writer| {
@@ -1680,7 +1685,7 @@ fn cmd_sources(c: cargo) {
16801685
mut method: assume_source_method(url),
16811686
mut key: None,
16821687
mut keyfp: None,
1683-
packages: DVec()
1688+
mut packages: ~[mut]
16841689
});
16851690
info(fmt!("added source: %s", name));
16861691
}

branches/incoming/src/libcore/iter-trait.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
1818
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B {
1919
iter::foldl(self, move b0, blk)
2020
}
21-
pure fn position(f: fn(A) -> bool) -> Option<uint> {
22-
iter::position(self, f)
23-
}
2421
}
2522

2623
impl<A: Eq> IMPL_T<A>: iter::EqIter<A> {
2724
pure fn contains(x: A) -> bool { iter::contains(self, x) }
2825
pure fn count(x: A) -> uint { iter::count(self, x) }
26+
pure fn position(f: fn(A) -> bool) -> Option<uint> {
27+
iter::position(self, f)
28+
}
2929
}
3030

3131
impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {

branches/incoming/src/libcore/iter.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ trait ExtendedIter<A> {
1313
pure fn all(blk: fn(A) -> bool) -> bool;
1414
pure fn any(blk: fn(A) -> bool) -> bool;
1515
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B;
16-
pure fn position(f: fn(A) -> bool) -> Option<uint>;
1716
}
1817

1918
trait EqIter<A:Eq> {
2019
pure fn contains(x: A) -> bool;
2120
pure fn count(x: A) -> uint;
21+
pure fn position(f: fn(A) -> bool) -> Option<uint>;
2222
}
2323

2424
trait Times {
@@ -142,8 +142,7 @@ pure fn count<A:Eq,IA:BaseIter<A>>(self: IA, x: A) -> uint {
142142
}
143143

144144
pure fn position<A,IA:BaseIter<A>>(self: IA, f: fn(A) -> bool)
145-
-> Option<uint>
146-
{
145+
-> Option<uint> {
147146
let mut i = 0;
148147
for self.each |a| {
149148
if f(a) { return Some(i); }

branches/incoming/src/libcore/repr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl ReprPrinterWrapper {
184184
self.printer.ptr = transmute(&(*box).data);
185185
intrinsic::visit_tydesc((*box).type_desc, self as @TyVisitor);
186186
let box_size = sys::size_of::<*BoxRepr>();
187-
self.printer.ptr = transmute(box_ptr as uint + box_size);
187+
self.printer.ptr = transmute(self.printer.ptr as uint + box_size);
188188
true
189189
}
190190
}
@@ -200,7 +200,7 @@ impl ReprPrinterWrapper {
200200
intrinsic::visit_tydesc(inner, self as @TyVisitor);
201201
}
202202
let ptr_size = sys::size_of::<*c_void>();
203-
self.printer.ptr = transmute(data_ptr as uint + ptr_size);
203+
self.printer.ptr = transmute(self.printer.ptr as uint + ptr_size);
204204
true
205205
}
206206
}
@@ -508,7 +508,7 @@ impl ReprPrinterWrapper : TyVisitor {
508508
_disr_val: int,
509509
n_fields: uint,
510510
_name: &str) -> bool {
511-
if !self.printer.skip && n_fields >= 1 {
511+
if !self.printer.skip && n_fields > 1 {
512512
self.printer.writer.write_char(')');
513513
}
514514
true

branches/incoming/src/libcore/task.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,11 +1403,9 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) {
14031403

14041404
let num_threads = match opts.mode {
14051405
SingleThreaded => 1u,
1406-
ThreadPerCore => {
1407-
fail ~"thread_per_core scheduling mode unimplemented"
1408-
}
1406+
ThreadPerCore => rustrt::rust_num_threads(),
14091407
ThreadPerTask => {
1410-
fail ~"thread_per_task scheduling mode unimplemented"
1408+
fail ~"ThreadPerTask scheduling mode unimplemented"
14111409
}
14121410
ManualThreads(threads) => {
14131411
if threads == 0u {
@@ -1657,6 +1655,8 @@ extern mod rustrt {
16571655

16581656
fn rust_get_sched_id() -> sched_id;
16591657
fn rust_new_sched(num_threads: libc::uintptr_t) -> sched_id;
1658+
fn sched_threads() -> libc::size_t;
1659+
fn rust_num_threads() -> libc::uintptr_t;
16601660

16611661
fn get_task_id() -> task_id;
16621662
#[rust_stack]
@@ -2422,3 +2422,13 @@ fn test_tls_cleanup_on_failure() unsafe {
24222422
local_data_set(int_key, @31337);
24232423
fail;
24242424
}
2425+
2426+
#[test]
2427+
fn test_sched_thread_per_core() {
2428+
let cores = rustrt::rust_num_threads();
2429+
let mut reported_threads = 0u;
2430+
do spawn_sched(ThreadPerCore) {
2431+
reported_threads = rustrt::sched_threads();
2432+
}
2433+
assert(cores == reported_threads);
2434+
}

branches/incoming/src/libcore/vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,14 +2019,14 @@ impl<A> &[A]: iter::ExtendedIter<A> {
20192019
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B {
20202020
iter::foldl(self, move b0, blk)
20212021
}
2022-
pure fn position(f: fn(A) -> bool) -> Option<uint> {
2023-
iter::position(self, f)
2024-
}
20252022
}
20262023

20272024
impl<A: Eq> &[A]: iter::EqIter<A> {
20282025
pure fn contains(x: A) -> bool { iter::contains(self, x) }
20292026
pure fn count(x: A) -> uint { iter::count(self, x) }
2027+
pure fn position(f: fn(A) -> bool) -> Option<uint> {
2028+
iter::position(self, f)
2029+
}
20302030
}
20312031

20322032
impl<A: Copy> &[A]: iter::CopyableIter<A> {

branches/incoming/src/rt/rust_builtin.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,12 @@ rust_get_sched_id() {
572572
return task->sched->get_id();
573573
}
574574

575+
extern "C" CDECL uintptr_t
576+
rust_num_threads() {
577+
rust_task *task = rust_get_current_task();
578+
return task->kernel->env->num_sched_threads;
579+
}
580+
575581
extern "C" CDECL rust_sched_id
576582
rust_new_sched(uintptr_t threads) {
577583
rust_task *task = rust_get_current_task();
@@ -620,7 +626,7 @@ start_task(rust_task *target, fn_env_pair *f) {
620626
target->start(f->f, f->env, NULL);
621627
}
622628

623-
extern "C" CDECL int
629+
extern "C" CDECL size_t
624630
sched_threads() {
625631
rust_task *task = rust_get_current_task();
626632
return task->sched->number_of_threads();

branches/incoming/src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ rand_seed
3232
rust_get_sched_id
3333
rust_new_sched
3434
rust_new_task_in_sched
35+
rust_num_threads
3536
rust_path_is_dir
3637
rust_path_exists
3738
rust_getcwd

branches/incoming/src/rustc/middle/trans/base.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,6 +2714,16 @@ fn trans_crate(sess: session::session,
27142714
io::println(fmt!("n_monos: %u", ccx.stats.n_monos));
27152715
io::println(fmt!("n_inlines: %u", ccx.stats.n_inlines));
27162716
io::println(fmt!("n_closures: %u", ccx.stats.n_closures));
2717+
2718+
// FIXME (#2280): this temporary shouldn't be
2719+
// necessary, but seems to be, for borrowing.
2720+
/*
2721+
let times = copy *ccx.stats.fn_times;
2722+
for vec::each(times) |timing| {
2723+
io::println(fmt!("time: %s took %d ms", timing.ident,
2724+
timing.time));
2725+
}
2726+
*/
27172727
}
27182728

27192729
if ccx.sess.count_llvm_insns() {

branches/incoming/src/snapshots.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
S 2012-09-12 fa74edf
2-
macos-i386 da38aa39fd1515ea765790a3c320194bc50fd602
3-
macos-x86_64 7509861e5a6d3e082ad9a9d3474661856b7731c1
4-
freebsd-x86_64 c4e0517d6894d18342eb852b6e738f48d086004f
5-
linux-i386 ee0d36b221d8d2dbb02cd1fd1feb09294e0dbb6f
6-
linux-x86_64 ce585fd55ae42e33398870c3bc77a671547411aa
7-
winnt-i386 5b32231d75d65c057ccd91a6f810e67941f5400a
8-
91
S 2012-09-12 8fbe4b5
102
macos-x86_64 bdbd0feff0391b902ea0a0c68948962c0acf5dae
113
macos-i386 c7e0da4ffb778045f77b84878872dc3944d147da

branches/incoming/src/test/bench/shootout-mandelbrot.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn writer(path: ~str, writech: comm::Chan<comm::Chan<line>>, size: uint)
118118
};
119119
cout.write_line(~"P4");
120120
cout.write_line(fmt!("%u %u", size, size));
121-
let lines: HashMap<uint, ~[u8]> = std::map::uint_hash();
121+
let lines = std::map::uint_hash();
122122
let mut done = 0_u;
123123
let mut i = 0_u;
124124
while i < size {
@@ -131,7 +131,10 @@ fn writer(path: ~str, writech: comm::Chan<comm::Chan<line>>, size: uint)
131131
while prev <= i {
132132
if lines.contains_key(prev) {
133133
debug!("WS %u", prev);
134-
cout.write(lines.get(prev));
134+
// FIXME (#2280): this temporary shouldn't be
135+
// necessary, but seems to be, for borrowing.
136+
let v : ~[u8] = lines.get(prev);
137+
cout.write(v);
135138
done += 1_u;
136139
lines.remove(prev);
137140
prev += 1_u;

branches/incoming/src/test/run-pass/log-knows-the-names-of-variants.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@ enum foo {
44
c,
55
}
66

7-
enum bar {
8-
d, e, f
9-
}
10-
117
fn main() {
128
assert ~"a(22)" == fmt!("%?", a(22u));
139
assert ~"b(~\"hi\")" == fmt!("%?", b(~"hi"));
1410
assert ~"c" == fmt!("%?", c);
15-
assert ~"d" == fmt!("%?", d);
1611
}

0 commit comments

Comments
 (0)