intrinsics: Eliminate recv intrinsic
This intrinsic existed just to get ahold of the return pointer. I replaced it with a call_with_retptr intrinsic that grabs the return pointer and passes it to another Rust function, thereby eliminating the need to call C functions on the Rust stack.
This commit is contained in:
parent
93931311ff
commit
3a6320f71b
@ -48,11 +48,13 @@ fn chan_id_send<send T>(t: *sys::type_desc,
|
||||
fn rust_port_detach(po: *rust_port);
|
||||
fn get_port_id(po: *rust_port) -> port_id;
|
||||
fn rust_port_size(po: *rust_port) -> ctypes::size_t;
|
||||
fn port_recv(dptr: *uint, po: *rust_port,
|
||||
yield: *ctypes::uintptr_t);
|
||||
}
|
||||
|
||||
#[abi = "rust-intrinsic"]
|
||||
native mod rusti {
|
||||
fn recv<send T>(port: *rustrt::rust_port) -> T;
|
||||
fn call_with_retptr<send T>(&&f: fn@(*uint)) -> T;
|
||||
}
|
||||
|
||||
type port_id = int;
|
||||
@ -87,7 +89,7 @@ fn chan_id_send<send T>(t: *sys::type_desc,
|
||||
while rustrt::rust_port_size(po) > 0u {
|
||||
// FIXME: For some reason if we don't assign to something here
|
||||
// we end up with invalid reads in the drop glue.
|
||||
let _t = rusti::recv::<T>(po);
|
||||
let _t = recv_::<T>(po);
|
||||
}
|
||||
rustrt::del_port(po);
|
||||
}
|
||||
@ -140,7 +142,29 @@ fn port<send T>() -> port<T> {
|
||||
If no data is available on the port then the task will block until data
|
||||
becomes available.
|
||||
*/
|
||||
fn recv<send T>(p: port<T>) -> T { ret rusti::recv(***p) }
|
||||
fn recv<send T>(p: port<T>) -> T { recv_(***p) }
|
||||
|
||||
// Receive on a raw port pointer
|
||||
fn recv_<send T>(p: *rustrt::rust_port) -> T {
|
||||
// FIXME: Due to issue 1185 we can't use a return pointer when
|
||||
// calling C code, and since we can't create our own return
|
||||
// pointer on the stack, we're going to call a little intrinsic
|
||||
// that will grab the value of the return pointer, then call this
|
||||
// function, which we will then use to call the runtime.
|
||||
fn recv(dptr: *uint, port: *rustrt::rust_port,
|
||||
yield: *ctypes::uintptr_t) unsafe {
|
||||
rustrt::port_recv(dptr,
|
||||
port, yield);
|
||||
}
|
||||
let yield = 0u;
|
||||
let yieldp = ptr::addr_of(yield);
|
||||
let res = rusti::call_with_retptr(bind recv(_, p, yieldp));
|
||||
if yield != 0u {
|
||||
// Data isn't available yet, so res has not been initialized.
|
||||
task::yield();
|
||||
}
|
||||
ret res;
|
||||
}
|
||||
|
||||
/*
|
||||
Function: chan
|
||||
|
@ -53,12 +53,22 @@ rust_intrinsic_addr_of(void **retptr,
|
||||
*retptr = valptr;
|
||||
}
|
||||
|
||||
struct rust_fn {
|
||||
uintptr_t *fn;
|
||||
rust_box *env;
|
||||
};
|
||||
|
||||
typedef void (*retptr_fn)(void **retptr,
|
||||
void *env,
|
||||
void **dptr);
|
||||
// FIXME (1185): This exists just to get access to the return pointer
|
||||
extern "C" void
|
||||
rust_intrinsic_recv(void **retptr,
|
||||
void *env,
|
||||
type_desc *ty,
|
||||
rust_port *port) {
|
||||
port_recv((uintptr_t*)retptr, port);
|
||||
rust_intrinsic_call_with_retptr(void **retptr,
|
||||
void *env,
|
||||
type_desc *ty,
|
||||
rust_fn *recvfn) {
|
||||
retptr_fn fn = ((retptr_fn)(recvfn->fn));
|
||||
((retptr_fn)(*fn))(NULL, recvfn->env, retptr);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
|
@ -8,11 +8,20 @@ target triple = "@CFG_TARGET_TRIPLE@"
|
||||
%struct.UT_hash_table = type { %struct.UT_hash_bucket*, i32, i32, i32, %struct.UT_hash_handle*, i32, i32, i32, i32, i32 }
|
||||
%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 }
|
||||
%struct.rust_vec = type { i32, i32, [0 x i8] }
|
||||
%class.rust_port = type { i32, i32, %class.rust_kernel*, %struct.rust_task*, i32, %class.circular_buffer, %class.lock_and_signal }
|
||||
%class.rust_kernel = type { i32 (...)**, %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, %class.array_list.0, %struct.randctx, i32, %class.hash_map, i32, i32, i32, %struct.rust_env* }
|
||||
%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list, i8, i8, %class.lock_and_signal }
|
||||
%struct.rust_fn = type { i32*, %struct.rust_box* }
|
||||
%struct.rust_box = type opaque
|
||||
%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* }
|
||||
%struct.registers_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, i32, i32 }
|
||||
%struct.stk_seg = type { %struct.stk_seg*, i32, i32, i32, [0 x i8] }
|
||||
%struct.rust_scheduler = type { %class.rust_thread, i32, i32, %class.rust_log, i32, %class.rust_srv*, i8*, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_crate_cache, %struct.randctx, %class.rust_kernel*, i32, i32, %class.lock_and_signal, i32, %union.pthread_attr_t, %struct.rust_env*, %class.context }
|
||||
%class.rust_thread = type { i32 (...)**, i8, i32 }
|
||||
%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_scheduler*, i8 }
|
||||
%class.rust_srv = type { i32 (...)**, %struct.rust_env*, %class.memory_region }
|
||||
%struct.rust_env = type { i32, i32, i8*, i8, i8, i8* }
|
||||
%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list, i8, i8, %class.lock_and_signal }
|
||||
%class.array_list = type { i32, %"struct.memory_region::alloc_header"**, i32 }
|
||||
%"struct.memory_region::alloc_header" = type { i8 }
|
||||
%class.lock_and_signal = type { i32 (...)**, %union.pthread_cond_t, %union.pthread_mutex_t, i32, i8, i8 }
|
||||
@ -21,19 +30,16 @@ target triple = "@CFG_TARGET_TRIPLE@"
|
||||
%union.pthread_mutex_t = type { %"struct.<anonymous union>::__pthread_mutex_s" }
|
||||
%"struct.<anonymous union>::__pthread_mutex_s" = type { i32, i32, i32, i32, i32, %union.anon }
|
||||
%union.anon = type { i32 }
|
||||
%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_scheduler*, i8 }
|
||||
%struct.rust_scheduler = type { %class.rust_thread, i32, i32, %class.rust_log, i32, %class.rust_srv*, i8*, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_crate_cache, %struct.randctx, %class.rust_kernel*, i32, i32, %class.lock_and_signal, i32, %union.pthread_attr_t, %struct.rust_env*, %class.context }
|
||||
%class.rust_thread = type { i32 (...)**, i8, i32 }
|
||||
%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, 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* }
|
||||
%struct.registers_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, i32, i32 }
|
||||
%struct.stk_seg = type { %struct.stk_seg*, i32, i32, i32, [0 x i8] }
|
||||
%class.indexed_list = type { i32 (...)**, %class.array_list.1 }
|
||||
%class.array_list.1 = type { i32, %struct.rust_task**, i32 }
|
||||
%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_scheduler*, i32 }
|
||||
%struct.randctx = type { i32, [256 x i32], [256 x i32], i32, i32, i32 }
|
||||
%class.rust_kernel = type { i32 (...)**, %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, %class.array_list.3, %struct.randctx, i32, %class.hash_map, i32, i32, i32, %struct.rust_env* }
|
||||
%class.array_list.3 = type { i32, %struct.rust_scheduler**, i32 }
|
||||
%class.hash_map = type { %"struct.hash_map<int, rust_task *>::map_entry"* }
|
||||
%"struct.hash_map<int, rust_task *>::map_entry" = type opaque
|
||||
%union.pthread_attr_t = type { i32, [32 x i8] }
|
||||
%struct.rust_cond = type { i8 }
|
||||
%class.timer = type { i32 (...)**, i64, i64 }
|
||||
%class.hash_map.4 = type { %"struct.hash_map<int, rust_port *>::map_entry"* }
|
||||
@ -49,12 +55,6 @@ target triple = "@CFG_TARGET_TRIPLE@"
|
||||
%"class.std::map.5" = type { %"class.std::_Rb_tree.6" }
|
||||
%"class.std::_Rb_tree.6" = type { %"struct.std::_Rb_tree<void *, std::pair<void *const, std::basic_string<char> >, std::_Select1st<std::pair<void *const, std::basic_string<char> > >, std::less<void *>, std::allocator<std::pair<void *const, std::basic_string<char> > > >::_Rb_tree_impl" }
|
||||
%"struct.std::_Rb_tree<void *, std::pair<void *const, std::basic_string<char> >, std::_Select1st<std::pair<void *const, std::basic_string<char> > >, std::less<void *>, std::allocator<std::pair<void *const, std::basic_string<char> > > >::_Rb_tree_impl" = type { %"struct.std::less", %"struct.std::_Rb_tree_node_base", i32 }
|
||||
%struct.randctx = type { i32, [256 x i32], [256 x i32], i32, i32, i32 }
|
||||
%union.pthread_attr_t = type { i32, [32 x i8] }
|
||||
%class.array_list.0 = type { i32, %struct.rust_scheduler**, i32 }
|
||||
%class.hash_map = type { %"struct.hash_map<int, rust_task *>::map_entry"* }
|
||||
%"struct.hash_map<int, rust_task *>::map_entry" = type opaque
|
||||
%class.circular_buffer = type { %class.rust_kernel*, i32, i32, i32, i32, i8* }
|
||||
|
||||
define void @rust_intrinsic_vec_len(i32* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind {
|
||||
%1 = load %struct.rust_vec** %vp, align 4, !tbaa !0
|
||||
@ -90,14 +90,17 @@ define void @rust_intrinsic_addr_of(i8** nocapture %retptr, i8* nocapture %env,
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @rust_intrinsic_recv(i8** %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
|
||||
%1 = bitcast i8** %retptr to i32*
|
||||
tail call void @port_recv(i32* %1, %class.rust_port* %port)
|
||||
define void @rust_intrinsic_call_with_retptr(i8** %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_fn* nocapture %recvfn) {
|
||||
%1 = getelementptr inbounds %struct.rust_fn* %recvfn, i32 0, i32 0
|
||||
%2 = load i32** %1, align 4, !tbaa !0
|
||||
%3 = bitcast i32* %2 to void (i8**, i8*, i8**)*
|
||||
%4 = getelementptr inbounds %struct.rust_fn* %recvfn, i32 0, i32 1
|
||||
%5 = load %struct.rust_box** %4, align 4, !tbaa !0
|
||||
%6 = bitcast %struct.rust_box* %5 to i8*
|
||||
tail call void %3(i8** null, i8* %6, i8** %retptr)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @port_recv(i32*, %class.rust_port*)
|
||||
|
||||
define void @rust_intrinsic_get_type_desc(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* %ty) nounwind {
|
||||
%ty.c = bitcast %struct.type_desc* %ty to i8*
|
||||
store i8* %ty.c, i8** %retptr, align 4, !tbaa !0
|
||||
|
@ -8,11 +8,20 @@ target triple = "@CFG_TARGET_TRIPLE@"
|
||||
%struct.UT_hash_table = type { %struct.UT_hash_bucket*, i32, i32, i32, %struct.UT_hash_handle*, i64, i32, i32, i32, i32 }
|
||||
%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 }
|
||||
%struct.rust_vec = type { i64, i64, [0 x i8] }
|
||||
%class.rust_port = type { i64, i64, %class.rust_kernel*, %struct.rust_task*, i64, %class.circular_buffer, %class.lock_and_signal }
|
||||
%class.rust_kernel = type { i32 (...)**, %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, %class.array_list.0, %struct.randctx, i64, %class.hash_map, i64, i32, i32, %struct.rust_env* }
|
||||
%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list, i8, i8, %class.lock_and_signal }
|
||||
%struct.rust_fn = type { i64*, %struct.rust_box* }
|
||||
%struct.rust_box = type opaque
|
||||
%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* }
|
||||
%struct.registers_t = type { [22 x i64] }
|
||||
%struct.stk_seg = type { %struct.stk_seg*, i64, i32, [0 x i8] }
|
||||
%struct.rust_scheduler = type { %class.rust_thread, i64, i64, %class.rust_log, i32, %class.rust_srv*, i8*, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_crate_cache, %struct.randctx, %class.rust_kernel*, i32, i32, %class.lock_and_signal, i64, %union.pthread_attr_t, %struct.rust_env*, %class.context }
|
||||
%class.rust_thread = type { i32 (...)**, i8, i64 }
|
||||
%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_scheduler*, i8 }
|
||||
%class.rust_srv = type { i32 (...)**, %struct.rust_env*, %class.memory_region }
|
||||
%struct.rust_env = type { i64, i64, i8*, i8, i8, i8* }
|
||||
%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list, i8, i8, %class.lock_and_signal }
|
||||
%class.array_list = type { i64, %"struct.memory_region::alloc_header"**, i64 }
|
||||
%"struct.memory_region::alloc_header" = type { i8 }
|
||||
%class.lock_and_signal = type { i32 (...)**, %union.pthread_cond_t, %union.pthread_mutex_t, i64, i8, i8 }
|
||||
@ -21,19 +30,16 @@ target triple = "@CFG_TARGET_TRIPLE@"
|
||||
%union.pthread_mutex_t = type { %"struct.<anonymous union>::__pthread_mutex_s" }
|
||||
%"struct.<anonymous union>::__pthread_mutex_s" = type { i32, i32, i32, i32, i32, i32, %struct.__pthread_internal_list }
|
||||
%struct.__pthread_internal_list = type { %struct.__pthread_internal_list*, %struct.__pthread_internal_list* }
|
||||
%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_scheduler*, i8 }
|
||||
%struct.rust_scheduler = type { %class.rust_thread, i64, i64, %class.rust_log, i32, %class.rust_srv*, i8*, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_crate_cache, %struct.randctx, %class.rust_kernel*, i32, i32, %class.lock_and_signal, i64, %union.pthread_attr_t, %struct.rust_env*, %class.context }
|
||||
%class.rust_thread = type { i32 (...)**, i8, i64 }
|
||||
%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, 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* }
|
||||
%struct.registers_t = type { [22 x i64] }
|
||||
%struct.stk_seg = type { %struct.stk_seg*, i64, i32, [0 x i8] }
|
||||
%class.indexed_list = type { i32 (...)**, %class.array_list.1 }
|
||||
%class.array_list.1 = type { i64, %struct.rust_task**, i64 }
|
||||
%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_scheduler*, i64 }
|
||||
%struct.randctx = type { i64, [256 x i64], [256 x i64], i64, i64, i64 }
|
||||
%class.rust_kernel = type { i32 (...)**, %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, %class.array_list.3, %struct.randctx, i64, %class.hash_map, i64, i32, i32, %struct.rust_env* }
|
||||
%class.array_list.3 = type { i64, %struct.rust_scheduler**, i64 }
|
||||
%class.hash_map = type { %"struct.hash_map<long, rust_task *>::map_entry"* }
|
||||
%"struct.hash_map<long, rust_task *>::map_entry" = type opaque
|
||||
%union.pthread_attr_t = type { i64, [48 x i8] }
|
||||
%struct.rust_cond = type { i8 }
|
||||
%class.timer = type { i32 (...)**, i64, i64 }
|
||||
%class.hash_map.4 = type { %"struct.hash_map<long, rust_port *>::map_entry"* }
|
||||
@ -49,12 +55,6 @@ target triple = "@CFG_TARGET_TRIPLE@"
|
||||
%"class.std::map.5" = type { %"class.std::_Rb_tree.6" }
|
||||
%"class.std::_Rb_tree.6" = type { %"struct.std::_Rb_tree<void *, std::pair<void *const, std::basic_string<char> >, std::_Select1st<std::pair<void *const, std::basic_string<char> > >, std::less<void *>, std::allocator<std::pair<void *const, std::basic_string<char> > > >::_Rb_tree_impl" }
|
||||
%"struct.std::_Rb_tree<void *, std::pair<void *const, std::basic_string<char> >, std::_Select1st<std::pair<void *const, std::basic_string<char> > >, std::less<void *>, std::allocator<std::pair<void *const, std::basic_string<char> > > >::_Rb_tree_impl" = type { %"struct.std::less", %"struct.std::_Rb_tree_node_base", i64 }
|
||||
%struct.randctx = type { i64, [256 x i64], [256 x i64], i64, i64, i64 }
|
||||
%union.pthread_attr_t = type { i64, [48 x i8] }
|
||||
%class.array_list.0 = type { i64, %struct.rust_scheduler**, i64 }
|
||||
%class.hash_map = type { %"struct.hash_map<long, rust_task *>::map_entry"* }
|
||||
%"struct.hash_map<long, rust_task *>::map_entry" = type opaque
|
||||
%class.circular_buffer = type { %class.rust_kernel*, i64, i64, i64, i64, i8* }
|
||||
|
||||
define void @rust_intrinsic_vec_len(i64* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind uwtable {
|
||||
%1 = load %struct.rust_vec** %vp, align 8, !tbaa !0
|
||||
@ -90,14 +90,17 @@ define void @rust_intrinsic_addr_of(i8** nocapture %retptr, i8* nocapture %env,
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @rust_intrinsic_recv(i8** %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %class.rust_port* %port) uwtable {
|
||||
%1 = bitcast i8** %retptr to i64*
|
||||
tail call void @port_recv(i64* %1, %class.rust_port* %port)
|
||||
define void @rust_intrinsic_call_with_retptr(i8** %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_fn* nocapture %recvfn) uwtable {
|
||||
%1 = getelementptr inbounds %struct.rust_fn* %recvfn, i64 0, i32 0
|
||||
%2 = load i64** %1, align 8, !tbaa !0
|
||||
%3 = bitcast i64* %2 to void (i8**, i8*, i8**)*
|
||||
%4 = getelementptr inbounds %struct.rust_fn* %recvfn, i64 0, i32 1
|
||||
%5 = load %struct.rust_box** %4, align 8, !tbaa !0
|
||||
%6 = bitcast %struct.rust_box* %5 to i8*
|
||||
tail call void %3(i8** null, i8* %6, i8** %retptr)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @port_recv(i64*, %class.rust_port*)
|
||||
|
||||
define void @rust_intrinsic_get_type_desc(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* %ty) nounwind uwtable {
|
||||
%ty.c = bitcast %struct.type_desc* %ty to i8*
|
||||
store i8* %ty.c, i8** %retptr, align 8, !tbaa !0
|
||||
|
@ -515,10 +515,8 @@ rust_task_sleep(rust_task *task, size_t time_in_us) {
|
||||
task->yield(time_in_us);
|
||||
}
|
||||
|
||||
// This is called by an intrinsic on the Rust stack.
|
||||
// Do not call on the C stack.
|
||||
extern "C" CDECL void
|
||||
port_recv(uintptr_t *dptr, rust_port *port) {
|
||||
port_recv(uintptr_t *dptr, rust_port *port, uintptr_t *yield) {
|
||||
rust_task *task = rust_scheduler::get_task();
|
||||
{
|
||||
scoped_lock with(port->lock);
|
||||
@ -528,6 +526,7 @@ port_recv(uintptr_t *dptr, rust_port *port) {
|
||||
(uintptr_t) port, (uintptr_t) dptr, port->unit_sz);
|
||||
|
||||
if (port->receive(dptr)) {
|
||||
*yield = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -539,7 +538,8 @@ port_recv(uintptr_t *dptr, rust_port *port) {
|
||||
task->rendezvous_ptr = dptr;
|
||||
task->block(port, "waiting for rendezvous data");
|
||||
}
|
||||
task->yield(3);
|
||||
*yield = true;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user