@@ -21,11 +21,14 @@ use crate::{
2121 RegClass , VReg ,
2222} ;
2323use fxhash:: FxHashSet ;
24+ use arena_btree:: BTreeMap ;
2425use smallvec:: SmallVec ;
2526use std:: cmp:: Ordering ;
26- use std:: collections:: { BTreeMap , HashMap , HashSet } ;
27+ use std:: collections:: { HashMap , HashSet } ;
2728use std:: fmt:: Debug ;
2829
30+ pub use arena_btree:: Arena ;
31+
2932/// A range from `from` (inclusive) to `to` (exclusive).
3033#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
3134pub struct CodeRange {
@@ -288,8 +291,8 @@ pub struct VRegData {
288291}
289292
290293#[ derive( Clone , Debug ) ]
291- pub struct PRegData {
292- pub allocations : LiveRangeSet ,
294+ pub struct PRegData < ' arena > {
295+ pub allocations : LiveRangeSet < ' arena > ,
293296 pub is_stack : bool ,
294297}
295298
@@ -362,8 +365,9 @@ impl BlockparamIn {
362365 }
363366}
364367
365- #[ derive( Clone , Debug ) ]
366- pub struct Env < ' a , F : Function > {
368+ pub struct Env < ' a , ' arena , F : Function > {
369+ pub arena : & ' arena Arena < LiveRangeKey , LiveRangeIndex > ,
370+
367371 pub func : & ' a F ,
368372 pub env : & ' a MachineEnv ,
369373 pub cfginfo : CFGInfo ,
@@ -376,13 +380,13 @@ pub struct Env<'a, F: Function> {
376380 pub bundles : Vec < LiveBundle > ,
377381 pub spillsets : Vec < SpillSet > ,
378382 pub vregs : Vec < VRegData > ,
379- pub pregs : Vec < PRegData > ,
383+ pub pregs : Vec < PRegData < ' arena > > ,
380384 pub allocation_queue : PrioQueue ,
381385 pub safepoints : Vec < Inst > , // Sorted list of safepoint insts.
382386 pub safepoints_per_vreg : HashMap < usize , HashSet < Inst > > ,
383387
384388 pub spilled_bundles : Vec < LiveBundleIndex > ,
385- pub spillslots : Vec < SpillSlotData > ,
389+ pub spillslots : Vec < SpillSlotData < ' arena > > ,
386390 pub slots_by_size : Vec < SpillSlotList > ,
387391
388392 pub extra_spillslots_by_class : [ SmallVec < [ Allocation ; 2 ] > ; 2 ] ,
@@ -437,7 +441,7 @@ pub struct Env<'a, F: Function> {
437441 pub conflict_set : FxHashSet < LiveBundleIndex > ,
438442}
439443
440- impl < ' a , F : Function > Env < ' a , F > {
444+ impl < ' a , ' arena , F : Function > Env < ' a , ' arena , F > {
441445 /// Get the VReg (with bundled RegClass) from a vreg index.
442446 #[ inline]
443447 pub fn vreg ( & self , index : VRegIndex ) -> VReg {
@@ -463,8 +467,8 @@ impl<'a, F: Function> Env<'a, F> {
463467}
464468
465469#[ derive( Clone , Debug ) ]
466- pub struct SpillSlotData {
467- pub ranges : LiveRangeSet ,
470+ pub struct SpillSlotData < ' arena > {
471+ pub ranges : LiveRangeSet < ' arena > ,
468472 pub slots : u32 ,
469473 pub alloc : Allocation ,
470474}
@@ -501,8 +505,8 @@ pub struct PrioQueueEntry {
501505}
502506
503507#[ derive( Clone , Debug ) ]
504- pub struct LiveRangeSet {
505- pub btree : BTreeMap < LiveRangeKey , LiveRangeIndex > ,
508+ pub struct LiveRangeSet < ' arena > {
509+ pub btree : BTreeMap < ' arena , LiveRangeKey , LiveRangeIndex > ,
506510}
507511
508512#[ derive( Clone , Copy , Debug ) ]
@@ -592,10 +596,10 @@ impl PrioQueue {
592596 }
593597}
594598
595- impl LiveRangeSet {
596- pub ( crate ) fn new ( ) -> Self {
599+ impl < ' arena > LiveRangeSet < ' arena > {
600+ pub ( crate ) fn new ( arena : & ' arena Arena < LiveRangeKey , LiveRangeIndex > ) -> Self {
597601 Self {
598- btree : BTreeMap :: new ( ) ,
602+ btree : BTreeMap :: new ( arena ) ,
599603 }
600604 }
601605}
0 commit comments