@@ -10,7 +10,7 @@ use rustc_data_structures::sorted_map::SortedMap;
10
10
use rustc_target:: abi:: { Align , HasDataLayout , Size } ;
11
11
12
12
use super :: {
13
- read_target_uint, write_target_uint, AllocId , InterpResult , Pointer , Scalar , ScalarMaybeUndef ,
13
+ read_target_uint, write_target_uint, AllocId , InterpResult , Pointer , Scalar , ScalarMaybeUninit ,
14
14
} ;
15
15
16
16
// NOTE: When adding new fields, make sure to adjust the `Snapshot` impl in
@@ -27,7 +27,7 @@ pub struct Allocation<Tag = (), Extra = ()> {
27
27
/// at the given offset.
28
28
relocations : Relocations < Tag > ,
29
29
/// Denotes which part of this allocation is initialized.
30
- undef_mask : UndefMask ,
30
+ undef_mask : UninitMask ,
31
31
/// The size of the allocation. Currently, must always equal `bytes.len()`.
32
32
pub size : Size ,
33
33
/// The alignment of the allocation to detect unaligned reads.
@@ -94,7 +94,7 @@ impl<Tag> Allocation<Tag> {
94
94
Self {
95
95
bytes,
96
96
relocations : Relocations :: new ( ) ,
97
- undef_mask : UndefMask :: new ( size, true ) ,
97
+ undef_mask : UninitMask :: new ( size, true ) ,
98
98
size,
99
99
align,
100
100
mutability : Mutability :: Not ,
@@ -110,7 +110,7 @@ impl<Tag> Allocation<Tag> {
110
110
Allocation {
111
111
bytes : vec ! [ 0 ; size. bytes_usize( ) ] ,
112
112
relocations : Relocations :: new ( ) ,
113
- undef_mask : UndefMask :: new ( size, false ) ,
113
+ undef_mask : UninitMask :: new ( size, false ) ,
114
114
size,
115
115
align,
116
116
mutability : Mutability :: Mut ,
@@ -163,7 +163,7 @@ impl<Tag, Extra> Allocation<Tag, Extra> {
163
163
}
164
164
165
165
/// Returns the undef mask.
166
- pub fn undef_mask ( & self ) -> & UndefMask {
166
+ pub fn undef_mask ( & self ) -> & UninitMask {
167
167
& self . undef_mask
168
168
}
169
169
@@ -360,15 +360,15 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
360
360
cx : & impl HasDataLayout ,
361
361
ptr : Pointer < Tag > ,
362
362
size : Size ,
363
- ) -> InterpResult < ' tcx , ScalarMaybeUndef < Tag > > {
363
+ ) -> InterpResult < ' tcx , ScalarMaybeUninit < Tag > > {
364
364
// `get_bytes_unchecked` tests relocation edges.
365
365
let bytes = self . get_bytes_with_undef_and_ptr ( cx, ptr, size) ?;
366
366
// Undef check happens *after* we established that the alignment is correct.
367
367
// We must not return `Ok()` for unaligned pointers!
368
368
if self . is_defined ( ptr, size) . is_err ( ) {
369
369
// This inflates undefined bytes to the entire scalar, even if only a few
370
370
// bytes are undefined.
371
- return Ok ( ScalarMaybeUndef :: Undef ) ;
371
+ return Ok ( ScalarMaybeUninit :: Undef ) ;
372
372
}
373
373
// Now we do the actual reading.
374
374
let bits = read_target_uint ( cx. data_layout ( ) . endian , bytes) . unwrap ( ) ;
@@ -379,11 +379,11 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
379
379
} else {
380
380
if let Some ( & ( tag, alloc_id) ) = self . relocations . get ( & ptr. offset ) {
381
381
let ptr = Pointer :: new_with_tag ( alloc_id, Size :: from_bytes ( bits) , tag) ;
382
- return Ok ( ScalarMaybeUndef :: Scalar ( ptr. into ( ) ) ) ;
382
+ return Ok ( ScalarMaybeUninit :: Scalar ( ptr. into ( ) ) ) ;
383
383
}
384
384
}
385
385
// We don't. Just return the bits.
386
- Ok ( ScalarMaybeUndef :: Scalar ( Scalar :: from_uint ( bits, size) ) )
386
+ Ok ( ScalarMaybeUninit :: Scalar ( Scalar :: from_uint ( bits, size) ) )
387
387
}
388
388
389
389
/// Reads a pointer-sized scalar.
@@ -394,7 +394,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
394
394
& self ,
395
395
cx : & impl HasDataLayout ,
396
396
ptr : Pointer < Tag > ,
397
- ) -> InterpResult < ' tcx , ScalarMaybeUndef < Tag > > {
397
+ ) -> InterpResult < ' tcx , ScalarMaybeUninit < Tag > > {
398
398
self . read_scalar ( cx, ptr, cx. data_layout ( ) . pointer_size )
399
399
}
400
400
@@ -411,12 +411,12 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
411
411
& mut self ,
412
412
cx : & impl HasDataLayout ,
413
413
ptr : Pointer < Tag > ,
414
- val : ScalarMaybeUndef < Tag > ,
414
+ val : ScalarMaybeUninit < Tag > ,
415
415
type_size : Size ,
416
416
) -> InterpResult < ' tcx > {
417
417
let val = match val {
418
- ScalarMaybeUndef :: Scalar ( scalar) => scalar,
419
- ScalarMaybeUndef :: Undef => {
418
+ ScalarMaybeUninit :: Scalar ( scalar) => scalar,
419
+ ScalarMaybeUninit :: Undef => {
420
420
self . mark_definedness ( ptr, type_size, false ) ;
421
421
return Ok ( ( ) ) ;
422
422
}
@@ -447,7 +447,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
447
447
& mut self ,
448
448
cx : & impl HasDataLayout ,
449
449
ptr : Pointer < Tag > ,
450
- val : ScalarMaybeUndef < Tag > ,
450
+ val : ScalarMaybeUninit < Tag > ,
451
451
) -> InterpResult < ' tcx > {
452
452
let ptr_size = cx. data_layout ( ) . pointer_size ;
453
453
self . write_scalar ( cx, ptr, val, ptr_size)
@@ -557,7 +557,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
557
557
/// error which will report the first byte which is undefined.
558
558
fn check_defined ( & self , ptr : Pointer < Tag > , size : Size ) -> InterpResult < ' tcx > {
559
559
self . is_defined ( ptr, size)
560
- . or_else ( |idx| throw_ub ! ( InvalidUndefBytes ( Some ( Pointer :: new( ptr. alloc_id, idx) ) ) ) )
560
+ . or_else ( |idx| throw_ub ! ( InvalidUninitBytes ( Some ( Pointer :: new( ptr. alloc_id, idx) ) ) ) )
561
561
}
562
562
563
563
pub fn mark_definedness ( & mut self , ptr : Pointer < Tag > , size : Size , new_state : bool ) {
@@ -744,16 +744,16 @@ type Block = u64;
744
744
/// is defined. If it is `false` the byte is undefined.
745
745
#[ derive( Clone , Debug , Eq , PartialEq , PartialOrd , Ord , Hash , RustcEncodable , RustcDecodable ) ]
746
746
#[ derive( HashStable ) ]
747
- pub struct UndefMask {
747
+ pub struct UninitMask {
748
748
blocks : Vec < Block > ,
749
749
len : Size ,
750
750
}
751
751
752
- impl UndefMask {
752
+ impl UninitMask {
753
753
pub const BLOCK_SIZE : u64 = 64 ;
754
754
755
755
pub fn new ( size : Size , state : bool ) -> Self {
756
- let mut m = UndefMask { blocks : vec ! [ ] , len : Size :: ZERO } ;
756
+ let mut m = UninitMask { blocks : vec ! [ ] , len : Size :: ZERO } ;
757
757
m. grow ( size, state) ;
758
758
m
759
759
}
@@ -872,7 +872,7 @@ impl UndefMask {
872
872
#[ inline]
873
873
fn bit_index ( bits : Size ) -> ( usize , usize ) {
874
874
let bits = bits. bytes ( ) ;
875
- let a = bits / UndefMask :: BLOCK_SIZE ;
876
- let b = bits % UndefMask :: BLOCK_SIZE ;
875
+ let a = bits / UninitMask :: BLOCK_SIZE ;
876
+ let b = bits % UninitMask :: BLOCK_SIZE ;
877
877
( usize:: try_from ( a) . unwrap ( ) , usize:: try_from ( b) . unwrap ( ) )
878
878
}
0 commit comments