librustc: Convert some large structural records over to structs. rs=perf
No effect on compile-time performance.
This commit is contained in:
parent
fa96740923
commit
96e01a67c7
9 changed files with 81 additions and 54 deletions
|
@ -1086,8 +1086,13 @@ fn new_block(cx: fn_ctxt, parent: Option<block>, +kind: block_kind,
|
|||
}
|
||||
|
||||
fn simple_block_scope() -> block_kind {
|
||||
block_scope({loop_break: None, loop_label: None, mut cleanups: ~[],
|
||||
mut cleanup_paths: ~[], mut landing_pad: None})
|
||||
block_scope(scope_info {
|
||||
loop_break: None,
|
||||
loop_label: None,
|
||||
mut cleanups: ~[],
|
||||
mut cleanup_paths: ~[],
|
||||
mut landing_pad: None
|
||||
})
|
||||
}
|
||||
|
||||
// Use this when you're at the top block of a function or the like.
|
||||
|
@ -1105,7 +1110,7 @@ fn scope_block(bcx: block,
|
|||
|
||||
fn loop_scope_block(bcx: block, loop_break: block, loop_label: Option<ident>,
|
||||
n: ~str, opt_node_info: Option<node_info>) -> block {
|
||||
return new_block(bcx.fcx, Some(bcx), block_scope({
|
||||
return new_block(bcx.fcx, Some(bcx), block_scope(scope_info {
|
||||
loop_break: Some(loop_break),
|
||||
loop_label: loop_label,
|
||||
mut cleanups: ~[],
|
||||
|
@ -1436,7 +1441,8 @@ fn new_fn_ctxt_w_id(ccx: @crate_ctxt,
|
|||
param_substs: Option<param_substs>,
|
||||
sp: Option<span>) -> fn_ctxt {
|
||||
let llbbs = mk_standard_basic_blocks(llfndecl);
|
||||
return @{llfn: llfndecl,
|
||||
return @fn_ctxt_ {
|
||||
llfn: llfndecl,
|
||||
llenv: llvm::LLVMGetParam(llfndecl, 1u as c_uint),
|
||||
llretptr: llvm::LLVMGetParam(llfndecl, 0u as c_uint),
|
||||
mut llstaticallocas: llbbs.sa,
|
||||
|
@ -1453,7 +1459,8 @@ fn new_fn_ctxt_w_id(ccx: @crate_ctxt,
|
|||
param_substs: param_substs,
|
||||
span: sp,
|
||||
path: path,
|
||||
ccx: ccx};
|
||||
ccx: ccx
|
||||
};
|
||||
}
|
||||
|
||||
fn new_fn_ctxt(ccx: @crate_ctxt, path: path, llfndecl: ValueRef,
|
||||
|
@ -2814,8 +2821,8 @@ fn trans_crate(sess: session::Session,
|
|||
option::None
|
||||
};
|
||||
|
||||
let ccx =
|
||||
@{sess: sess,
|
||||
let ccx = @crate_ctxt {
|
||||
sess: sess,
|
||||
llmod: llmod,
|
||||
td: td,
|
||||
tn: tn,
|
||||
|
@ -2875,8 +2882,8 @@ fn trans_crate(sess: session::Session,
|
|||
crate_map: crate_map,
|
||||
mut uses_gc: false,
|
||||
dbg_cx: dbg_cx,
|
||||
mut do_not_commit_warning_issued: false};
|
||||
|
||||
mut do_not_commit_warning_issued: false
|
||||
};
|
||||
|
||||
gather_rtcalls(ccx, crate);
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ fn BuilderRef_res(B: BuilderRef) -> BuilderRef_res {
|
|||
}
|
||||
|
||||
// Crate context. Every crate we compile has one of these.
|
||||
type crate_ctxt = {
|
||||
struct crate_ctxt {
|
||||
sess: session::Session,
|
||||
llmod: ModuleRef,
|
||||
td: target_data,
|
||||
|
@ -211,7 +211,8 @@ type crate_ctxt = {
|
|||
// is not emitted by LLVM's GC pass when no functions use GC.
|
||||
mut uses_gc: bool,
|
||||
dbg_cx: Option<debuginfo::debug_ctxt>,
|
||||
mut do_not_commit_warning_issued: bool};
|
||||
mut do_not_commit_warning_issued: bool
|
||||
}
|
||||
|
||||
// Types used for llself.
|
||||
struct ValSelfData {
|
||||
|
@ -224,10 +225,12 @@ enum local_val { local_mem(ValueRef), local_imm(ValueRef), }
|
|||
|
||||
// Here `self_ty` is the real type of the self parameter to this method. It
|
||||
// will only be set in the case of default methods.
|
||||
type param_substs = {tys: ~[ty::t],
|
||||
vtables: Option<typeck::vtable_res>,
|
||||
bounds: @~[ty::param_bounds],
|
||||
self_ty: Option<ty::t>};
|
||||
struct param_substs {
|
||||
tys: ~[ty::t],
|
||||
vtables: Option<typeck::vtable_res>,
|
||||
bounds: @~[ty::param_bounds],
|
||||
self_ty: Option<ty::t>
|
||||
}
|
||||
|
||||
fn param_substs_to_str(tcx: ty::ctxt, substs: ¶m_substs) -> ~str {
|
||||
fmt!("param_substs {tys:%?, vtables:%?, bounds:%?}",
|
||||
|
@ -238,7 +241,7 @@ fn param_substs_to_str(tcx: ty::ctxt, substs: ¶m_substs) -> ~str {
|
|||
|
||||
// Function context. Every LLVM function we create will have one of
|
||||
// these.
|
||||
type fn_ctxt = @{
|
||||
struct fn_ctxt_ {
|
||||
// The ValueRef returned from a call to llvm::LLVMAddFunction; the
|
||||
// address of the first instruction in the sequence of
|
||||
// instructions for this function that will go in the .text
|
||||
|
@ -302,7 +305,9 @@ type fn_ctxt = @{
|
|||
|
||||
// This function's enclosing crate context.
|
||||
ccx: @crate_ctxt
|
||||
};
|
||||
}
|
||||
|
||||
pub type fn_ctxt = @fn_ctxt_;
|
||||
|
||||
fn warn_not_to_commit(ccx: @crate_ctxt, msg: ~str) {
|
||||
if !ccx.do_not_commit_warning_issued {
|
||||
|
@ -484,7 +489,7 @@ enum block_kind {
|
|||
block_non_scope,
|
||||
}
|
||||
|
||||
type scope_info = {
|
||||
struct scope_info {
|
||||
loop_break: Option<block>,
|
||||
loop_label: Option<ident>,
|
||||
// A list of functions that must be run at when leaving this
|
||||
|
@ -496,7 +501,7 @@ type scope_info = {
|
|||
mut cleanup_paths: ~[cleanup_path],
|
||||
// Unwinding landing pad. Also cleared when cleanups change.
|
||||
mut landing_pad: Option<BasicBlockRef>,
|
||||
};
|
||||
}
|
||||
|
||||
trait get_node_info {
|
||||
fn info() -> Option<node_info>;
|
||||
|
@ -1171,11 +1176,11 @@ enum mono_param_id {
|
|||
datum::DatumMode),
|
||||
}
|
||||
|
||||
type mono_id_ = {
|
||||
struct mono_id_ {
|
||||
def: ast::def_id,
|
||||
params: ~[mono_param_id],
|
||||
impl_did_opt: Option<ast::def_id>
|
||||
};
|
||||
}
|
||||
|
||||
type mono_id = @mono_id_;
|
||||
|
||||
|
|
|
@ -224,7 +224,11 @@ fn trans_break_cont(bcx: block, opt_label: Option<ident>, to_end: bool)
|
|||
let mut target;
|
||||
loop {
|
||||
match unwind.kind {
|
||||
block_scope({loop_break: Some(brk), loop_label: l, _}) => {
|
||||
block_scope(scope_info {
|
||||
loop_break: Some(brk),
|
||||
loop_label: l,
|
||||
_
|
||||
}) => {
|
||||
// If we're looking for a labeled loop, check the label...
|
||||
target = if to_end {
|
||||
brk
|
||||
|
|
|
@ -59,7 +59,7 @@ fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident,
|
|||
match self_ty {
|
||||
None => param_substs_opt = None,
|
||||
Some(self_ty) => {
|
||||
param_substs_opt = Some({
|
||||
param_substs_opt = Some(param_substs {
|
||||
tys: ~[],
|
||||
vtables: None,
|
||||
bounds: @~[],
|
||||
|
@ -112,7 +112,7 @@ fn trans_method(ccx: @crate_ctxt,
|
|||
}
|
||||
let self_ty = match param_substs {
|
||||
None => self_ty,
|
||||
Some({tys: ref tys, _}) => {
|
||||
Some(param_substs {tys: ref tys, _}) => {
|
||||
ty::subst_tps(ccx.tcx, *tys, None, self_ty)
|
||||
}
|
||||
};
|
||||
|
@ -722,9 +722,11 @@ fn vtable_id(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> mono_id {
|
|||
None)
|
||||
}
|
||||
typeck::vtable_trait(trait_id, substs) => {
|
||||
@{def: trait_id,
|
||||
params: vec::map(substs, |t| mono_precise(*t, None)),
|
||||
impl_did_opt: None}
|
||||
@mono_id_ {
|
||||
def: trait_id,
|
||||
params: vec::map(substs, |t| mono_precise(*t, None)),
|
||||
impl_did_opt: None
|
||||
}
|
||||
}
|
||||
// can't this be checked at the callee?
|
||||
_ => fail ~"vtable_id"
|
||||
|
|
|
@ -156,7 +156,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
|
|||
lldecl
|
||||
};
|
||||
|
||||
let psubsts = Some({
|
||||
let psubsts = Some(param_substs {
|
||||
tys: substs,
|
||||
vtables: vtables,
|
||||
bounds: tpt.bounds,
|
||||
|
@ -381,5 +381,5 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
|
|||
})
|
||||
}
|
||||
};
|
||||
@{def: item, params: param_ids, impl_did_opt: impl_did_opt}
|
||||
@mono_id_ {def: item, params: param_ids, impl_did_opt: impl_did_opt}
|
||||
}
|
||||
|
|
|
@ -32,16 +32,22 @@ export map, find_reachable;
|
|||
|
||||
type map = HashMap<node_id, ()>;
|
||||
|
||||
type ctx = {exp_map2: resolve::ExportMap2,
|
||||
tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
rmap: map};
|
||||
struct ctx {
|
||||
exp_map2: resolve::ExportMap2,
|
||||
tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
rmap: map
|
||||
}
|
||||
|
||||
fn find_reachable(crate_mod: _mod, exp_map2: resolve::ExportMap2,
|
||||
tcx: ty::ctxt, method_map: typeck::method_map) -> map {
|
||||
let rmap = HashMap();
|
||||
let cx = {exp_map2: exp_map2, tcx: tcx,
|
||||
method_map: method_map, rmap: rmap};
|
||||
let cx = ctx {
|
||||
exp_map2: exp_map2,
|
||||
tcx: tcx,
|
||||
method_map: method_map,
|
||||
rmap: rmap
|
||||
};
|
||||
traverse_public_mod(cx, ast::crate_node_id, crate_mod);
|
||||
traverse_all_resources_and_impls(cx, crate_mod);
|
||||
rmap
|
||||
|
|
|
@ -33,7 +33,7 @@ fn check_alt(fcx: @fn_ctxt,
|
|||
// Typecheck the patterns first, so that we get types for all the
|
||||
// bindings.
|
||||
for arms.each |arm| {
|
||||
let pcx = {
|
||||
let pcx = pat_ctxt {
|
||||
fcx: fcx,
|
||||
map: pat_id_map(tcx.def_map, arm.pats[0]),
|
||||
alt_region: ty::re_scope(expr.id),
|
||||
|
@ -61,12 +61,12 @@ fn check_alt(fcx: @fn_ctxt,
|
|||
return bot;
|
||||
}
|
||||
|
||||
type pat_ctxt = {
|
||||
struct pat_ctxt {
|
||||
fcx: @fn_ctxt,
|
||||
map: PatIdMap,
|
||||
alt_region: ty::Region, // Region for the alt as a whole
|
||||
block_region: ty::Region, // Region for the block of the arm
|
||||
};
|
||||
}
|
||||
|
||||
fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
|
||||
subpats: Option<~[@ast::pat]>, expected: ty::t) {
|
||||
|
|
|
@ -84,6 +84,7 @@ use middle::ty;
|
|||
use middle::typeck::astconv::{ast_conv, ast_path_to_ty};
|
||||
use middle::typeck::astconv::{ast_region_to_region, ast_ty_to_ty};
|
||||
use middle::typeck::astconv;
|
||||
use middle::typeck::check::alt::pat_ctxt;
|
||||
use middle::typeck::check::method::TransformTypeNormally;
|
||||
use middle::typeck::check::regionmanip::replace_bound_regions_in_fn_ty;
|
||||
use middle::typeck::check::vtable::{LocationInfo, VtableContext};
|
||||
|
@ -421,7 +422,7 @@ fn check_fn(ccx: @crate_ctxt,
|
|||
|
||||
// Check the pattern.
|
||||
let region = fcx.block_region();
|
||||
let pcx = {
|
||||
let pcx = pat_ctxt {
|
||||
fcx: fcx,
|
||||
map: pat_id_map(tcx.def_map, input.pat),
|
||||
alt_region: region,
|
||||
|
@ -2485,7 +2486,7 @@ fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool {
|
|||
|
||||
let region =
|
||||
ty::re_scope(tcx.region_map.get(local.node.id));
|
||||
let pcx = {
|
||||
let pcx = pat_ctxt {
|
||||
fcx: fcx,
|
||||
map: pat_id_map(tcx.def_map, local.node.pat),
|
||||
alt_region: region,
|
||||
|
|
|
@ -216,16 +216,17 @@ impl vtable_origin {
|
|||
|
||||
type vtable_map = HashMap<ast::node_id, vtable_res>;
|
||||
|
||||
type crate_ctxt_ = {// A mapping from method call sites to traits that have
|
||||
// that method.
|
||||
trait_map: resolve::TraitMap,
|
||||
method_map: method_map,
|
||||
vtable_map: vtable_map,
|
||||
coherence_info: @coherence::CoherenceInfo,
|
||||
tcx: ty::ctxt};
|
||||
struct crate_ctxt__ {
|
||||
// A mapping from method call sites to traits that have that method.
|
||||
trait_map: resolve::TraitMap,
|
||||
method_map: method_map,
|
||||
vtable_map: vtable_map,
|
||||
coherence_info: @coherence::CoherenceInfo,
|
||||
tcx: ty::ctxt
|
||||
}
|
||||
|
||||
enum crate_ctxt {
|
||||
crate_ctxt_(crate_ctxt_)
|
||||
crate_ctxt_(crate_ctxt__)
|
||||
}
|
||||
|
||||
// Functions that write types into the node type table
|
||||
|
@ -392,12 +393,13 @@ fn check_crate(tcx: ty::ctxt,
|
|||
crate: @ast::crate)
|
||||
-> (method_map, vtable_map) {
|
||||
|
||||
let ccx = @crate_ctxt_({trait_map: trait_map,
|
||||
method_map: map::HashMap(),
|
||||
vtable_map: map::HashMap(),
|
||||
coherence_info: @coherence::CoherenceInfo(),
|
||||
tcx: tcx
|
||||
});
|
||||
let ccx = @crate_ctxt_(crate_ctxt__ {
|
||||
trait_map: trait_map,
|
||||
method_map: map::HashMap(),
|
||||
vtable_map: map::HashMap(),
|
||||
coherence_info: @coherence::CoherenceInfo(),
|
||||
tcx: tcx
|
||||
});
|
||||
collect::collect_item_types(ccx, crate);
|
||||
coherence::check_coherence(ccx, crate);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue