Get rid of taskpointer-passing throughout the compiler
Only intrinsics still take a dummy taskptr. We'll have to do some makefile stunts to snapshot a version without taskptrs-in-intrinsics. Issue #466
This commit is contained in:
parent
457683c7fe
commit
8124846b2c
11 changed files with 52 additions and 80 deletions
|
@ -31,7 +31,7 @@ type upcalls =
|
||||||
rust_personality: ValueRef};
|
rust_personality: ValueRef};
|
||||||
|
|
||||||
fn declare_upcalls(_tn: type_names, tydesc_type: TypeRef,
|
fn declare_upcalls(_tn: type_names, tydesc_type: TypeRef,
|
||||||
taskptr_type: TypeRef, llmod: ModuleRef) -> @upcalls {
|
llmod: ModuleRef) -> @upcalls {
|
||||||
fn decl(llmod: ModuleRef, name: str, tys: [TypeRef], rv: TypeRef) ->
|
fn decl(llmod: ModuleRef, name: str, tys: [TypeRef], rv: TypeRef) ->
|
||||||
ValueRef {
|
ValueRef {
|
||||||
let arg_tys: [TypeRef] = [];
|
let arg_tys: [TypeRef] = [];
|
||||||
|
@ -63,7 +63,7 @@ fn declare_upcalls(_tn: type_names, tydesc_type: TypeRef,
|
||||||
T_ptr(T_i8())]),
|
T_ptr(T_i8())]),
|
||||||
cmp_type:
|
cmp_type:
|
||||||
dv("cmp_type",
|
dv("cmp_type",
|
||||||
[T_ptr(T_i1()), taskptr_type, T_ptr(tydesc_type),
|
[T_ptr(T_i1()), T_ptr(tydesc_type),
|
||||||
T_ptr(T_ptr(tydesc_type)), T_ptr(T_i8()), T_ptr(T_i8()),
|
T_ptr(T_ptr(tydesc_type)), T_ptr(T_i8()), T_ptr(T_i8()),
|
||||||
T_i8()]),
|
T_i8()]),
|
||||||
log_type:
|
log_type:
|
||||||
|
|
|
@ -92,10 +92,7 @@ fn type_of_fn(cx: @crate_ctxt, sp: span, proto: ast::proto,
|
||||||
let out_ty = T_ptr(type_of_inner(cx, sp, output));
|
let out_ty = T_ptr(type_of_inner(cx, sp, output));
|
||||||
atys += [ret_ref ? T_ptr(out_ty) : out_ty];
|
atys += [ret_ref ? T_ptr(out_ty) : out_ty];
|
||||||
|
|
||||||
// Arg 1: task pointer.
|
// Arg 1: Env (closure-bindings / self-obj)
|
||||||
atys += [T_taskptr(*cx)];
|
|
||||||
|
|
||||||
// Arg 2: Env (closure-bindings / self-obj)
|
|
||||||
if is_method {
|
if is_method {
|
||||||
atys += [T_ptr(cx.rust_object_type)];
|
atys += [T_ptr(cx.rust_object_type)];
|
||||||
} else {
|
} else {
|
||||||
|
@ -109,7 +106,7 @@ fn type_of_fn(cx: @crate_ctxt, sp: span, proto: ast::proto,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Args >3: ty params, if not acquired via capture...
|
// Args >2: ty params, if not acquired via capture...
|
||||||
if !is_method {
|
if !is_method {
|
||||||
let i = 0u;
|
let i = 0u;
|
||||||
while i < ty_param_count { atys += [T_ptr(cx.tydesc_type)]; i += 1u; }
|
while i < ty_param_count { atys += [T_ptr(cx.tydesc_type)]; i += 1u; }
|
||||||
|
@ -349,10 +346,6 @@ fn decl_internal_cdecl_fn(llmod: ModuleRef, name: str, llty: TypeRef) ->
|
||||||
ret llfn;
|
ret llfn;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decl_glue(llmod: ModuleRef, cx: crate_ctxt, s: str) -> ValueRef {
|
|
||||||
ret decl_cdecl_fn(llmod, s, T_fn([T_taskptr(cx)], T_void()));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_extern_fn(externs: hashmap<str, ValueRef>, llmod: ModuleRef, name: str,
|
fn get_extern_fn(externs: hashmap<str, ValueRef>, llmod: ModuleRef, name: str,
|
||||||
cc: uint, ty: TypeRef) -> ValueRef {
|
cc: uint, ty: TypeRef) -> ValueRef {
|
||||||
if externs.contains_key(name) { ret externs.get(name); }
|
if externs.contains_key(name) { ret externs.get(name); }
|
||||||
|
@ -1217,7 +1210,7 @@ fn make_generic_glue_inner(cx: @local_ctxt, sp: span, t: ty::t,
|
||||||
} else { T_ptr(T_i8()) };
|
} else { T_ptr(T_i8()) };
|
||||||
|
|
||||||
let ty_param_count = std::vec::len::<uint>(ty_params);
|
let ty_param_count = std::vec::len::<uint>(ty_params);
|
||||||
let lltyparams = llvm::LLVMGetParam(llfn, 3u);
|
let lltyparams = llvm::LLVMGetParam(llfn, 2u);
|
||||||
let load_env_bcx = new_raw_block_ctxt(fcx, fcx.llloadenv);
|
let load_env_bcx = new_raw_block_ctxt(fcx, fcx.llloadenv);
|
||||||
let lltydescs = [mutable];
|
let lltydescs = [mutable];
|
||||||
let p = 0u;
|
let p = 0u;
|
||||||
|
@ -1235,12 +1228,12 @@ fn make_generic_glue_inner(cx: @local_ctxt, sp: span, t: ty::t,
|
||||||
|
|
||||||
let bcx = new_top_block_ctxt(fcx);
|
let bcx = new_top_block_ctxt(fcx);
|
||||||
let lltop = bcx.llbb;
|
let lltop = bcx.llbb;
|
||||||
let llrawptr0 = llvm::LLVMGetParam(llfn, 4u);
|
let llrawptr0 = llvm::LLVMGetParam(llfn, 3u);
|
||||||
let llval0 = BitCast(bcx, llrawptr0, llty);
|
let llval0 = BitCast(bcx, llrawptr0, llty);
|
||||||
alt helper {
|
alt helper {
|
||||||
default_helper(helper) { helper(bcx, llval0, t); }
|
default_helper(helper) { helper(bcx, llval0, t); }
|
||||||
copy_helper(helper) {
|
copy_helper(helper) {
|
||||||
let llrawptr1 = llvm::LLVMGetParam(llfn, 5u);
|
let llrawptr1 = llvm::LLVMGetParam(llfn, 4u);
|
||||||
let llval1 = BitCast(bcx, llrawptr1, llty);
|
let llval1 = BitCast(bcx, llrawptr1, llty);
|
||||||
helper(bcx, llval0, llval1, t);
|
helper(bcx, llval0, llval1, t);
|
||||||
}
|
}
|
||||||
|
@ -1463,7 +1456,7 @@ fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: ast::def_id,
|
||||||
cx = val.bcx;
|
cx = val.bcx;
|
||||||
// Find and call the actual destructor.
|
// Find and call the actual destructor.
|
||||||
let dtor_addr = trans_common::get_res_dtor(ccx, cx.sp, did, inner_t);
|
let dtor_addr = trans_common::get_res_dtor(ccx, cx.sp, did, inner_t);
|
||||||
let args = [cx.fcx.llretptr, cx.fcx.lltaskptr, null_env_ptr(cx)];
|
let args = [cx.fcx.llretptr, null_env_ptr(cx)];
|
||||||
for tp: ty::t in tps {
|
for tp: ty::t in tps {
|
||||||
let ti: option::t<@tydesc_info> = none;
|
let ti: option::t<@tydesc_info> = none;
|
||||||
let td = get_tydesc(cx, tp, false, tps_normal, ti).result;
|
let td = get_tydesc(cx, tp, false, tps_normal, ti).result;
|
||||||
|
@ -1888,9 +1881,8 @@ fn call_tydesc_glue_full(cx: @block_ctxt, v: ValueRef, tydesc: ValueRef,
|
||||||
some(sgf) { llfn = sgf; }
|
some(sgf) { llfn = sgf; }
|
||||||
}
|
}
|
||||||
|
|
||||||
Call(cx, llfn,
|
Call(cx, llfn, [C_null(T_ptr(T_nil())), C_null(T_ptr(T_nil())),
|
||||||
[C_null(T_ptr(T_nil())), cx.fcx.lltaskptr, C_null(T_ptr(T_nil())),
|
lltydescs, llrawptr]);
|
||||||
lltydescs, llrawptr]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call_tydesc_glue(cx: @block_ctxt, v: ValueRef, t: ty::t, field: int) ->
|
fn call_tydesc_glue(cx: @block_ctxt, v: ValueRef, t: ty::t, field: int) ->
|
||||||
|
@ -1937,7 +1929,7 @@ fn call_cmp_glue(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef, t: ty::t,
|
||||||
}
|
}
|
||||||
|
|
||||||
let llcmpresultptr = alloca(bcx, T_i1());
|
let llcmpresultptr = alloca(bcx, T_i1());
|
||||||
Call(bcx, llfn, [llcmpresultptr, bcx.fcx.lltaskptr, lltydesc, lltydescs,
|
Call(bcx, llfn, [llcmpresultptr, lltydesc, lltydescs,
|
||||||
llrawlhsptr, llrawrhsptr, llop]);
|
llrawlhsptr, llrawrhsptr, llop]);
|
||||||
ret rslt(bcx, Load(bcx, llcmpresultptr));
|
ret rslt(bcx, Load(bcx, llcmpresultptr));
|
||||||
}
|
}
|
||||||
|
@ -2921,7 +2913,7 @@ fn trans_for_each(cx: @block_ctxt, local: @ast::local, seq: @ast::expr,
|
||||||
let bcx = new_top_block_ctxt(fcx);
|
let bcx = new_top_block_ctxt(fcx);
|
||||||
// Add bindings for the loop variable alias.
|
// Add bindings for the loop variable alias.
|
||||||
bcx = trans_alt::bind_irrefutable_pat(bcx, local.node.pat,
|
bcx = trans_alt::bind_irrefutable_pat(bcx, local.node.pat,
|
||||||
llvm::LLVMGetParam(fcx.llfn, 3u),
|
llvm::LLVMGetParam(fcx.llfn, 2u),
|
||||||
false);
|
false);
|
||||||
let lltop = bcx.llbb;
|
let lltop = bcx.llbb;
|
||||||
bcx = trans_block(bcx, body);
|
bcx = trans_block(bcx, body);
|
||||||
|
@ -3560,10 +3552,10 @@ fn trans_bind_thunk(cx: @local_ctxt, sp: span, incoming_fty: ty::t,
|
||||||
let llargs: [ValueRef] = alt ty::ty_fn_proto(ccx.tcx, outgoing_fty) {
|
let llargs: [ValueRef] = alt ty::ty_fn_proto(ccx.tcx, outgoing_fty) {
|
||||||
ast::proto_bare. {
|
ast::proto_bare. {
|
||||||
// Bare functions don't take an environment
|
// Bare functions don't take an environment
|
||||||
[llretptr, fcx.lltaskptr]
|
[llretptr]
|
||||||
}
|
}
|
||||||
_ {
|
_ {
|
||||||
[llretptr, fcx.lltaskptr, lltargetenv]
|
[llretptr, lltargetenv]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3583,7 +3575,7 @@ fn trans_bind_thunk(cx: @local_ctxt, sp: span, incoming_fty: ty::t,
|
||||||
i += 1u;
|
i += 1u;
|
||||||
}
|
}
|
||||||
|
|
||||||
let a: uint = 3u; // retptr, task ptr, env come first
|
let a: uint = 2u; // retptr, env come first
|
||||||
let b: int = starting_idx;
|
let b: int = starting_idx;
|
||||||
let outgoing_arg_index: uint = 0u;
|
let outgoing_arg_index: uint = 0u;
|
||||||
let llout_arg_tys: [TypeRef] =
|
let llout_arg_tys: [TypeRef] =
|
||||||
|
@ -3847,10 +3839,7 @@ fn trans_args(cx: @block_ctxt, outer_cx: @block_ctxt, llenv: ValueRef,
|
||||||
llargs += [PointerCast(cx, llretslot, llretty)];
|
llargs += [PointerCast(cx, llretslot, llretty)];
|
||||||
} else { llargs += [llretslot]; }
|
} else { llargs += [llretslot]; }
|
||||||
|
|
||||||
// Arg 1: task pointer.
|
// Arg 1: Env (closure-bindings / self-obj)
|
||||||
llargs += [bcx.fcx.lltaskptr];
|
|
||||||
|
|
||||||
// Arg 2: Env (closure-bindings / self-obj)
|
|
||||||
alt ty::ty_fn_proto(tcx, fn_ty) {
|
alt ty::ty_fn_proto(tcx, fn_ty) {
|
||||||
ast::proto_bare. { }
|
ast::proto_bare. { }
|
||||||
_ {
|
_ {
|
||||||
|
@ -3858,7 +3847,7 @@ fn trans_args(cx: @block_ctxt, outer_cx: @block_ctxt, llenv: ValueRef,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Args >3: ty_params ...
|
// Args >2: ty_params ...
|
||||||
llargs += lltydescs;
|
llargs += lltydescs;
|
||||||
|
|
||||||
// ... then possibly an lliterbody argument.
|
// ... then possibly an lliterbody argument.
|
||||||
|
@ -4639,7 +4628,7 @@ fn trans_put(in_cx: @block_ctxt, e: option::t<@ast::expr>) -> @block_ctxt {
|
||||||
}
|
}
|
||||||
let bcx = cx;
|
let bcx = cx;
|
||||||
let dummy_retslot = alloca(bcx, T_nil());
|
let dummy_retslot = alloca(bcx, T_nil());
|
||||||
let llargs: [ValueRef] = [dummy_retslot, cx.fcx.lltaskptr, llenv];
|
let llargs: [ValueRef] = [dummy_retslot, llenv];
|
||||||
alt e {
|
alt e {
|
||||||
none. {
|
none. {
|
||||||
llargs += [C_null(T_ptr(T_nil()))];
|
llargs += [C_null(T_ptr(T_nil()))];
|
||||||
|
@ -5110,8 +5099,7 @@ fn new_fn_ctxt_w_id(cx: @local_ctxt, sp: span, llfndecl: ValueRef,
|
||||||
let llbbs = mk_standard_basic_blocks(llfndecl);
|
let llbbs = mk_standard_basic_blocks(llfndecl);
|
||||||
// FIXME: llenv is not correct for bare functions
|
// FIXME: llenv is not correct for bare functions
|
||||||
ret @{llfn: llfndecl,
|
ret @{llfn: llfndecl,
|
||||||
lltaskptr: llvm::LLVMGetParam(llfndecl, 1u),
|
llenv: llvm::LLVMGetParam(llfndecl, 1u),
|
||||||
llenv: llvm::LLVMGetParam(llfndecl, 2u),
|
|
||||||
llretptr: llvm::LLVMGetParam(llfndecl, 0u),
|
llretptr: llvm::LLVMGetParam(llfndecl, 0u),
|
||||||
mutable llstaticallocas: llbbs.sa,
|
mutable llstaticallocas: llbbs.sa,
|
||||||
mutable llloadenv: llbbs.ca,
|
mutable llloadenv: llbbs.ca,
|
||||||
|
@ -5141,8 +5129,8 @@ fn new_fn_ctxt(cx: @local_ctxt, sp: span, llfndecl: ValueRef) -> @fn_ctxt {
|
||||||
|
|
||||||
fn implicit_args_for_fn(proto: ast::proto) -> uint {
|
fn implicit_args_for_fn(proto: ast::proto) -> uint {
|
||||||
alt proto {
|
alt proto {
|
||||||
ast::proto_bare. { 2u }
|
ast::proto_bare. { 1u }
|
||||||
_ { 3u }
|
_ { 2u }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5666,10 +5654,9 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
|
||||||
let lltop = bcx.llbb;
|
let lltop = bcx.llbb;
|
||||||
|
|
||||||
let lloutputarg = llvm::LLVMGetParam(llfdecl, 0u);
|
let lloutputarg = llvm::LLVMGetParam(llfdecl, 0u);
|
||||||
let lltaskarg = llvm::LLVMGetParam(llfdecl, 1u);
|
let llenvarg = llvm::LLVMGetParam(llfdecl, 1u);
|
||||||
let llenvarg = llvm::LLVMGetParam(llfdecl, 2u);
|
let args = [lloutputarg, llenvarg];
|
||||||
let args = [lloutputarg, lltaskarg, llenvarg];
|
if takes_argv { args += [llvm::LLVMGetParam(llfdecl, 2u)]; }
|
||||||
if takes_argv { args += [llvm::LLVMGetParam(llfdecl, 3u)]; }
|
|
||||||
Call(bcx, main_llfn, args);
|
Call(bcx, main_llfn, args);
|
||||||
build_return(bcx);
|
build_return(bcx);
|
||||||
|
|
||||||
|
@ -5825,16 +5812,11 @@ fn register_native_fn(ccx: @crate_ctxt, sp: span, path: [str], name: str,
|
||||||
let rty = ty::ty_fn_ret(ccx.tcx, fn_type);
|
let rty = ty::ty_fn_ret(ccx.tcx, fn_type);
|
||||||
let rty_is_nil = ty::type_is_nil(ccx.tcx, rty);
|
let rty_is_nil = ty::type_is_nil(ccx.tcx, rty);
|
||||||
|
|
||||||
let lltaskptr;
|
|
||||||
if cast_to_i32 {
|
|
||||||
lltaskptr = vp2i(bcx, fcx.lltaskptr);
|
|
||||||
} else { lltaskptr = fcx.lltaskptr; }
|
|
||||||
|
|
||||||
let call_args: [ValueRef] = [];
|
let call_args: [ValueRef] = [];
|
||||||
if pass_task { call_args += [lltaskptr]; }
|
if pass_task { call_args += [C_null(T_ptr(ccx.task_type))]; }
|
||||||
if uses_retptr { call_args += [bcx.fcx.llretptr]; }
|
if uses_retptr { call_args += [bcx.fcx.llretptr]; }
|
||||||
|
|
||||||
let arg_n = 3u;
|
let arg_n = 2u;
|
||||||
for each i: uint in uint::range(0u, num_ty_param) {
|
for each i: uint in uint::range(0u, num_ty_param) {
|
||||||
let llarg = llvm::LLVMGetParam(fcx.llfn, arg_n);
|
let llarg = llvm::LLVMGetParam(fcx.llfn, arg_n);
|
||||||
fcx.lltydescs += [llarg];
|
fcx.lltydescs += [llarg];
|
||||||
|
@ -6144,11 +6126,6 @@ fn trap(bcx: @block_ctxt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decl_no_op_type_glue(llmod: ModuleRef, taskptr_type: TypeRef) -> ValueRef {
|
|
||||||
let ty = T_fn([taskptr_type, T_ptr(T_i8())], T_void());
|
|
||||||
ret decl_cdecl_fn(llmod, abi::no_op_type_glue_name(), ty);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
|
fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
|
||||||
let elttype = T_struct([T_int(), T_int()]);
|
let elttype = T_struct([T_int(), T_int()]);
|
||||||
let maptype = T_array(elttype, ccx.module_data.size() + 1u);
|
let maptype = T_array(elttype, ccx.module_data.size() + 1u);
|
||||||
|
@ -6255,9 +6232,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
|
||||||
let tn = mk_type_names();
|
let tn = mk_type_names();
|
||||||
let intrinsics = declare_intrinsics(llmod);
|
let intrinsics = declare_intrinsics(llmod);
|
||||||
let task_type = T_task();
|
let task_type = T_task();
|
||||||
let taskptr_type = T_ptr(task_type);
|
let tydesc_type = T_tydesc();
|
||||||
tn.associate("taskptr", taskptr_type);
|
|
||||||
let tydesc_type = T_tydesc(taskptr_type);
|
|
||||||
tn.associate("tydesc", tydesc_type);
|
tn.associate("tydesc", tydesc_type);
|
||||||
let hasher = ty::hash_ty;
|
let hasher = ty::hash_ty;
|
||||||
let eqer = ty::eq_ty;
|
let eqer = ty::eq_ty;
|
||||||
|
@ -6302,7 +6277,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
|
||||||
mutable n_real_glues: 0u,
|
mutable n_real_glues: 0u,
|
||||||
fn_times: @mutable []},
|
fn_times: @mutable []},
|
||||||
upcalls:
|
upcalls:
|
||||||
upcall::declare_upcalls(tn, tydesc_type, taskptr_type, llmod),
|
upcall::declare_upcalls(tn, tydesc_type, llmod),
|
||||||
rust_object_type: T_rust_object(),
|
rust_object_type: T_rust_object(),
|
||||||
tydesc_type: tydesc_type,
|
tydesc_type: tydesc_type,
|
||||||
task_type: task_type,
|
task_type: task_type,
|
||||||
|
|
|
@ -234,7 +234,6 @@ type fn_ctxt =
|
||||||
|
|
||||||
// This function's enclosing local context.
|
// This function's enclosing local context.
|
||||||
{llfn: ValueRef,
|
{llfn: ValueRef,
|
||||||
lltaskptr: ValueRef,
|
|
||||||
llenv: ValueRef,
|
llenv: ValueRef,
|
||||||
llretptr: ValueRef,
|
llretptr: ValueRef,
|
||||||
mutable llstaticallocas: BasicBlockRef,
|
mutable llstaticallocas: BasicBlockRef,
|
||||||
|
@ -605,15 +604,15 @@ fn T_cmp_glue_fn(cx: crate_ctxt) -> TypeRef {
|
||||||
ret t;
|
ret t;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn T_tydesc(taskptr_type: TypeRef) -> TypeRef {
|
fn T_tydesc() -> TypeRef {
|
||||||
let tydesc = T_named_struct("tydesc");
|
let tydesc = T_named_struct("tydesc");
|
||||||
let tydescpp = T_ptr(T_ptr(tydesc));
|
let tydescpp = T_ptr(T_ptr(tydesc));
|
||||||
let pvoid = T_ptr(T_i8());
|
let pvoid = T_ptr(T_i8());
|
||||||
let glue_fn_ty =
|
let glue_fn_ty =
|
||||||
T_ptr(T_fn([T_ptr(T_nil()), taskptr_type, T_ptr(T_nil()), tydescpp,
|
T_ptr(T_fn([T_ptr(T_nil()), T_ptr(T_nil()), tydescpp,
|
||||||
pvoid], T_void()));
|
pvoid], T_void()));
|
||||||
let cmp_glue_fn_ty =
|
let cmp_glue_fn_ty =
|
||||||
T_ptr(T_fn([T_ptr(T_i1()), taskptr_type, T_ptr(tydesc), tydescpp,
|
T_ptr(T_fn([T_ptr(T_i1()), T_ptr(tydesc), tydescpp,
|
||||||
pvoid, pvoid, T_i8()], T_void()));
|
pvoid, pvoid, T_i8()], T_void()));
|
||||||
|
|
||||||
let elems =
|
let elems =
|
||||||
|
|
|
@ -680,13 +680,12 @@ fn process_bkwding_mthd(cx: @local_ctxt, sp: span, m: @ty::method,
|
||||||
|
|
||||||
// Set up the three implicit arguments to the outer method we'll need to
|
// Set up the three implicit arguments to the outer method we'll need to
|
||||||
// call.
|
// call.
|
||||||
let llouter_mthd_args: [ValueRef] = [llretptr, fcx.lltaskptr,
|
let llouter_mthd_args: [ValueRef] = [llretptr, llself_obj_ptr];
|
||||||
llself_obj_ptr];
|
|
||||||
|
|
||||||
// Copy the explicit arguments that are being passed into the forwarding
|
// Copy the explicit arguments that are being passed into the forwarding
|
||||||
// function (they're in fcx.llargs) to llouter_mthd_args.
|
// function (they're in fcx.llargs) to llouter_mthd_args.
|
||||||
|
|
||||||
let a: uint = 3u; // retptr, task ptr, env come first
|
let a: uint = 2u; // retptr, env come first
|
||||||
for arg: ty::arg in m.inputs {
|
for arg: ty::arg in m.inputs {
|
||||||
llouter_mthd_args += [llvm::LLVMGetParam(llbackwarding_fn, a)];
|
llouter_mthd_args += [llvm::LLVMGetParam(llbackwarding_fn, a)];
|
||||||
a += 1u;
|
a += 1u;
|
||||||
|
@ -833,12 +832,12 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: span, m: @ty::method,
|
||||||
|
|
||||||
// Set up the three implicit arguments to the original method we'll need
|
// Set up the three implicit arguments to the original method we'll need
|
||||||
// to call.
|
// to call.
|
||||||
let llorig_mthd_args: [ValueRef] = [llretptr, fcx.lltaskptr, self_stack];
|
let llorig_mthd_args: [ValueRef] = [llretptr, self_stack];
|
||||||
|
|
||||||
// Copy the explicit arguments that are being passed into the forwarding
|
// Copy the explicit arguments that are being passed into the forwarding
|
||||||
// function (they're in fcx.llargs) to llorig_mthd_args.
|
// function (they're in fcx.llargs) to llorig_mthd_args.
|
||||||
|
|
||||||
let a: uint = 3u; // retptr, task ptr, env come first
|
let a: uint = 2u; // retptr, env come first
|
||||||
for arg: ty::arg in m.inputs {
|
for arg: ty::arg in m.inputs {
|
||||||
llorig_mthd_args += [llvm::LLVMGetParam(llforwarding_fn, a)];
|
llorig_mthd_args += [llvm::LLVMGetParam(llforwarding_fn, a)];
|
||||||
a += 1u;
|
a += 1u;
|
||||||
|
|
|
@ -28,7 +28,7 @@ rust_intrinsic_cast(rust_task *task, void *retptr, type_desc *t1,
|
||||||
type_desc *t2, void *src)
|
type_desc *t2, void *src)
|
||||||
{
|
{
|
||||||
if (t1->size != t2->size) {
|
if (t1->size != t2->size) {
|
||||||
upcall_fail(task, "attempt to cast values of differing sizes",
|
upcall_fail("attempt to cast values of differing sizes",
|
||||||
__FILE__, __LINE__);
|
__FILE__, __LINE__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,6 @@ rust_intrinsic_addr_of(rust_task *task, void **retptr, type_desc *ty,
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_intrinsic_recv(rust_task *task, void **retptr, type_desc *ty,
|
rust_intrinsic_recv(rust_task *task, void **retptr, type_desc *ty,
|
||||||
rust_port *port) {
|
rust_port *port) {
|
||||||
port_recv(task, (uintptr_t*)retptr, port);
|
port_recv((uintptr_t*)retptr, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ entry:
|
||||||
br i1 %cmp, label %if.end, label %if.then
|
br i1 %cmp, label %if.end, label %if.then
|
||||||
|
|
||||||
if.then: ; preds = %entry
|
if.then: ; preds = %entry
|
||||||
tail call void @upcall_fail(%struct.rust_task* %task, i8* getelementptr inbounds ([42 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8]* @.str1, i32 0, i32 0), i32 45)
|
tail call void @upcall_fail(i8* getelementptr inbounds ([42 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8]* @.str1, i32 0, i32 0), i32 45)
|
||||||
br label %return
|
br label %return
|
||||||
|
|
||||||
if.end: ; preds = %entry
|
if.end: ; preds = %entry
|
||||||
|
@ -94,7 +94,7 @@ return: ; preds = %if.end, %if.then
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
declare void @upcall_fail(%struct.rust_task*, i8*, i8*, i32)
|
declare void @upcall_fail(i8*, i8*, i32)
|
||||||
|
|
||||||
declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
|
declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
|
||||||
|
|
||||||
|
@ -107,11 +107,11 @@ entry:
|
||||||
define linkonce_odr void @rust_intrinsic_recv(%struct.rust_task* %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
|
define linkonce_odr void @rust_intrinsic_recv(%struct.rust_task* %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
|
||||||
entry:
|
entry:
|
||||||
%0 = bitcast i8** %retptr to i32*
|
%0 = bitcast i8** %retptr to i32*
|
||||||
tail call void @port_recv(%struct.rust_task* %task, i32* %0, %class.rust_port* %port)
|
tail call void @port_recv(i32* %0, %class.rust_port* %port)
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
declare void @port_recv(%struct.rust_task*, i32*, %class.rust_port*)
|
declare void @port_recv(i32*, %class.rust_port*)
|
||||||
|
|
||||||
!0 = metadata !{metadata !"long", metadata !1}
|
!0 = metadata !{metadata !"long", metadata !1}
|
||||||
!1 = metadata !{metadata !"omnipotent char", metadata !2}
|
!1 = metadata !{metadata !"omnipotent char", metadata !2}
|
||||||
|
|
|
@ -452,9 +452,9 @@ struct fn_env_pair {
|
||||||
|
|
||||||
// FIXME This is probably not needed at all anymore. Have to rearrange some
|
// FIXME This is probably not needed at all anymore. Have to rearrange some
|
||||||
// argument passing to remove it.
|
// argument passing to remove it.
|
||||||
void rust_spawn_wrapper(void* retptr, rust_task* taskptr, void* envptr,
|
void rust_spawn_wrapper(void* retptr, void* envptr,
|
||||||
void(*func)(void*, rust_task*, void*)) {
|
void(*func)(void*, void*)) {
|
||||||
func(retptr, taskptr, envptr);
|
func(retptr, envptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" CDECL void
|
extern "C" CDECL void
|
||||||
|
|
|
@ -245,9 +245,9 @@ struct rust_timer {
|
||||||
|
|
||||||
#include "rust_util.h"
|
#include "rust_util.h"
|
||||||
|
|
||||||
typedef void CDECL (glue_fn)(void *, rust_task *, void *,
|
typedef void CDECL (glue_fn)(void *, void *,
|
||||||
const type_desc **, void *);
|
const type_desc **, void *);
|
||||||
typedef void CDECL (cmp_glue_fn)(void *, rust_task *, void *,
|
typedef void CDECL (cmp_glue_fn)(void *, void *,
|
||||||
const type_desc **,
|
const type_desc **,
|
||||||
void *, void *, int8_t);
|
void *, void *, int8_t);
|
||||||
|
|
||||||
|
|
|
@ -530,9 +530,10 @@ log::walk_res(const rust_fn *dtor, unsigned n_params,
|
||||||
} // end namespace shape
|
} // end namespace shape
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
upcall_cmp_type(int8_t *result, rust_task *task, const type_desc *tydesc,
|
upcall_cmp_type(int8_t *result, const type_desc *tydesc,
|
||||||
const type_desc **subtydescs, uint8_t *data_0,
|
const type_desc **subtydescs, uint8_t *data_0,
|
||||||
uint8_t *data_1, uint8_t cmp_type) {
|
uint8_t *data_1, uint8_t cmp_type) {
|
||||||
|
rust_task *task = rust_scheduler::get_task();
|
||||||
shape::arena arena;
|
shape::arena arena;
|
||||||
|
|
||||||
// FIXME: This may well be broken when comparing two closures or objects
|
// FIXME: This may well be broken when comparing two closures or objects
|
||||||
|
|
|
@ -130,8 +130,7 @@ struct spawn_args {
|
||||||
rust_task *task;
|
rust_task *task;
|
||||||
uintptr_t a3;
|
uintptr_t a3;
|
||||||
uintptr_t a4;
|
uintptr_t a4;
|
||||||
void (*CDECL f)(int *, rust_task *,
|
void (*CDECL f)(int *, uintptr_t, uintptr_t);
|
||||||
uintptr_t, uintptr_t);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rust_closure_env {
|
struct rust_closure_env {
|
||||||
|
@ -147,7 +146,7 @@ void task_start_wrapper(spawn_args *a)
|
||||||
|
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
try {
|
try {
|
||||||
a->f(&rval, task, a->a3, a->a4);
|
a->f(&rval, a->a3, a->a4);
|
||||||
} catch (rust_task *ex) {
|
} catch (rust_task *ex) {
|
||||||
A(task->sched, ex == task,
|
A(task->sched, ex == task,
|
||||||
"Expected this task to be thrown for unwinding");
|
"Expected this task to be thrown for unwinding");
|
||||||
|
|
|
@ -28,8 +28,7 @@ check_stack(rust_task *task) {
|
||||||
// dealing with reference counts
|
// dealing with reference counts
|
||||||
static inline void
|
static inline void
|
||||||
copy_elements(rust_task *task, type_desc *elem_t,
|
copy_elements(rust_task *task, type_desc *elem_t,
|
||||||
void *pdst, void *psrc, size_t n)
|
void *pdst, void *psrc, size_t n) {
|
||||||
{
|
|
||||||
char *dst = (char *)pdst, *src = (char *)psrc;
|
char *dst = (char *)pdst, *src = (char *)psrc;
|
||||||
memmove(dst, src, n);
|
memmove(dst, src, n);
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ copy_elements(rust_task *task, type_desc *elem_t,
|
||||||
size_t elem_size = elem_t->size;
|
size_t elem_size = elem_t->size;
|
||||||
const type_desc **tydescs = elem_t->first_param;
|
const type_desc **tydescs = elem_t->first_param;
|
||||||
for (char *p = dst; p < dst+n; p += elem_size) {
|
for (char *p = dst; p < dst+n; p += elem_size) {
|
||||||
take_glue(NULL, task, NULL, tydescs, p);
|
take_glue(NULL, NULL, tydescs, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue