From 21865ddce662767ff8319732cb55b4cdbc9ea67e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 17 Nov 2011 15:19:46 -0800 Subject: [PATCH] intrinsics: Remove the call to get_task from task_sleep --- src/lib/task.rs | 8 ++++++-- src/rt/intrinsics/intrinsics.cpp | 5 +++-- src/rt/intrinsics/intrinsics.i386.ll.in | 9 ++++----- src/rt/intrinsics/intrinsics.x86_64.ll.in | 9 ++++----- src/rt/rust_builtin.cpp | 3 +-- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/lib/task.rs b/src/lib/task.rs index d5cda975a3a..1d7f859bfa2 100644 --- a/src/lib/task.rs +++ b/src/lib/task.rs @@ -53,7 +53,7 @@ export spawn_joinable; #[abi = "rust-intrinsic"] native mod rusti { // these must run on the Rust stack so that they can swap stacks etc: - fn task_sleep(time_in_us: uint); + fn task_sleep(task: *rust_task, time_in_us: uint); } #[link_name = "rustrt"] @@ -63,6 +63,7 @@ native mod rustrt { fn pin_task(); fn unpin_task(); fn get_task_id() -> task_id; + fn rust_get_task() -> *rust_task; fn set_min_stack(stack_size: uint); @@ -142,7 +143,10 @@ Parameters: time_in_us - maximum number of microseconds to yield control for */ -fn sleep(time_in_us: uint) { ret rusti::task_sleep(time_in_us); } +fn sleep(time_in_us: uint) { + let task = rustrt::rust_get_task(); + ret rusti::task_sleep(task, time_in_us); +} /* Function: yield diff --git a/src/rt/intrinsics/intrinsics.cpp b/src/rt/intrinsics/intrinsics.cpp index 419c6cd1dc6..145a41c5a6d 100644 --- a/src/rt/intrinsics/intrinsics.cpp +++ b/src/rt/intrinsics/intrinsics.cpp @@ -12,7 +12,7 @@ extern "C" CDECL void port_recv(uintptr_t *dptr, rust_port *port); extern "C" CDECL void -rust_task_sleep(size_t time_in_us); +rust_task_sleep(rust_task *task, size_t time_in_us); extern "C" void rust_intrinsic_vec_len(size_t *retptr, @@ -71,7 +71,8 @@ rust_intrinsic_get_type_desc(void **retptr, extern "C" void rust_intrinsic_task_sleep(void **retptr, void *env, + rust_task *task, size_t time_in_us) { - rust_task_sleep(time_in_us); + rust_task_sleep(task, time_in_us); } diff --git a/src/rt/intrinsics/intrinsics.i386.ll.in b/src/rt/intrinsics/intrinsics.i386.ll.in index 47ac0bbd578..effc6005972 100644 --- a/src/rt/intrinsics/intrinsics.i386.ll.in +++ b/src/rt/intrinsics/intrinsics.i386.ll.in @@ -27,7 +27,7 @@ target triple = "@CFG_TARGET_TRIPLE@" %class.rust_task_list = type { %class.indexed_list, %struct.rust_scheduler*, i8* } %class.indexed_list = type { i32 (...)**, %class.array_list.2 } %class.array_list.2 = type { i32, %struct.rust_task**, i32 } -%struct.rust_task = type { %struct.rust_task_user, i32, %class.context, %struct.stk_seg*, i32, %struct.rust_scheduler*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %struct.rust_cond*, i8*, %struct.rust_task*, i32, i32, %class.timer, i32*, i32, i32, %class.memory_region, %"class.rust_task::wakeup_callback"*, i8, i8, i8, %class.lock_and_signal, %class.hash_map.4, %class.rust_obstack, %"class.std::map", i32, %"class.debug::task_debug_info" } +%struct.rust_task = type { %struct.rust_task_user, i32, %class.context, %struct.stk_seg*, i32, %struct.rust_scheduler*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %struct.rust_cond*, i8*, %struct.rust_task*, i32, i32, %class.timer, i32*, i32, i32, %class.memory_region, i8, i8, i8, %class.lock_and_signal, %class.hash_map.4, %class.rust_obstack, %"class.std::map", i32, %"class.debug::task_debug_info" } %struct.rust_task_user = type { i32, i32, %struct.chan_handle, i32 } %struct.chan_handle = type { i32, i32 } %class.context = type { %struct.registers_t, %class.context* } @@ -36,7 +36,6 @@ target triple = "@CFG_TARGET_TRIPLE@" %class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_scheduler*, i32 } %struct.rust_cond = type { i8 } %class.timer = type { i32 (...)**, i64, i64 } -%"class.rust_task::wakeup_callback" = type { i32 (...)** } %class.hash_map.4 = type { %"struct.hash_map::map_entry"* } %"struct.hash_map::map_entry" = type opaque %class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* } @@ -105,12 +104,12 @@ define void @rust_intrinsic_get_type_desc(i8** nocapture %retptr, i8* nocapture ret void } -define void @rust_intrinsic_task_sleep(i8** nocapture %retptr, i8* nocapture %env, i32 %time_in_us) { - tail call void @rust_task_sleep(i32 %time_in_us) +define void @rust_intrinsic_task_sleep(i8** nocapture %retptr, i8* nocapture %env, %struct.rust_task* %task, i32 %time_in_us) { + tail call void @rust_task_sleep(%struct.rust_task* %task, i32 %time_in_us) ret void } -declare void @rust_task_sleep(i32) +declare void @rust_task_sleep(%struct.rust_task*, i32) !0 = metadata !{metadata !"any pointer", metadata !1} !1 = metadata !{metadata !"omnipotent char", metadata !2} diff --git a/src/rt/intrinsics/intrinsics.x86_64.ll.in b/src/rt/intrinsics/intrinsics.x86_64.ll.in index 4aa771f0e44..aeec58a0fac 100644 --- a/src/rt/intrinsics/intrinsics.x86_64.ll.in +++ b/src/rt/intrinsics/intrinsics.x86_64.ll.in @@ -27,7 +27,7 @@ target triple = "@CFG_TARGET_TRIPLE@" %class.rust_task_list = type { %class.indexed_list, %struct.rust_scheduler*, i8* } %class.indexed_list = type { i32 (...)**, %class.array_list.2 } %class.array_list.2 = type { i64, %struct.rust_task**, i64 } -%struct.rust_task = type { %struct.rust_task_user, i64, %class.context, %struct.stk_seg*, i64, %struct.rust_scheduler*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %struct.rust_cond*, i8*, %struct.rust_task*, i32, i64, %class.timer, i64*, i32, i32, %class.memory_region, %"class.rust_task::wakeup_callback"*, i8, i8, i8, %class.lock_and_signal, %class.hash_map.4, %class.rust_obstack, %"class.std::map", i32, %"class.debug::task_debug_info" } +%struct.rust_task = type { %struct.rust_task_user, i64, %class.context, %struct.stk_seg*, i64, %struct.rust_scheduler*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %struct.rust_cond*, i8*, %struct.rust_task*, i32, i64, %class.timer, i64*, i32, i32, %class.memory_region, i8, i8, i8, %class.lock_and_signal, %class.hash_map.4, %class.rust_obstack, %"class.std::map", i32, %"class.debug::task_debug_info" } %struct.rust_task_user = type { i64, i64, %struct.chan_handle, i64 } %struct.chan_handle = type { i64, i64 } %class.context = type { %struct.registers_t, %class.context* } @@ -36,7 +36,6 @@ target triple = "@CFG_TARGET_TRIPLE@" %class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_scheduler*, i64 } %struct.rust_cond = type { i8 } %class.timer = type { i32 (...)**, i64, i64 } -%"class.rust_task::wakeup_callback" = type { i32 (...)** } %class.hash_map.4 = type { %"struct.hash_map::map_entry"* } %"struct.hash_map::map_entry" = type opaque %class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* } @@ -105,12 +104,12 @@ define void @rust_intrinsic_get_type_desc(i8** nocapture %retptr, i8* nocapture ret void } -define void @rust_intrinsic_task_sleep(i8** nocapture %retptr, i8* nocapture %env, i64 %time_in_us) uwtable { - tail call void @rust_task_sleep(i64 %time_in_us) +define void @rust_intrinsic_task_sleep(i8** nocapture %retptr, i8* nocapture %env, %struct.rust_task* %task, i64 %time_in_us) uwtable { + tail call void @rust_task_sleep(%struct.rust_task* %task, i64 %time_in_us) ret void } -declare void @rust_task_sleep(i64) +declare void @rust_task_sleep(%struct.rust_task*, i64) !0 = metadata !{metadata !"any pointer", metadata !1} !1 = metadata !{metadata !"omnipotent char", metadata !2} diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index dd5d2bd1054..0ae191da0f6 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -511,8 +511,7 @@ chan_id_send(type_desc *t, rust_task_id target_task_id, // This is called by an intrinsic on the Rust stack. // Do not call on the C stack. extern "C" CDECL void -rust_task_sleep(size_t time_in_us) { - rust_task *task = rust_scheduler::get_task(); +rust_task_sleep(rust_task *task, size_t time_in_us) { task->yield(time_in_us); }