@@ -26,20 +26,20 @@ pub use self::error::{
26
26
27
27
pub use self :: value:: { Scalar , ConstValue } ;
28
28
29
- pub use self :: allocation:: { Allocation , MemoryAccess } ;
29
+ pub use self :: allocation:: {
30
+ Allocation , AllocationExtra ,
31
+ Relocations , UndefMask ,
32
+ } ;
30
33
31
34
use std:: fmt;
32
35
use mir;
33
36
use hir:: def_id:: DefId ;
34
37
use ty:: { self , TyCtxt , Instance } ;
35
38
use ty:: layout:: { self , HasDataLayout , Size } ;
36
39
use middle:: region;
37
- use std:: iter;
38
40
use std:: io;
39
- use std:: ops:: { Deref , DerefMut } ;
40
41
use std:: hash:: Hash ;
41
42
use rustc_serialize:: { Encoder , Decodable , Encodable } ;
42
- use rustc_data_structures:: sorted_map:: SortedMap ;
43
43
use rustc_data_structures:: fx:: FxHashMap ;
44
44
use rustc_data_structures:: sync:: { Lock as Mutex , HashMapExt } ;
45
45
use rustc_data_structures:: tiny_list:: TinyList ;
@@ -530,35 +530,6 @@ impl<'tcx, M: fmt::Debug + Eq + Hash + Clone> AllocMap<'tcx, M> {
530
530
}
531
531
}
532
532
533
- #[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug , RustcEncodable , RustcDecodable ) ]
534
- pub struct Relocations < Tag =( ) , Id =AllocId > ( SortedMap < Size , ( Tag , Id ) > ) ;
535
-
536
- impl < Tag , Id > Relocations < Tag , Id > {
537
- pub fn new ( ) -> Self {
538
- Relocations ( SortedMap :: new ( ) )
539
- }
540
-
541
- // The caller must guarantee that the given relocations are already sorted
542
- // by address and contain no duplicates.
543
- pub fn from_presorted ( r : Vec < ( Size , ( Tag , Id ) ) > ) -> Self {
544
- Relocations ( SortedMap :: from_presorted_elements ( r) )
545
- }
546
- }
547
-
548
- impl < Tag > Deref for Relocations < Tag > {
549
- type Target = SortedMap < Size , ( Tag , AllocId ) > ;
550
-
551
- fn deref ( & self ) -> & Self :: Target {
552
- & self . 0
553
- }
554
- }
555
-
556
- impl < Tag > DerefMut for Relocations < Tag > {
557
- fn deref_mut ( & mut self ) -> & mut Self :: Target {
558
- & mut self . 0
559
- }
560
- }
561
-
562
533
////////////////////////////////////////////////////////////////////////////////
563
534
// Methods to access integers in the target endianness
564
535
////////////////////////////////////////////////////////////////////////////////
@@ -602,106 +573,6 @@ pub fn truncate(value: u128, size: Size) -> u128 {
602
573
( value << shift) >> shift
603
574
}
604
575
605
- ////////////////////////////////////////////////////////////////////////////////
606
- // Undefined byte tracking
607
- ////////////////////////////////////////////////////////////////////////////////
608
-
609
- type Block = u64 ;
610
- const BLOCK_SIZE : u64 = 64 ;
611
-
612
- #[ derive( Clone , Debug , Eq , PartialEq , PartialOrd , Ord , Hash , RustcEncodable , RustcDecodable ) ]
613
- pub struct UndefMask {
614
- blocks : Vec < Block > ,
615
- len : Size ,
616
- }
617
-
618
- impl_stable_hash_for ! ( struct mir:: interpret:: UndefMask { blocks, len} ) ;
619
-
620
- impl UndefMask {
621
- pub fn new ( size : Size ) -> Self {
622
- let mut m = UndefMask {
623
- blocks : vec ! [ ] ,
624
- len : Size :: ZERO ,
625
- } ;
626
- m. grow ( size, false ) ;
627
- m
628
- }
629
-
630
- /// Check whether the range `start..end` (end-exclusive) is entirely defined.
631
- ///
632
- /// Returns `Ok(())` if it's defined. Otherwise returns the index of the byte
633
- /// at which the first undefined access begins.
634
- #[ inline]
635
- pub fn is_range_defined ( & self , start : Size , end : Size ) -> Result < ( ) , Size > {
636
- if end > self . len {
637
- return Err ( self . len ) ;
638
- }
639
-
640
- let idx = ( start. bytes ( ) ..end. bytes ( ) )
641
- . map ( |i| Size :: from_bytes ( i) )
642
- . find ( |& i| !self . get ( i) ) ;
643
-
644
- match idx {
645
- Some ( idx) => Err ( idx) ,
646
- None => Ok ( ( ) )
647
- }
648
- }
649
-
650
- pub fn set_range ( & mut self , start : Size , end : Size , new_state : bool ) {
651
- let len = self . len ;
652
- if end > len {
653
- self . grow ( end - len, new_state) ;
654
- }
655
- self . set_range_inbounds ( start, end, new_state) ;
656
- }
657
-
658
- pub fn set_range_inbounds ( & mut self , start : Size , end : Size , new_state : bool ) {
659
- for i in start. bytes ( ) ..end. bytes ( ) {
660
- self . set ( Size :: from_bytes ( i) , new_state) ;
661
- }
662
- }
663
-
664
- #[ inline]
665
- pub fn get ( & self , i : Size ) -> bool {
666
- let ( block, bit) = bit_index ( i) ;
667
- ( self . blocks [ block] & 1 << bit) != 0
668
- }
669
-
670
- #[ inline]
671
- pub fn set ( & mut self , i : Size , new_state : bool ) {
672
- let ( block, bit) = bit_index ( i) ;
673
- if new_state {
674
- self . blocks [ block] |= 1 << bit;
675
- } else {
676
- self . blocks [ block] &= !( 1 << bit) ;
677
- }
678
- }
679
-
680
- pub fn grow ( & mut self , amount : Size , new_state : bool ) {
681
- let unused_trailing_bits = self . blocks . len ( ) as u64 * BLOCK_SIZE - self . len . bytes ( ) ;
682
- if amount. bytes ( ) > unused_trailing_bits {
683
- let additional_blocks = amount. bytes ( ) / BLOCK_SIZE + 1 ;
684
- assert_eq ! ( additional_blocks as usize as u64 , additional_blocks) ;
685
- self . blocks . extend (
686
- iter:: repeat ( 0 ) . take ( additional_blocks as usize ) ,
687
- ) ;
688
- }
689
- let start = self . len ;
690
- self . len += amount;
691
- self . set_range_inbounds ( start, start + amount, new_state) ;
692
- }
693
- }
694
-
695
- #[ inline]
696
- fn bit_index ( bits : Size ) -> ( usize , usize ) {
697
- let bits = bits. bytes ( ) ;
698
- let a = bits / BLOCK_SIZE ;
699
- let b = bits % BLOCK_SIZE ;
700
- assert_eq ! ( a as usize as u64 , a) ;
701
- assert_eq ! ( b as usize as u64 , b) ;
702
- ( a as usize , b as usize )
703
- }
704
-
705
576
#[ derive( Clone , Copy , Debug , Eq , PartialEq , Ord , PartialOrd , RustcEncodable , RustcDecodable , Hash ) ]
706
577
pub enum ScalarMaybeUndef < Tag =( ) , Id =AllocId > {
707
578
Scalar ( Scalar < Tag , Id > ) ,
0 commit comments