Adding a function to stdlib to set the min stack size, for programs
that absolutely will not succeed with a large default stack. This should be removed once we have stack grown working. Also updated word-count to succeed under the new test framework.
This commit is contained in:
parent
117e251733
commit
e697a52359
5 changed files with 27 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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++
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ rust_ptr_eq
|
|||
rust_run_program
|
||||
rust_start
|
||||
rust_getcwd
|
||||
set_min_stack
|
||||
size_of
|
||||
squareroot
|
||||
str_alloc
|
||||
|
|
|
|||
|
|
@ -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 <filename> ...", 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 == '_' }
|
||||
fn is_word_char(c: char) -> bool { is_alpha(c) || is_digit(c) || c == '_' }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue