Skip to content

Commit 6ab06c9

Browse files
committed
---
yaml --- r: 6897 b: refs/heads/master c: 854daae h: refs/heads/master i: 6895: 5a713b2 v: v3
1 parent 7593c6e commit 6ab06c9

File tree

9 files changed

+95
-34
lines changed

9 files changed

+95
-34
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: bbc534bcccfc1904104a1fa275a6a873a7675cd1
2+
refs/heads/master: 854daaec0c4cf0c236e46b45a1254c85a8b352db

trunk/src/cargo/cargo.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ type package = {
3131
uuid: str,
3232
url: str,
3333
method: str,
34-
ref: option::t<str>,
3534
tags: [str]
3635
};
3736

@@ -243,11 +242,6 @@ fn load_one_source_package(&src: source, p: map::hashmap<str, json::json>) {
243242
}
244243
};
245244

246-
let ref = alt p.find("ref") {
247-
some(json::string(_n)) { some(_n) }
248-
_ { none }
249-
};
250-
251245
let tags = [];
252246
alt p.find("tags") {
253247
some(json::list(js)) {
@@ -266,7 +260,6 @@ fn load_one_source_package(&src: source, p: map::hashmap<str, json::json>) {
266260
uuid: uuid,
267261
url: url,
268262
method: method,
269-
ref: ref,
270263
tags: tags
271264
});
272265
log " Loaded package: " + src.name + "/" + name;
@@ -405,14 +398,8 @@ fn install_source(c: cargo, path: str) {
405398
}
406399
}
407400

