about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJon Morton <jonanin@gmail.com>2012-04-02 16:13:40 -0500
committerBrian Anderson <banderson@mozilla.com>2012-04-02 14:21:09 -0700
commitfa88d15d636d84b7e6928323386f86d3fec8f51b (patch)
tree5ef2894ef4bb7fc0eb4bd96049acb30b21a697e3
parent33a949eed6e6a5f2cba72663d92a0012e5439d80 (diff)
remove unneeded assert, move get_task_tls to sched_loop
-rw-r--r--src/rt/rust_sched_loop.h32
-rw-r--r--src/rt/rust_task.h22
2 files changed, 27 insertions, 27 deletions
diff --git a/src/rt/rust_sched_loop.h b/src/rt/rust_sched_loop.h
index 61ed25bf8fa..9c059ac6230 100644
--- a/src/rt/rust_sched_loop.h
+++ b/src/rt/rust_sched_loop.h
@@ -38,6 +38,14 @@ private:
 
     const int id;
 
+    static bool tls_initialized;
+
+#ifndef __WIN32__
+    static pthread_key_t task_key;
+#else
+    static DWORD task_key;
+#endif
+
     context c_context;
 
     bool should_exit;
@@ -62,13 +70,6 @@ private:
 public:
     rust_kernel *kernel;
     rust_scheduler *sched;
-    static bool tls_initialized;
-
-#ifndef __WIN32__
-    static pthread_key_t task_key;
-#else
-    static DWORD task_key;
-#endif
 
     // NB: this is used to filter *runtime-originating* debug
     // logging, on a per-scheduler basis. It's not likely what
@@ -116,6 +117,8 @@ public:
     void init_tls();
     void place_task_in_tls(rust_task *task);
 
+    static rust_task *get_task_tls();
+
     // Called by each task when they are ready to be destroyed
     void release_task(rust_task *task);
 
@@ -132,6 +135,21 @@ rust_sched_loop::get_log() {
     return _log;
 }
 
+inline rust_task* rust_sched_loop::get_task_tls()
+{
+    if (!tls_initialized)
+        return NULL;
+#ifdef __WIN32__
+    rust_task *task = reinterpret_cast<rust_task *>
+        (TlsGetValue(task_key));
+#else
+    rust_task *task = reinterpret_cast<rust_task *>
+        (pthread_getspecific(task_key));
+#endif
+    assert(task && "Couldn't get the task from TLS!");
+    return task;
+}
+
 // NB: Runs on the Rust stack
 inline stk_seg *
 rust_sched_loop::borrow_c_stack() {
diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h
index 25266242485..87aeca511e9 100644
--- a/src/rt/rust_task.h
+++ b/src/rt/rust_task.h
@@ -444,22 +444,6 @@ rust_task::record_stack_limit() {
     record_sp_limit(stk->data + LIMIT_OFFSET + RED_ZONE_SIZE);
 }
 
-inline rust_task* __rust_get_task_tls()
-{
-    if (!rust_sched_loop::tls_initialized)
-        return NULL;
-#ifdef __WIN32__
-    rust_task *task = reinterpret_cast<rust_task *>
-        (TlsGetValue(rust_sched_loop::task_key));
-#else
-    rust_task *task = reinterpret_cast<rust_task *>
-        (pthread_getspecific(rust_sched_loop::task_key));
-#endif
-    assert(task && "Couldn't get the task from TLS!");
-    return task;
-
-}
-
 inline rust_task* rust_get_current_task() {
     uintptr_t sp_limit = get_sp_limit();
 
@@ -467,7 +451,7 @@ inline rust_task* rust_get_current_task() {
     // value is sometimes inconveniently set to 0, so we can't use this
     // method of retreiving the task pointer and need to fall back to TLS.
     if (sp_limit == 0)
-        return __rust_get_task_tls();
+        return rust_sched_loop::get_task_tls();
 
     // The stack pointer boundary is stored in a quickly-accessible location
     // in the TCB. From that we can calculate the address of the stack segment
@@ -476,11 +460,9 @@ inline rust_task* rust_get_current_task() {
     uintptr_t seg_addr =
         sp_limit - RED_ZONE_SIZE - LIMIT_OFFSET - sizeof(stk_seg);
     stk_seg *stk = (stk_seg*) seg_addr;
+
     // Make sure we've calculated the right address
     ::check_stack_canary(stk);
-
-    if (stk->task == NULL)
-        return __rust_get_task_tls();
     return stk->task;
 }