Skip to content

Commit 5e637a8

Browse files
committed
librustc: Move block contexts into per-function arenas, and
stack-allocate function contexts.
1 parent b7ff9c1 commit 5e637a8

File tree

20 files changed

+1128
-745
lines changed

20 files changed

+1128
-745
lines changed

src/librustc/middle/trans/_match.rs

Lines changed: 205 additions & 171 deletions
Large diffs are not rendered by default.

src/librustc/middle/trans/adt.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub struct Struct {
111111
* these, for places in trans where the `ty::t` isn't directly
112112
* available.
113113
*/
114-
pub fn represent_node(bcx: @Block, node: ast::NodeId) -> @Repr {
114+
pub fn represent_node(bcx: &Block, node: ast::NodeId) -> @Repr {
115115
represent_type(bcx.ccx(), node_id_type(bcx, node))
116116
}
117117

@@ -463,7 +463,7 @@ fn struct_llfields(cx: &CrateContext, st: &Struct, sizing: bool) -> ~[Type] {
463463
*
464464
* This should ideally be less tightly tied to `_match`.
465465
*/
466-
pub fn trans_switch(bcx: @Block, r: &Repr, scrutinee: ValueRef)
466+
pub fn trans_switch(bcx: &Block, r: &Repr, scrutinee: ValueRef)
467467
-> (_match::branch_kind, Option<ValueRef>) {
468468
match *r {
469469
CEnum(..) | General(..) => {
@@ -481,7 +481,7 @@ pub fn trans_switch(bcx: @Block, r: &Repr, scrutinee: ValueRef)
481481

482482

483483
/// Obtain the actual discriminant of a value.
484-
pub fn trans_get_discr(bcx: @Block, r: &Repr, scrutinee: ValueRef, cast_to: Option<Type>)
484+
pub fn trans_get_discr(bcx: &Block, r: &Repr, scrutinee: ValueRef, cast_to: Option<Type>)
485485
-> ValueRef {
486486
let signed;
487487
let val;
@@ -510,7 +510,7 @@ pub fn trans_get_discr(bcx: @Block, r: &Repr, scrutinee: ValueRef, cast_to: Opti
510510
}
511511
}
512512

513-
fn nullable_bitdiscr(bcx: @Block, nonnull: &Struct, nndiscr: Disr, ptrfield: uint,
513+
fn nullable_bitdiscr(bcx: &Block, nonnull: &Struct, nndiscr: Disr, ptrfield: uint,
514514
scrutinee: ValueRef) -> ValueRef {
515515
let cmp = if nndiscr == 0 { IntEQ } else { IntNE };
516516
let llptr = Load(bcx, GEPi(bcx, scrutinee, [0, ptrfield]));
@@ -519,7 +519,7 @@ fn nullable_bitdiscr(bcx: @Block, nonnull: &Struct, nndiscr: Disr, ptrfield: uin
519519
}
520520

521521
/// Helper for cases where the discriminant is simply loaded.
522-
fn load_discr(bcx: @Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
522+
fn load_discr(bcx: &Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
523523
-> ValueRef {
524524
let llty = ll_inttype(bcx.ccx(), ity);
525525
assert_eq!(val_ty(ptr), llty.ptr_to());
@@ -547,7 +547,8 @@ fn load_discr(bcx: @Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
547547
*
548548
* This should ideally be less tightly tied to `_match`.
549549
*/
550-
pub fn trans_case(bcx: @Block, r: &Repr, discr: Disr) -> _match::opt_result {
550+
pub fn trans_case<'a>(bcx: &'a Block<'a>, r: &Repr, discr: Disr)
551+
-> _match::opt_result<'a> {
551552
match *r {
552553
CEnum(ity, _, _) => {
553554
_match::single_result(rslt(bcx, C_integral(ll_inttype(bcx.ccx(), ity),
@@ -572,7 +573,7 @@ pub fn trans_case(bcx: @Block, r: &Repr, discr: Disr) -> _match::opt_result {
572573
* representation. The fields, if any, should then be initialized via
573574
* `trans_field_ptr`.
574575
*/
575-
pub fn trans_start_init(bcx: @Block, r: &Repr, val: ValueRef, discr: Disr) {
576+
pub fn trans_start_init(bcx: &Block, r: &Repr, val: ValueRef, discr: Disr) {
576577
match *r {
577578
CEnum(ity, min, max) => {
578579
assert_discr_in_range(ity, min, max, discr);
@@ -628,7 +629,7 @@ pub fn num_args(r: &Repr, discr: Disr) -> uint {
628629
}
629630

630631
/// Access a field, at a point when the value's case is known.
631-
pub fn trans_field_ptr(bcx: @Block, r: &Repr, val: ValueRef, discr: Disr,
632+
pub fn trans_field_ptr(bcx: &Block, r: &Repr, val: ValueRef, discr: Disr,
632633
ix: uint) -> ValueRef {
633634
// Note: if this ever needs to generate conditionals (e.g., if we
634635
// decide to do some kind of cdr-coding-like non-unique repr
@@ -661,7 +662,7 @@ pub fn trans_field_ptr(bcx: @Block, r: &Repr, val: ValueRef, discr: Disr,
661662
}
662663
}
663664

664-
fn struct_field_ptr(bcx: @Block, st: &Struct, val: ValueRef, ix: uint,
665+
fn struct_field_ptr(bcx: &Block, st: &Struct, val: ValueRef, ix: uint,
665666
needs_cast: bool) -> ValueRef {
666667
let ccx = bcx.ccx();
667668

@@ -677,7 +678,7 @@ fn struct_field_ptr(bcx: @Block, st: &Struct, val: ValueRef, ix: uint,
677678
}
678679

679680
/// Access the struct drop flag, if present.
680-
pub fn trans_drop_flag_ptr(bcx: @Block, r: &Repr, val: ValueRef) -> ValueRef {
681+
pub fn trans_drop_flag_ptr(bcx: &Block, r: &Repr, val: ValueRef) -> ValueRef {
681682
match *r {
682683
Univariant(ref st, true) => GEPi(bcx, val, [0, st.fields.len() - 1]),
683684
_ => bcx.ccx().sess.bug("tried to get drop flag of non-droppable type")

src/librustc/middle/trans/asm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ use middle::trans::type_::Type;
2727
use syntax::ast;
2828

2929
// Take an inline assembly expression and splat it out via LLVM
30-
pub fn trans_inline_asm(bcx: @Block, ia: &ast::inline_asm) -> @Block {
31-
30+
pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::inline_asm)
31+
-> &'a Block<'a> {
3232
let mut bcx = bcx;
3333
let mut constraints = ~[];
3434
let mut cleanups = ~[];

0 commit comments

Comments
 (0)