@@ -500,14 +500,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
500500 // Standard C allocation
501501 "malloc" => {
502502 let [ size] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
503- let size = this. read_scalar ( size) ? . to_machine_usize ( this ) ?;
503+ let size = this. read_machine_usize ( size) ?;
504504 let res = this. malloc ( size, /*zero_init:*/ false , MiriMemoryKind :: C ) ?;
505505 this. write_pointer ( res, dest) ?;
506506 }
507507 "calloc" => {
508508 let [ items, len] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
509- let items = this. read_scalar ( items) ? . to_machine_usize ( this ) ?;
510- let len = this. read_scalar ( len) ? . to_machine_usize ( this ) ?;
509+ let items = this. read_machine_usize ( items) ?;
510+ let len = this. read_machine_usize ( len) ?;
511511 let size =
512512 items. checked_mul ( len) . ok_or_else ( || err_ub_format ! ( "overflow during calloc size computation" ) ) ?;
513513 let res = this. malloc ( size, /*zero_init:*/ true , MiriMemoryKind :: C ) ?;
@@ -521,16 +521,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
521521 "realloc" => {
522522 let [ old_ptr, new_size] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
523523 let old_ptr = this. read_pointer ( old_ptr) ?;
524- let new_size = this. read_scalar ( new_size) ? . to_machine_usize ( this ) ?;
524+ let new_size = this. read_machine_usize ( new_size) ?;
525525 let res = this. realloc ( old_ptr, new_size, MiriMemoryKind :: C ) ?;
526526 this. write_pointer ( res, dest) ?;
527527 }
528528
529529 // Rust allocation
530530 "__rust_alloc" | "miri_alloc" => {
531531 let [ size, align] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
532- let size = this. read_scalar ( size) ? . to_machine_usize ( this ) ?;
533- let align = this. read_scalar ( align) ? . to_machine_usize ( this ) ?;
532+ let size = this. read_machine_usize ( size) ?;
533+ let align = this. read_machine_usize ( align) ?;
534534
535535 let default = |this : & mut MiriInterpCx < ' mir , ' tcx > | {
536536 Self :: check_alloc_request ( size, align) ?;
@@ -561,8 +561,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
561561 }
562562 "__rust_alloc_zeroed" => {
563563 let [ size, align] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
564- let size = this. read_scalar ( size) ? . to_machine_usize ( this ) ?;
565- let align = this. read_scalar ( align) ? . to_machine_usize ( this ) ?;
564+ let size = this. read_machine_usize ( size) ?;
565+ let align = this. read_machine_usize ( align) ?;
566566
567567 return this. emulate_allocator ( Symbol :: intern ( "__rg_alloc_zeroed" ) , |this| {
568568 Self :: check_alloc_request ( size, align) ?;
@@ -581,8 +581,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
581581 "__rust_dealloc" | "miri_dealloc" => {
582582 let [ ptr, old_size, align] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
583583 let ptr = this. read_pointer ( ptr) ?;
584- let old_size = this. read_scalar ( old_size) ? . to_machine_usize ( this ) ?;
585- let align = this. read_scalar ( align) ? . to_machine_usize ( this ) ?;
584+ let old_size = this. read_machine_usize ( old_size) ?;
585+ let align = this. read_machine_usize ( align) ?;
586586
587587 let default = |this : & mut MiriInterpCx < ' mir , ' tcx > | {
588588 let memory_kind = match link_name. as_str ( ) {
@@ -611,9 +611,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
611611 "__rust_realloc" => {
612612 let [ ptr, old_size, align, new_size] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
613613 let ptr = this. read_pointer ( ptr) ?;
614- let old_size = this. read_scalar ( old_size) ? . to_machine_usize ( this ) ?;
615- let align = this. read_scalar ( align) ? . to_machine_usize ( this ) ?;
616- let new_size = this. read_scalar ( new_size) ? . to_machine_usize ( this ) ?;
614+ let old_size = this. read_machine_usize ( old_size) ?;
615+ let align = this. read_machine_usize ( align) ?;
616+ let new_size = this. read_machine_usize ( new_size) ?;
617617 // No need to check old_size; we anyway check that they match the allocation.
618618
619619 return this. emulate_allocator ( Symbol :: intern ( "__rg_realloc" ) , |this| {
@@ -636,7 +636,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
636636 let [ left, right, n] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
637637 let left = this. read_pointer ( left) ?;
638638 let right = this. read_pointer ( right) ?;
639- let n = Size :: from_bytes ( this. read_scalar ( n ) ? . to_machine_usize ( this ) ?) ;
639+ let n = Size :: from_bytes ( this. read_machine_usize ( n ) ?) ;
640640
641641 let result = {
642642 let left_bytes = this. read_bytes_ptr_strip_provenance ( left, n) ?;
@@ -656,7 +656,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
656656 let [ ptr, val, num] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
657657 let ptr = this. read_pointer ( ptr) ?;
658658 let val = this. read_scalar ( val) ?. to_i32 ( ) ?;
659- let num = this. read_scalar ( num) ? . to_machine_usize ( this ) ?;
659+ let num = this. read_machine_usize ( num) ?;
660660 // The docs say val is "interpreted as unsigned char".
661661 #[ allow( clippy:: cast_sign_loss, clippy:: cast_possible_truncation) ]
662662 let val = val as u8 ;
@@ -679,7 +679,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
679679 let [ ptr, val, num] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
680680 let ptr = this. read_pointer ( ptr) ?;
681681 let val = this. read_scalar ( val) ?. to_i32 ( ) ?;
682- let num = this. read_scalar ( num) ? . to_machine_usize ( this ) ?;
682+ let num = this. read_machine_usize ( num) ?;
683683 // The docs say val is "interpreted as unsigned char".
684684 #[ allow( clippy:: cast_sign_loss, clippy:: cast_possible_truncation) ]
685685 let val = val as u8 ;
0 commit comments