@@ -485,14 +485,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
485
485
// Standard C allocation
486
486
"malloc" => {
487
487
let [ size] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
488
- let size = this. read_scalar ( size) ? . to_machine_usize ( this ) ?;
488
+ let size = this. read_machine_usize ( size) ?;
489
489
let res = this. malloc ( size, /*zero_init:*/ false , MiriMemoryKind :: C ) ?;
490
490
this. write_pointer ( res, dest) ?;
491
491
}
492
492
"calloc" => {
493
493
let [ items, len] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
494
- let items = this. read_scalar ( items) ? . to_machine_usize ( this ) ?;
495
- let len = this. read_scalar ( len) ? . to_machine_usize ( this ) ?;
494
+ let items = this. read_machine_usize ( items) ?;
495
+ let len = this. read_machine_usize ( len) ?;
496
496
let size =
497
497
items. checked_mul ( len) . ok_or_else ( || err_ub_format ! ( "overflow during calloc size computation" ) ) ?;
498
498
let res = this. malloc ( size, /*zero_init:*/ true , MiriMemoryKind :: C ) ?;
@@ -506,16 +506,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
506
506
"realloc" => {
507
507
let [ old_ptr, new_size] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
508
508
let old_ptr = this. read_pointer ( old_ptr) ?;
509
- let new_size = this. read_scalar ( new_size) ? . to_machine_usize ( this ) ?;
509
+ let new_size = this. read_machine_usize ( new_size) ?;
510
510
let res = this. realloc ( old_ptr, new_size, MiriMemoryKind :: C ) ?;
511
511
this. write_pointer ( res, dest) ?;
512
512
}
513
513
514
514
// Rust allocation
515
515
"__rust_alloc" | "miri_alloc" => {
516
516
let [ size, align] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
517
- let size = this. read_scalar ( size) ? . to_machine_usize ( this ) ?;
518
- let align = this. read_scalar ( align) ? . to_machine_usize ( this ) ?;
517
+ let size = this. read_machine_usize ( size) ?;
518
+ let align = this. read_machine_usize ( align) ?;
519
519
520
520
let default = |this : & mut MiriInterpCx < ' mir , ' tcx > | {
521
521
Self :: check_alloc_request ( size, align) ?;
@@ -546,8 +546,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
546
546
}
547
547
"__rust_alloc_zeroed" => {
548
548
let [ size, align] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
549
- let size = this. read_scalar ( size) ? . to_machine_usize ( this ) ?;
550
- let align = this. read_scalar ( align) ? . to_machine_usize ( this ) ?;
549
+ let size = this. read_machine_usize ( size) ?;
550
+ let align = this. read_machine_usize ( align) ?;
551
551
552
552
return this. emulate_allocator ( Symbol :: intern ( "__rg_alloc_zeroed" ) , |this| {
553
553
Self :: check_alloc_request ( size, align) ?;
@@ -566,8 +566,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
566
566
"__rust_dealloc" | "miri_dealloc" => {
567
567
let [ ptr, old_size, align] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
568
568
let ptr = this. read_pointer ( ptr) ?;
569
- let old_size = this. read_scalar ( old_size) ? . to_machine_usize ( this ) ?;
570
- let align = this. read_scalar ( align) ? . to_machine_usize ( this ) ?;
569
+ let old_size = this. read_machine_usize ( old_size) ?;
570
+ let align = this. read_machine_usize ( align) ?;
571
571
572
572
let default = |this : & mut MiriInterpCx < ' mir , ' tcx > | {
573
573
let memory_kind = match link_name. as_str ( ) {
@@ -596,9 +596,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
596
596
"__rust_realloc" => {
597
597
let [ ptr, old_size, align, new_size] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
598
598
let ptr = this. read_pointer ( ptr) ?;
599
- let old_size = this. read_scalar ( old_size) ? . to_machine_usize ( this ) ?;
600
- let align = this. read_scalar ( align) ? . to_machine_usize ( this ) ?;
601
- let new_size = this. read_scalar ( new_size) ? . to_machine_usize ( this ) ?;
599
+ let old_size = this. read_machine_usize ( old_size) ?;
600
+ let align = this. read_machine_usize ( align) ?;
601
+ let new_size = this. read_machine_usize ( new_size) ?;
602
602
// No need to check old_size; we anyway check that they match the allocation.
603
603
604
604
return this. emulate_allocator ( Symbol :: intern ( "__rg_realloc" ) , |this| {
@@ -621,7 +621,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
621
621
let [ left, right, n] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
622
622
let left = this. read_pointer ( left) ?;
623
623
let right = this. read_pointer ( right) ?;
624
- let n = Size :: from_bytes ( this. read_scalar ( n ) ? . to_machine_usize ( this ) ?) ;
624
+ let n = Size :: from_bytes ( this. read_machine_usize ( n ) ?) ;
625
625
626
626
let result = {
627
627
let left_bytes = this. read_bytes_ptr_strip_provenance ( left, n) ?;
@@ -641,7 +641,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
641
641
let [ ptr, val, num] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
642
642
let ptr = this. read_pointer ( ptr) ?;
643
643
let val = this. read_scalar ( val) ?. to_i32 ( ) ?;
644
- let num = this. read_scalar ( num) ? . to_machine_usize ( this ) ?;
644
+ let num = this. read_machine_usize ( num) ?;
645
645
// The docs say val is "interpreted as unsigned char".
646
646
#[ allow( clippy:: cast_sign_loss, clippy:: cast_possible_truncation) ]
647
647
let val = val as u8 ;
@@ -664,7 +664,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
664
664
let [ ptr, val, num] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
665
665
let ptr = this. read_pointer ( ptr) ?;
666
666
let val = this. read_scalar ( val) ?. to_i32 ( ) ?;
667
- let num = this. read_scalar ( num) ? . to_machine_usize ( this ) ?;
667
+ let num = this. read_machine_usize ( num) ?;
668
668
// The docs say val is "interpreted as unsigned char".
669
669
#[ allow( clippy:: cast_sign_loss, clippy:: cast_possible_truncation) ]
670
670
let val = val as u8 ;
0 commit comments