Remove lltyparams field in trans::common::fn_ctxt
This commit is contained in:
parent
d0f5e58e95
commit
bc8a43a776
2 changed files with 18 additions and 69 deletions
|
@ -507,18 +507,17 @@ fn get_tydesc(cx: block, t: ty::t,
|
||||||
// FIXME[mono]
|
// FIXME[mono]
|
||||||
assert !ty::type_has_params(t);
|
assert !ty::type_has_params(t);
|
||||||
// Otherwise, generate a tydesc if necessary, and return it.
|
// Otherwise, generate a tydesc if necessary, and return it.
|
||||||
let info = get_static_tydesc(cx.ccx(), t, []);
|
let info = get_static_tydesc(cx.ccx(), t);
|
||||||
static_ti = some(info);
|
static_ti = some(info);
|
||||||
ret rslt(cx, info.tydesc);
|
ret rslt(cx, info.tydesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_static_tydesc(ccx: @crate_ctxt, t: ty::t, ty_params: [uint])
|
fn get_static_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info {
|
||||||
-> @tydesc_info {
|
|
||||||
alt ccx.tydescs.find(t) {
|
alt ccx.tydescs.find(t) {
|
||||||
some(info) { ret info; }
|
some(info) { ret info; }
|
||||||
none {
|
none {
|
||||||
ccx.stats.n_static_tydescs += 1u;
|
ccx.stats.n_static_tydescs += 1u;
|
||||||
let info = declare_tydesc(ccx, t, ty_params);
|
let info = declare_tydesc(ccx, t);
|
||||||
ccx.tydescs.insert(t, info);
|
ccx.tydescs.insert(t, info);
|
||||||
ret info;
|
ret info;
|
||||||
}
|
}
|
||||||
|
@ -569,8 +568,7 @@ fn set_glue_inlining(f: ValueRef, t: ty::t) {
|
||||||
|
|
||||||
|
|
||||||
// Generates the declaration for (but doesn't emit) a type descriptor.
|
// Generates the declaration for (but doesn't emit) a type descriptor.
|
||||||
fn declare_tydesc(ccx: @crate_ctxt, t: ty::t, ty_params: [uint])
|
fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info {
|
||||||
-> @tydesc_info {
|
|
||||||
log(debug, "+++ declare_tydesc " + ty_to_str(ccx.tcx, t));
|
log(debug, "+++ declare_tydesc " + ty_to_str(ccx.tcx, t));
|
||||||
let llsize;
|
let llsize;
|
||||||
let llalign;
|
let llalign;
|
||||||
|
@ -600,8 +598,7 @@ fn declare_tydesc(ccx: @crate_ctxt, t: ty::t, ty_params: [uint])
|
||||||
align: llalign,
|
align: llalign,
|
||||||
mutable take_glue: none,
|
mutable take_glue: none,
|
||||||
mutable drop_glue: none,
|
mutable drop_glue: none,
|
||||||
mutable free_glue: none,
|
mutable free_glue: none};
|
||||||
ty_params: ty_params};
|
|
||||||
log(debug, "--- declare_tydesc " + ty_to_str(ccx.tcx, t));
|
log(debug, "--- declare_tydesc " + ty_to_str(ccx.tcx, t));
|
||||||
ret info;
|
ret info;
|
||||||
}
|
}
|
||||||
|
@ -622,8 +619,7 @@ fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t,
|
fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t,
|
||||||
llfn: ValueRef, helper: glue_helper,
|
llfn: ValueRef, helper: glue_helper) -> ValueRef {
|
||||||
ty_params: [uint]) -> ValueRef {
|
|
||||||
let fcx = new_fn_ctxt(ccx, [], llfn, none);
|
let fcx = new_fn_ctxt(ccx, [], llfn, none);
|
||||||
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
|
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
|
||||||
ccx.stats.n_glues_created += 1u;
|
ccx.stats.n_glues_created += 1u;
|
||||||
|
@ -636,22 +632,6 @@ fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t,
|
||||||
T_ptr(type_of(ccx, t))
|
T_ptr(type_of(ccx, t))
|
||||||
} else { T_ptr(T_i8()) };
|
} else { T_ptr(T_i8()) };
|
||||||
|
|
||||||
let ty_param_count = ty_params.len();
|
|
||||||
let lltyparams = llvm::LLVMGetParam(llfn, 2u as c_uint);
|
|
||||||
let load_env_bcx = raw_block(fcx, fcx.llloadenv);
|
|
||||||
let lltydescs = [mutable];
|
|
||||||
let p = 0u;
|
|
||||||
while p < ty_param_count {
|
|
||||||
let llparam = GEPi(load_env_bcx, lltyparams, [p as int]);
|
|
||||||
llparam = Load(load_env_bcx, llparam);
|
|
||||||
vec::grow_set(lltydescs, ty_params[p], 0 as ValueRef, llparam);
|
|
||||||
p += 1u;
|
|
||||||
}
|
|
||||||
|
|
||||||
fcx.lltyparams = vec::map(vec::from_mut(lltydescs), {|d|
|
|
||||||
{desc: d, vtables: none}
|
|
||||||
});
|
|
||||||
|
|
||||||
let bcx = top_scope_block(fcx, none);
|
let bcx = top_scope_block(fcx, none);
|
||||||
let lltop = bcx.llbb;
|
let lltop = bcx.llbb;
|
||||||
let llrawptr0 = llvm::LLVMGetParam(llfn, 3u as c_uint);
|
let llrawptr0 = llvm::LLVMGetParam(llfn, 3u as c_uint);
|
||||||
|
@ -662,14 +642,14 @@ fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef,
|
fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef,
|
||||||
helper: glue_helper, ty_params: [uint], name: str)
|
helper: glue_helper, name: str)
|
||||||
-> ValueRef {
|
-> ValueRef {
|
||||||
if !ccx.sess.opts.stats {
|
if !ccx.sess.opts.stats {
|
||||||
ret make_generic_glue_inner(ccx, t, llfn, helper, ty_params);
|
ret make_generic_glue_inner(ccx, t, llfn, helper);
|
||||||
}
|
}
|
||||||
|
|
||||||
let start = time::get_time();
|
let start = time::get_time();
|
||||||
let llval = make_generic_glue_inner(ccx, t, llfn, helper, ty_params);
|
let llval = make_generic_glue_inner(ccx, t, llfn, helper);
|
||||||
let end = time::get_time();
|
let end = time::get_time();
|
||||||
log_fn_time(ccx, "glue " + name + " " + ty_to_short_str(ccx.tcx, t),
|
log_fn_time(ccx, "glue " + name + " " + ty_to_short_str(ccx.tcx, t),
|
||||||
start, end);
|
start, end);
|
||||||
|
@ -696,7 +676,7 @@ fn emit_tydescs(ccx: @crate_ctxt) {
|
||||||
some(v) { ccx.stats.n_real_glues += 1u; v }
|
some(v) { ccx.stats.n_real_glues += 1u; v }
|
||||||
};
|
};
|
||||||
|
|
||||||
let shape = shape_of(ccx, key, ti.ty_params);
|
let shape = shape_of(ccx, key, []);
|
||||||
let shape_tables =
|
let shape_tables =
|
||||||
llvm::LLVMConstPointerCast(ccx.shape_cx.llshapetables,
|
llvm::LLVMConstPointerCast(ccx.shape_cx.llshapetables,
|
||||||
T_ptr(T_i8()));
|
T_ptr(T_i8()));
|
||||||
|
@ -1155,8 +1135,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: int,
|
||||||
(ccx, ti.ty, T_glue_fn(ccx), "take");
|
(ccx, ti.ty, T_glue_fn(ccx), "take");
|
||||||
ti.take_glue = some(glue_fn);
|
ti.take_glue = some(glue_fn);
|
||||||
make_generic_glue(ccx, ti.ty, glue_fn,
|
make_generic_glue(ccx, ti.ty, glue_fn,
|
||||||
make_take_glue,
|
make_take_glue, "take");
|
||||||
ti.ty_params, "take");
|
|
||||||
#debug("--- lazily_emit_tydesc_glue TAKE %s",
|
#debug("--- lazily_emit_tydesc_glue TAKE %s",
|
||||||
ty_to_str(ccx.tcx, ti.ty));
|
ty_to_str(ccx.tcx, ti.ty));
|
||||||
}
|
}
|
||||||
|
@ -1171,8 +1150,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: int,
|
||||||
declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), "drop");
|
declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), "drop");
|
||||||
ti.drop_glue = some(glue_fn);
|
ti.drop_glue = some(glue_fn);
|
||||||
make_generic_glue(ccx, ti.ty, glue_fn,
|
make_generic_glue(ccx, ti.ty, glue_fn,
|
||||||
make_drop_glue,
|
make_drop_glue, "drop");
|
||||||
ti.ty_params, "drop");
|
|
||||||
#debug("--- lazily_emit_tydesc_glue DROP %s",
|
#debug("--- lazily_emit_tydesc_glue DROP %s",
|
||||||
ty_to_str(ccx.tcx, ti.ty));
|
ty_to_str(ccx.tcx, ti.ty));
|
||||||
}
|
}
|
||||||
|
@ -1187,8 +1165,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: int,
|
||||||
declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), "free");
|
declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), "free");
|
||||||
ti.free_glue = some(glue_fn);
|
ti.free_glue = some(glue_fn);
|
||||||
make_generic_glue(ccx, ti.ty, glue_fn,
|
make_generic_glue(ccx, ti.ty, glue_fn,
|
||||||
make_free_glue,
|
make_free_glue, "free");
|
||||||
ti.ty_params, "free");
|
|
||||||
#debug("--- lazily_emit_tydesc_glue FREE %s",
|
#debug("--- lazily_emit_tydesc_glue FREE %s",
|
||||||
ty_to_str(ccx.tcx, ti.ty));
|
ty_to_str(ccx.tcx, ti.ty));
|
||||||
}
|
}
|
||||||
|
@ -3853,7 +3830,6 @@ fn new_fn_ctxt_w_id(ccx: @crate_ctxt, path: path,
|
||||||
llargs: int_hash::<local_val>(),
|
llargs: int_hash::<local_val>(),
|
||||||
lllocals: int_hash::<local_val>(),
|
lllocals: int_hash::<local_val>(),
|
||||||
llupvars: int_hash::<ValueRef>(),
|
llupvars: int_hash::<ValueRef>(),
|
||||||
mutable lltyparams: [],
|
|
||||||
derived_tydescs: ty::new_ty_hash(),
|
derived_tydescs: ty::new_ty_hash(),
|
||||||
id: id,
|
id: id,
|
||||||
self_id: maybe_self_id,
|
self_id: maybe_self_id,
|
||||||
|
@ -3884,8 +3860,7 @@ fn new_fn_ctxt(ccx: @crate_ctxt, path: path, llfndecl: ValueRef,
|
||||||
// field of the fn_ctxt with
|
// field of the fn_ctxt with
|
||||||
fn create_llargs_for_fn_args(cx: fn_ctxt,
|
fn create_llargs_for_fn_args(cx: fn_ctxt,
|
||||||
ty_self: self_arg,
|
ty_self: self_arg,
|
||||||
args: [ast::arg],
|
args: [ast::arg]) {
|
||||||
tps_bounds: [ty::param_bounds]) {
|
|
||||||
// Skip the implicit arguments 0, and 1.
|
// Skip the implicit arguments 0, and 1.
|
||||||
let arg_n = first_real_arg;
|
let arg_n = first_real_arg;
|
||||||
alt ty_self {
|
alt ty_self {
|
||||||
|
@ -3894,25 +3869,6 @@ fn create_llargs_for_fn_args(cx: fn_ctxt,
|
||||||
}
|
}
|
||||||
no_self {}
|
no_self {}
|
||||||
}
|
}
|
||||||
for bounds in tps_bounds {
|
|
||||||
let lltydesc = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint);
|
|
||||||
let vtables = none;
|
|
||||||
arg_n += 1u;
|
|
||||||
for bound in *bounds {
|
|
||||||
alt bound {
|
|
||||||
ty::bound_iface(_) {
|
|
||||||
let vtable = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint);
|
|
||||||
arg_n += 1u;
|
|
||||||
vtables = some(alt vtables {
|
|
||||||
none { [vtable] }
|
|
||||||
some(ds) { ds + [vtable] }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_ {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cx.lltyparams += [{desc: lltydesc, vtables: vtables}];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Populate the llargs field of the function context with the ValueRefs
|
// Populate the llargs field of the function context with the ValueRefs
|
||||||
// that we get from llvm::LLVMGetParam for each argument.
|
// that we get from llvm::LLVMGetParam for each argument.
|
||||||
|
@ -3994,7 +3950,7 @@ fn trans_closure(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
|
||||||
// Set up arguments to the function.
|
// Set up arguments to the function.
|
||||||
let fcx = new_fn_ctxt_w_id(ccx, path, llfndecl, id, maybe_self_id,
|
let fcx = new_fn_ctxt_w_id(ccx, path, llfndecl, id, maybe_self_id,
|
||||||
param_substs, some(body.span));
|
param_substs, some(body.span));
|
||||||
create_llargs_for_fn_args(fcx, ty_self, decl.inputs, []);
|
create_llargs_for_fn_args(fcx, ty_self, decl.inputs);
|
||||||
|
|
||||||
// Create the first basic block in the function and keep a handle on it to
|
// Create the first basic block in the function and keep a handle on it to
|
||||||
// pass to finish_fn later.
|
// pass to finish_fn later.
|
||||||
|
@ -4061,7 +4017,7 @@ fn trans_res_ctor(ccx: @crate_ctxt, path: path, dtor: ast::fn_decl,
|
||||||
// Create a function for the constructor
|
// Create a function for the constructor
|
||||||
let fcx = new_fn_ctxt_w_id(ccx, path, llfndecl, ctor_id,
|
let fcx = new_fn_ctxt_w_id(ccx, path, llfndecl, ctor_id,
|
||||||
none, param_substs, none);
|
none, param_substs, none);
|
||||||
create_llargs_for_fn_args(fcx, no_self, dtor.inputs, []);
|
create_llargs_for_fn_args(fcx, no_self, dtor.inputs);
|
||||||
let bcx = top_scope_block(fcx, none), lltop = bcx.llbb;
|
let bcx = top_scope_block(fcx, none), lltop = bcx.llbb;
|
||||||
let fty = node_id_type(bcx, ctor_id);
|
let fty = node_id_type(bcx, ctor_id);
|
||||||
let arg_t = ty::ty_fn_args(fty)[0].ty;
|
let arg_t = ty::ty_fn_args(fty)[0].ty;
|
||||||
|
@ -4103,7 +4059,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id,
|
||||||
}
|
}
|
||||||
let fcx = new_fn_ctxt_w_id(ccx, [], llfndecl, variant.node.id, none,
|
let fcx = new_fn_ctxt_w_id(ccx, [], llfndecl, variant.node.id, none,
|
||||||
param_substs, none);
|
param_substs, none);
|
||||||
create_llargs_for_fn_args(fcx, no_self, fn_args, []);
|
create_llargs_for_fn_args(fcx, no_self, fn_args);
|
||||||
let ty_param_substs = alt param_substs {
|
let ty_param_substs = alt param_substs {
|
||||||
some(substs) { substs.tys }
|
some(substs) { substs.tys }
|
||||||
none { [] }
|
none { [] }
|
||||||
|
|
|
@ -35,8 +35,7 @@ type tydesc_info =
|
||||||
align: ValueRef,
|
align: ValueRef,
|
||||||
mutable take_glue: option<ValueRef>,
|
mutable take_glue: option<ValueRef>,
|
||||||
mutable drop_glue: option<ValueRef>,
|
mutable drop_glue: option<ValueRef>,
|
||||||
mutable free_glue: option<ValueRef>,
|
mutable free_glue: option<ValueRef>};
|
||||||
ty_params: [uint]};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A note on nomenclature of linking: "upcall", "extern" and "native".
|
* A note on nomenclature of linking: "upcall", "extern" and "native".
|
||||||
|
@ -122,8 +121,6 @@ type val_self_pair = {v: ValueRef, t: ty::t};
|
||||||
|
|
||||||
enum local_val { local_mem(ValueRef), local_imm(ValueRef), }
|
enum local_val { local_mem(ValueRef), local_imm(ValueRef), }
|
||||||
|
|
||||||
type fn_ty_param = {desc: ValueRef, vtables: option<[ValueRef]>};
|
|
||||||
|
|
||||||
type param_substs = {tys: [ty::t],
|
type param_substs = {tys: [ty::t],
|
||||||
vtables: option<typeck::vtable_res>,
|
vtables: option<typeck::vtable_res>,
|
||||||
bounds: @[ty::param_bounds]};
|
bounds: @[ty::param_bounds]};
|
||||||
|
@ -179,10 +176,6 @@ type fn_ctxt = @{
|
||||||
// Same as above, but for closure upvars
|
// Same as above, but for closure upvars
|
||||||
llupvars: hashmap<ast::node_id, ValueRef>,
|
llupvars: hashmap<ast::node_id, ValueRef>,
|
||||||
|
|
||||||
// A vector of incoming type descriptors and their associated vtables.
|
|
||||||
// Currently only used by glue functions
|
|
||||||
mutable lltyparams: [fn_ty_param],
|
|
||||||
|
|
||||||
// Derived tydescs are tydescs created at runtime, for types that
|
// Derived tydescs are tydescs created at runtime, for types that
|
||||||
// involve type parameters inside type constructors. For example,
|
// involve type parameters inside type constructors. For example,
|
||||||
// suppose a function parameterized by T creates a vector of type
|
// suppose a function parameterized by T creates a vector of type
|
||||||
|
|
Loading…
Reference in a new issue