@@ -485,14 +485,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
485485 // Standard C allocation
486486 "malloc" => {
487487 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) ?;
489489 let res = this. malloc ( size, /*zero_init:*/ false , MiriMemoryKind :: C ) ?;
490490 this. write_pointer ( res, dest) ?;
491491 }
492492 "calloc" => {
493493 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) ?;
496496 let size =
497497 items. checked_mul ( len) . ok_or_else ( || err_ub_format ! ( "overflow during calloc size computation" ) ) ?;
498498 let res = this. malloc ( size, /*zero_init:*/ true , MiriMemoryKind :: C ) ?;
@@ -506,16 +506,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
506506 "realloc" => {
507507 let [ old_ptr, new_size] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
508508 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) ?;
510510 let res = this. realloc ( old_ptr, new_size, MiriMemoryKind :: C ) ?;
511511 this. write_pointer ( res, dest) ?;
512512 }
513513
514514 // Rust allocation
515515 "__rust_alloc" | "miri_alloc" => {
516516 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) ?;
519519
520520 let default = |this : & mut MiriInterpCx < ' mir , ' tcx > | {
521521 Self :: check_alloc_request ( size, align) ?;
@@ -546,8 +546,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
546546 }
547547 "__rust_alloc_zeroed" => {
548548 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) ?;
551551
552552 return this. emulate_allocator ( Symbol :: intern ( "__rg_alloc_zeroed" ) , |this| {
553553 Self :: check_alloc_request ( size, align) ?;
@@ -566,8 +566,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
566566 "__rust_dealloc" | "miri_dealloc" => {
567567 let [ ptr, old_size, align] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
568568 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) ?;
571571
572572 let default = |this : & mut MiriInterpCx < ' mir , ' tcx > | {
573573 let memory_kind = match link_name. as_str ( ) {
@@ -596,9 +596,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
596596 "__rust_realloc" => {
597597 let [ ptr, old_size, align, new_size] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
598598 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) ?;
602602 // No need to check old_size; we anyway check that they match the allocation.
603603
604604 return this. emulate_allocator ( Symbol :: intern ( "__rg_realloc" ) , |this| {
@@ -621,7 +621,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
621621 let [ left, right, n] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
622622 let left = this. read_pointer ( left) ?;
623623 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 ) ?) ;
625625
626626 let result = {
627627 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> {
641641 let [ ptr, val, num] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
642642 let ptr = this. read_pointer ( ptr) ?;
643643 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) ?;
645645 // The docs say val is "interpreted as unsigned char".
646646 #[ allow( clippy:: cast_sign_loss, clippy:: cast_possible_truncation) ]
647647 let val = val as u8 ;
@@ -664,7 +664,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
664664 let [ ptr, val, num] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
665665 let ptr = this. read_pointer ( ptr) ?;
666666 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) ?;
668668 // The docs say val is "interpreted as unsigned char".
669669 #[ allow( clippy:: cast_sign_loss, clippy:: cast_possible_truncation) ]
670670 let val = val as u8 ;
0 commit comments