1
1
//! The virtual memory representation of the MIR interpreter.
2
2
3
3
use super :: {
4
- Pointer , EvalResult , AllocId , ScalarMaybeUndef , write_target_uint, read_target_uint, Scalar ,
4
+ Pointer , InterpResult , AllocId , ScalarMaybeUndef , write_target_uint, read_target_uint, Scalar ,
5
5
} ;
6
6
7
7
use crate :: ty:: layout:: { Size , Align } ;
@@ -82,7 +82,7 @@ pub trait AllocationExtra<Tag>: ::std::fmt::Debug + Clone {
82
82
_alloc : & Allocation < Tag , Self > ,
83
83
_ptr : Pointer < Tag > ,
84
84
_size : Size ,
85
- ) -> EvalResult < ' tcx > {
85
+ ) -> InterpResult < ' tcx > {
86
86
Ok ( ( ) )
87
87
}
88
88
@@ -92,7 +92,7 @@ pub trait AllocationExtra<Tag>: ::std::fmt::Debug + Clone {
92
92
_alloc : & mut Allocation < Tag , Self > ,
93
93
_ptr : Pointer < Tag > ,
94
94
_size : Size ,
95
- ) -> EvalResult < ' tcx > {
95
+ ) -> InterpResult < ' tcx > {
96
96
Ok ( ( ) )
97
97
}
98
98
@@ -103,7 +103,7 @@ pub trait AllocationExtra<Tag>: ::std::fmt::Debug + Clone {
103
103
_alloc : & mut Allocation < Tag , Self > ,
104
104
_ptr : Pointer < Tag > ,
105
105
_size : Size ,
106
- ) -> EvalResult < ' tcx > {
106
+ ) -> InterpResult < ' tcx > {
107
107
Ok ( ( ) )
108
108
}
109
109
}
@@ -156,7 +156,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
156
156
& self ,
157
157
ptr : Pointer < Tag > ,
158
158
msg : CheckInAllocMsg ,
159
- ) -> EvalResult < ' tcx > {
159
+ ) -> InterpResult < ' tcx > {
160
160
let allocation_size = self . bytes . len ( ) as u64 ;
161
161
ptr. check_in_alloc ( Size :: from_bytes ( allocation_size) , msg)
162
162
}
@@ -169,7 +169,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
169
169
ptr : Pointer < Tag > ,
170
170
size : Size ,
171
171
msg : CheckInAllocMsg ,
172
- ) -> EvalResult < ' tcx > {
172
+ ) -> InterpResult < ' tcx > {
173
173
// if ptr.offset is in bounds, then so is ptr (because offset checks for overflow)
174
174
self . check_bounds_ptr ( ptr. offset ( size, cx) ?, msg)
175
175
}
@@ -191,7 +191,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
191
191
size : Size ,
192
192
check_defined_and_ptr : bool ,
193
193
msg : CheckInAllocMsg ,
194
- ) -> EvalResult < ' tcx , & [ u8 ] >
194
+ ) -> InterpResult < ' tcx , & [ u8 ] >
195
195
{
196
196
self . check_bounds ( cx, ptr, size, msg) ?;
197
197
@@ -217,7 +217,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
217
217
cx : & impl HasDataLayout ,
218
218
ptr : Pointer < Tag > ,
219
219
size : Size ,
220
- ) -> EvalResult < ' tcx , & [ u8 ] >
220
+ ) -> InterpResult < ' tcx , & [ u8 ] >
221
221
{
222
222
self . get_bytes_internal ( cx, ptr, size, true , CheckInAllocMsg :: MemoryAccessTest )
223
223
}
@@ -230,7 +230,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
230
230
cx : & impl HasDataLayout ,
231
231
ptr : Pointer < Tag > ,
232
232
size : Size ,
233
- ) -> EvalResult < ' tcx , & [ u8 ] >
233
+ ) -> InterpResult < ' tcx , & [ u8 ] >
234
234
{
235
235
self . get_bytes_internal ( cx, ptr, size, false , CheckInAllocMsg :: MemoryAccessTest )
236
236
}
@@ -242,7 +242,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
242
242
cx : & impl HasDataLayout ,
243
243
ptr : Pointer < Tag > ,
244
244
size : Size ,
245
- ) -> EvalResult < ' tcx , & mut [ u8 ] >
245
+ ) -> InterpResult < ' tcx , & mut [ u8 ] >
246
246
{
247
247
assert_ne ! ( size. bytes( ) , 0 , "0-sized accesses should never even get a `Pointer`" ) ;
248
248
self . check_bounds ( cx, ptr, size, CheckInAllocMsg :: MemoryAccessTest ) ?;
@@ -267,7 +267,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
267
267
& self ,
268
268
cx : & impl HasDataLayout ,
269
269
ptr : Pointer < Tag > ,
270
- ) -> EvalResult < ' tcx , & [ u8 ] >
270
+ ) -> InterpResult < ' tcx , & [ u8 ] >
271
271
{
272
272
assert_eq ! ( ptr. offset. bytes( ) as usize as u64 , ptr. offset. bytes( ) ) ;
273
273
let offset = ptr. offset . bytes ( ) as usize ;
@@ -292,7 +292,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
292
292
ptr : Pointer < Tag > ,
293
293
size : Size ,
294
294
allow_ptr_and_undef : bool ,
295
- ) -> EvalResult < ' tcx >
295
+ ) -> InterpResult < ' tcx >
296
296
{
297
297
// Check bounds and relocations on the edges
298
298
self . get_bytes_with_undef_and_ptr ( cx, ptr, size) ?;
@@ -312,7 +312,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
312
312
cx : & impl HasDataLayout ,
313
313
ptr : Pointer < Tag > ,
314
314
src : & [ u8 ] ,
315
- ) -> EvalResult < ' tcx >
315
+ ) -> InterpResult < ' tcx >
316
316
{
317
317
let bytes = self . get_bytes_mut ( cx, ptr, Size :: from_bytes ( src. len ( ) as u64 ) ) ?;
318
318
bytes. clone_from_slice ( src) ;
@@ -326,7 +326,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
326
326
ptr : Pointer < Tag > ,
327
327
val : u8 ,
328
328
count : Size
329
- ) -> EvalResult < ' tcx >
329
+ ) -> InterpResult < ' tcx >
330
330
{
331
331
let bytes = self . get_bytes_mut ( cx, ptr, count) ?;
332
332
for b in bytes {
@@ -348,7 +348,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
348
348
cx : & impl HasDataLayout ,
349
349
ptr : Pointer < Tag > ,
350
350
size : Size
351
- ) -> EvalResult < ' tcx , ScalarMaybeUndef < Tag > >
351
+ ) -> InterpResult < ' tcx , ScalarMaybeUndef < Tag > >
352
352
{
353
353
// get_bytes_unchecked tests relocation edges
354
354
let bytes = self . get_bytes_with_undef_and_ptr ( cx, ptr, size) ?;
@@ -383,7 +383,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
383
383
& self ,
384
384
cx : & impl HasDataLayout ,
385
385
ptr : Pointer < Tag > ,
386
- ) -> EvalResult < ' tcx , ScalarMaybeUndef < Tag > >
386
+ ) -> InterpResult < ' tcx , ScalarMaybeUndef < Tag > >
387
387
{
388
388
self . read_scalar ( cx, ptr, cx. data_layout ( ) . pointer_size )
389
389
}
@@ -402,7 +402,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
402
402
ptr : Pointer < Tag > ,
403
403
val : ScalarMaybeUndef < Tag > ,
404
404
type_size : Size ,
405
- ) -> EvalResult < ' tcx >
405
+ ) -> InterpResult < ' tcx >
406
406
{
407
407
let val = match val {
408
408
ScalarMaybeUndef :: Scalar ( scalar) => scalar,
@@ -438,7 +438,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
438
438
cx : & impl HasDataLayout ,
439
439
ptr : Pointer < Tag > ,
440
440
val : ScalarMaybeUndef < Tag >
441
- ) -> EvalResult < ' tcx >
441
+ ) -> InterpResult < ' tcx >
442
442
{
443
443
let ptr_size = cx. data_layout ( ) . pointer_size ;
444
444
self . write_scalar ( cx, ptr. into ( ) , val, ptr_size)
@@ -468,7 +468,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
468
468
cx : & impl HasDataLayout ,
469
469
ptr : Pointer < Tag > ,
470
470
size : Size ,
471
- ) -> EvalResult < ' tcx > {
471
+ ) -> InterpResult < ' tcx > {
472
472
if self . relocations ( cx, ptr, size) . is_empty ( ) {
473
473
Ok ( ( ) )
474
474
} else {
@@ -487,7 +487,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
487
487
cx : & impl HasDataLayout ,
488
488
ptr : Pointer < Tag > ,
489
489
size : Size ,
490
- ) -> EvalResult < ' tcx > {
490
+ ) -> InterpResult < ' tcx > {
491
491
// Find the start and end of the given range and its outermost relocations.
492
492
let ( first, last) = {
493
493
// Find all relocations overlapping the given range.
@@ -525,7 +525,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
525
525
cx : & impl HasDataLayout ,
526
526
ptr : Pointer < Tag > ,
527
527
size : Size ,
528
- ) -> EvalResult < ' tcx > {
528
+ ) -> InterpResult < ' tcx > {
529
529
self . check_relocations ( cx, ptr, Size :: ZERO ) ?;
530
530
self . check_relocations ( cx, ptr. offset ( size, cx) ?, Size :: ZERO ) ?;
531
531
Ok ( ( ) )
@@ -538,7 +538,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
538
538
/// Checks that a range of bytes is defined. If not, returns the `ReadUndefBytes`
539
539
/// error which will report the first byte which is undefined.
540
540
#[ inline]
541
- fn check_defined ( & self , ptr : Pointer < Tag > , size : Size ) -> EvalResult < ' tcx > {
541
+ fn check_defined ( & self , ptr : Pointer < Tag > , size : Size ) -> InterpResult < ' tcx > {
542
542
self . undef_mask . is_range_defined (
543
543
ptr. offset ,
544
544
ptr. offset + size,
@@ -550,7 +550,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
550
550
ptr : Pointer < Tag > ,
551
551
size : Size ,
552
552
new_state : bool ,
553
- ) -> EvalResult < ' tcx > {
553
+ ) -> InterpResult < ' tcx > {
554
554
if size. bytes ( ) == 0 {
555
555
return Ok ( ( ) ) ;
556
556
}
0 commit comments