408-
fn install_git(c: cargo, wd: str, url: str, ref: option::t<str>) {
401+
fn install_git(c: cargo, wd: str, url: str) {
409402
run::run_program("git", ["clone", url, wd]);
410-
if option::is_some::<str>(ref) {
411-
let r = option::get::<str>(ref);
412-
fs::change_dir(wd);
413-
run::run_program("git", ["checkout", r]);
414-
}
415-
416403
install_source(c, wd);
417404
}
418405

@@ -437,7 +424,7 @@ fn install_file(c: cargo, wd: str, path: str) {
437424
fn install_package(c: cargo, wd: str, pkg: package) {
438425
info("Installing with " + pkg.method + " from " + pkg.url + "...");
439426
if pkg.method == "git" {
440-
install_git(c, wd, pkg.url, pkg.ref);
427+
install_git(c, wd, pkg.url);
441428
} else if pkg.method == "http" {
442429
install_curl(c, wd, pkg.url);
443430
} else if pkg.method == "file" {

trunk/src/cargo/sources.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"url": "https://raw.github.com/graydon/cargo-central/master/packages.json"
44
},
55
"elly": {
6-
"url": "https://raw.github.com/elly/rust-packages/master/packages.json"
6+
"url": "https://raw.github.com/elly/rust-packages/master/packages.json",
77
"sig": "https://raw.github.com/elly/rust-packages/master/packages.json.sig",
88
"key": "https://raw.github.com/elly/rust-packages/master/signing-key.gpg",
99
"keyfp": "4107 21C0 FF32 858F 61FF 33F6 E595 8E36 FDC8 EA00"

trunk/src/libcore/core.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import option::{some, none};
77
import option = option::t;
88
export option, some, none;
9+
export repeat;
910

1011
// Export the log levels as global constants. Higher levels mean
1112
// more-verbosity. Error is the bottom level, default logging level is
@@ -15,3 +16,16 @@ const error : int = 0;
1516
const warn : int = 1;
1617
const info : int = 2;
1718
const debug : int = 3;
19+
20+
/*
21+
Function: repeat
22+
23+
Execute a function for a set number of times
24+
*/
25+
fn repeat(times: uint, f: block()) {
26+
let i = 0u;
27+
while i < times {
28+
f();
29+
i += 1u;
30+
}
31+
}

trunk/src/rt/circular_buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class
99
circular_buffer : public kernel_owned<circular_buffer> {
10-
static const size_t INITIAL_CIRCULAR_BUFFER_SIZE_IN_UNITS = 8;
10+
static const size_t INITIAL_CIRCULAR_BUFFER_SIZE_IN_UNITS = 1;
1111
static const size_t MAX_CIRCULAR_BUFFER_SIZE = 1 << 24;
1212

1313
public:

trunk/src/rt/rust_kernel.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,11 @@ rust_kernel::fail() {
150150

151151
rust_task_id
152152
rust_kernel::create_task(rust_task *spawner, const char *name) {
153+
scoped_lock with(_kernel_lock);
153154
rust_scheduler *thread = threads[isaac_rand(&rctx) % num_threads];
154155
rust_task *t = thread->create_task(spawner, name);
155-
{
156-
scoped_lock with(_kernel_lock);
157-
t->user.id = max_id++;
158-
task_table.put(t->user.id, t);
159-
}
156+
t->user.id = max_id++;
157+
task_table.put(t->user.id, t);
160158
return t->user.id;
161159
}
162160

trunk/src/rt/rust_task.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -397,23 +397,16 @@ void rust_task::start()
397397
sched->lock.signal();
398398
}
399399

400-
void
401-
rust_task::grow(size_t n_frame_bytes)
402-
{
403-
// FIXME (issue #151): Just fail rather than almost certainly crashing
404-
// mysteriously later. The commented-out logic below won't work at all in
405-
// the presence of non-word-aligned pointers.
406-
abort();
407-
408-
}
409-
410400
// Only run this on the rust stack
411401
void
412402
rust_task::yield(size_t time_in_us, bool *killed) {
413403
if (this->killed) {
414404
*killed = true;
415405
}
416406

407+
// We're not going to need any extra stack for a while
408+
clear_stack_cache();
409+
417410
yield_timer.reset_us(time_in_us);
418411

419412
// Return to the scheduler.
@@ -756,6 +749,15 @@ rust_task::del_stack() {
756749
record_stack_limit();
757750
}
758751

752+
void
753+
rust_task::clear_stack_cache() {
754+
A(sched, stk != NULL, "Expected to have a stack");
755+
if (stk->prev != NULL) {
756+
free_stk(this, stk->prev);
757+
stk->prev = NULL;
758+
}
759+
}
760+
759761
void
760762
rust_task::record_stack_limit() {
761763
// The function prolog compares the amount of stack needed to the end of

trunk/src/rt/rust_task.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ rust_task : public kernel_owned<rust_task>, rust_cond
138138
void start(uintptr_t spawnee_fn,
139139
uintptr_t args);
140140
void start();
141-
void grow(size_t n_frame_bytes);
142141
bool running();
143142
bool blocked();
144143
bool blocked_on(rust_cond *cond);
@@ -204,6 +203,7 @@ rust_task : public kernel_owned<rust_task>, rust_cond
204203
void reset_stack_limit();
205204
bool on_rust_stack();
206205
void check_stack_canary();
206+
void clear_stack_cache();
207207
};
208208

209209
//
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// xfail-test FIXME: Can't run under valgrind - too much RAM
2+
// FIXME: This doesn't spawn close to a million tasks yet
3+
4+
tag msg {
5+
ready(comm::chan<msg>);
6+
start;
7+
done(int);
8+
}
9+
10+
fn calc(&&args: (int, comm::chan<msg>)) {
11+
let (depth, parent_ch) = args;
12+
let port = comm::port();
13+
let children = depth > 0 ? 20u : 0u;
14+
let child_chs = [];
15+
let sum = 0;
16+
17+
repeat (children) {||
18+
task::spawn((depth - 1, comm::chan(port)), calc);
19+
}
20+
21+
repeat (children) {||
22+
alt comm::recv(port) {
23+
ready(child_ch) {
24+
child_chs += [child_ch];
25+
}
26+
}
27+
}
28+
29+
comm::send(parent_ch, ready(comm::chan(port)));
30+
31+
alt comm::recv(port) {
32+
start. {
33+
vec::iter (child_chs) { |child_ch|
34+
comm::send(child_ch, start);
35+
}
36+
}
37+
}
38+
39+
repeat (children) {||
40+
alt comm::recv(port) {
41+
done(child_sum) { sum += child_sum; }
42+
}
43+
}
44+
45+
comm::send(parent_ch, done(sum + 1));
46+
}
47+
48+
fn main() {
49+
let port = comm::port();
50+
task::spawn((3, comm::chan(port)), calc);
51+
alt comm::recv(port) {
52+
ready(chan) {
53+
comm::send(chan, start);
54+
}
55+
}
56+
let sum = alt comm::recv(port) {
57+
done(sum) { sum }
58+
};
59+
log #fmt("How many tasks? That's right, %d tasks.", sum);
60+
}

0 commit comments

Comments
 (0)