diff --git a/src/lib/task.rs b/src/lib/task.rs index 5968c456909a..62fff2cfc758 100644 --- a/src/lib/task.rs +++ b/src/lib/task.rs @@ -8,6 +8,8 @@ native "rust" mod rustrt { fn clone_chan(c: *rust_chan) -> *rust_chan; type rust_chan; + + fn set_min_stack(stack_size: uint); } /** @@ -40,6 +42,10 @@ fn send[T](c: chan[T], v: &T) { c <| v; } fn recv[T](p: port[T]) -> T { let v; p |> v; v } +fn set_min_stack(uint stack_size) { + rustrt::set_min_stack(stack_size); +} + // Local Variables: // mode: rust; // fill-column: 78; diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index eefc6dac8ceb..4870c9fe5459 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -856,6 +856,13 @@ clone_chan(rust_task *task, rust_chan *chan) { return chan->clone(task); } +// defined in rust_task.cpp +extern size_t g_min_stack_size; +extern "C" CDECL void +set_min_stack(rust_task *task, uintptr_t stack_size) { + g_min_stack_size = stack_size; +} + // // Local Variables: // mode: C++ diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 10ea48f57c24..538a9b34e569 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -14,6 +14,7 @@ // FIXME (issue #151): This should be 0x300; the change here is for // practicality's sake until stack growth is working. +size_t g_min_stack_size = 0x300000; static size_t get_min_stk_size() { char *stack_size = getenv("RUST_MIN_STACK"); @@ -21,7 +22,7 @@ static size_t get_min_stk_size() { return strtol(stack_size, NULL, 0); } else { - return 0x300000; + return g_min_stack_size; } } diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index c6d31a47f4c8..8326cabea88f 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -37,6 +37,7 @@ rust_ptr_eq rust_run_program rust_start rust_getcwd +set_min_stack size_of squareroot str_alloc diff --git a/src/test/bench/task-perf-word-count.rs b/src/test/bench/task-perf-word-count.rs index 6827ea55804a..6e7e2bdba8aa 100644 --- a/src/test/bench/task-perf-word-count.rs +++ b/src/test/bench/task-perf-word-count.rs @@ -1,6 +1,3 @@ -// xfail-stage1 -// xfail-stage2 -// xfail-stage3 /** A parallel word-frequency counting program. @@ -233,10 +230,19 @@ fn main(argv: vec[str]) { let out = io::stdout(); out.write_line(#fmt("Usage: %s ...", argv.(0))); - fail; + + // TODO: run something just to make sure the code hasn't + // broken yet. This is the unit test mode of this program. + + ret; } + // We can get by with 8k stacks, and we'll probably exhaust our + // address space otherwise. + task::set_min_stack(8192u); + let start = time::precise_time_ns(); + map_reduce::map_reduce(vec::slice(argv, 1u, vec::len(argv))); let stop = time::precise_time_ns(); @@ -342,4 +348,4 @@ fn is_alpha_upper(c: char) -> bool { fn is_alpha(c: char) -> bool { is_alpha_upper(c) || is_alpha_lower(c) } -fn is_word_char(c: char) -> bool { is_alpha(c) || is_digit(c) || c == '_' } \ No newline at end of file +fn is_word_char(c: char) -> bool { is_alpha(c) || is_digit(c) || c == '_' }