about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-01-29 21:20:36 -0800
committerBrian Anderson <banderson@mozilla.com>2012-01-29 21:20:39 -0800
commit6548cdd59beca24a90f41d6507cb615e67828b07 (patch)
tree15e0547e2c14ee150e35d4c78d4922b85102cb5f
parent361f90e618c081afe2fa8b0a67370610781e413e (diff)
downloadrust-6548cdd59beca24a90f41d6507cb615e67828b07.tar.gz
rust-6548cdd59beca24a90f41d6507cb615e67828b07.zip
rt: Make the initial segment of the main task's stack 1MB
This is a trick to fool microbenchmarks. Closes #1681
-rw-r--r--src/rt/rust.cpp4
-rw-r--r--src/rt/rust_kernel.cpp10
-rw-r--r--src/rt/rust_kernel.h4
-rw-r--r--src/rt/rust_scheduler.cpp5
-rw-r--r--src/rt/rust_scheduler.h3
-rw-r--r--src/rt/rust_task.cpp5
-rw-r--r--src/rt/rust_task.h3
7 files changed, 24 insertions, 10 deletions
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp
index 6542c7237a7..87520fe44a2 100644
--- a/src/rt/rust.cpp
+++ b/src/rt/rust.cpp
@@ -75,6 +75,8 @@ command_line_args : public kernel_owned<command_line_args>
 
 int check_claims = 0;
 
+const size_t MAIN_STACK_SIZE = 1024*1024;
+
 extern "C" CDECL int
 rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
 
@@ -85,7 +87,7 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
 
     rust_srv *srv = new rust_srv(env);
     rust_kernel *kernel = new rust_kernel(srv, env->num_sched_threads);
-    rust_task_id root_id = kernel->create_task(NULL, "main");
+    rust_task_id root_id = kernel->create_task(NULL, "main", MAIN_STACK_SIZE);
     rust_task *root_task = kernel->get_task_by_id(root_id);
     I(kernel, root_task != NULL);
     rust_scheduler *sched = root_task->sched;
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index a7e4ee2e450..c5322e65e41 100644
--- a/src/rt/rust_kernel.cpp
+++ b/src/rt/rust_kernel.cpp
@@ -151,15 +151,21 @@ rust_kernel::fail() {
 }
 
 rust_task_id
-rust_kernel::create_task(rust_task *spawner, const char *name) {
+rust_kernel::create_task(rust_task *spawner, const char *name,
+                         size_t init_stack_sz) {
     scoped_lock with(_kernel_lock);
     rust_scheduler *thread = threads[isaac_rand(&rctx) % num_threads];
-    rust_task *t = thread->create_task(spawner, name);
+    rust_task *t = thread->create_task(spawner, name, init_stack_sz);
     t->user.id = max_id++;
     task_table.put(t->user.id, t);
     return t->user.id;
 }
 
+rust_task_id
+rust_kernel::create_task(rust_task *spawner, const char *name) {
+    return create_task(spawner, name, env->min_stack_size);
+}
+
 rust_task *
 rust_kernel::get_task_by_id(rust_task_id id) {
     scoped_lock with(_kernel_lock);
diff --git a/src/rt/rust_kernel.h b/src/rt/rust_kernel.h
index f60987acae5..3d64e57d9f9 100644
--- a/src/rt/rust_kernel.h
+++ b/src/rt/rust_kernel.h
@@ -66,7 +66,9 @@ public:
     void win32_require(LPCTSTR fn, BOOL ok);
 #endif
 
-    rust_task_id create_task(rust_task *spawner, const char *name);
+    rust_task_id create_task(rust_task *spawner, const char *name,
+			     size_t init_stack_size);
+    rust_task_id create_task(rust_task * spawner, const char *name);
     rust_task *get_task_by_id(rust_task_id id);
     void release_task_id(rust_task_id tid);
     void set_exit_status(int code);
diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp
index 0b4e35910ac..5b8ae206a74 100644
--- a/src/rt/rust_scheduler.cpp
+++ b/src/rt/rust_scheduler.cpp
@@ -333,10 +333,11 @@ rust_scheduler::get_cache() {
 }
 
 rust_task *
-rust_scheduler::create_task(rust_task *spawner, const char *name) {
+rust_scheduler::create_task(rust_task *spawner, const char *name,
+                            size_t init_stack_sz) {
     rust_task *task =
         new (this->kernel, "rust_task")
-        rust_task (this, &newborn_tasks, spawner, name);
+        rust_task (this, &newborn_tasks, spawner, name, init_stack_sz);
     DLOG(this, task, "created task: " PTR ", spawner: %s, name: %s",
                         task, spawner ? spawner->name : "null", name);
     if(spawner) {
diff --git a/src/rt/rust_scheduler.h b/src/rt/rust_scheduler.h
index 49802646011..b5bd92efaaa 100644
--- a/src/rt/rust_scheduler.h
+++ b/src/rt/rust_scheduler.h
@@ -112,7 +112,8 @@ struct rust_scheduler : public kernel_owned<rust_scheduler>,
 
     void kill_all_tasks();
 
-    rust_task *create_task(rust_task *spawner, const char *name);
+    rust_task *create_task(rust_task *spawner, const char *name,
+                           size_t init_stack_sz);
 
     virtual void run();
 
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 4d136a59ae6..d6f43ca0794 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -239,7 +239,8 @@ del_stk(rust_task *task, stk_seg *stk)
 
 // Tasks
 rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
-                     rust_task *spawner, const char *name) :
+                     rust_task *spawner, const char *name,
+                     size_t init_stack_sz) :
     ref_count(1),
     stk(NULL),
     runtime_sp(0),
@@ -271,7 +272,7 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
 
     user.notify_enabled = 0;
 
-    stk = new_stk(sched, this, 0);
+    stk = new_stk(sched, this, init_stack_sz);
     user.rust_sp = stk->end;
     if (supervisor) {
         supervisor->ref();
diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h
index 6ae663d2066..0d7cfed4a32 100644
--- a/src/rt/rust_task.h
+++ b/src/rt/rust_task.h
@@ -133,7 +133,8 @@ rust_task : public kernel_owned<rust_task>, rust_cond
     rust_task(rust_scheduler *sched,
               rust_task_list *state,
               rust_task *spawner,
-              const char *name);
+              const char *name,
+              size_t init_stack_sz);
 
     ~rust_task();