@@ -525,45 +525,30 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
525
525
}
526
526
527
527
// Rust allocation
528
- name if name == this . mangle_internal_symbol ( "__rust_alloc" ) || name == "miri_alloc" => {
528
+ "miri_alloc" => {
529
529
let default = |ecx : & mut MiriInterpCx < ' tcx > | {
530
530
// Only call `check_shim` when `#[global_allocator]` isn't used. When that
531
531
// macro is used, we act like no shim exists, so that the exported function can run.
532
532
let [ size, align] = ecx. check_shim ( abi, CanonAbi :: Rust , link_name, args) ?;
533
533
let size = ecx. read_target_usize ( size) ?;
534
534
let align = ecx. read_target_usize ( align) ?;
535
535
536
- ecx. check_rustc_alloc_request ( size, align) ?;
537
-
538
- let memory_kind = match link_name. as_str ( ) {
539
- "miri_alloc" => MiriMemoryKind :: Miri ,
540
- _ => MiriMemoryKind :: Rust ,
541
- } ;
536
+ this. check_rustc_alloc_request ( size, align) ?;
542
537
543
538
let ptr = ecx. allocate_ptr (
544
539
Size :: from_bytes ( size) ,
545
540
Align :: from_bytes ( align) . unwrap ( ) ,
546
- memory_kind . into ( ) ,
541
+ MiriMemoryKind :: Miri . into ( ) ,
547
542
AllocInit :: Uninit ,
548
543
) ?;
549
544
550
545
ecx. write_pointer ( ptr, dest)
551
546
} ;
552
547
553
- match link_name. as_str ( ) {
554
- "miri_alloc" => {
555
- default ( this) ?;
556
- return interp_ok ( EmulateItemResult :: NeedsReturn ) ;
557
- }
558
- _ => return this. emulate_allocator ( ) ,
559
- }
560
- }
561
- name if name == this. mangle_internal_symbol ( "__rust_alloc_zeroed" ) => {
562
- return this. emulate_allocator ( ) ;
548
+ default ( this) ?;
549
+ return interp_ok ( EmulateItemResult :: NeedsReturn ) ;
563
550
}
564
- name if name == this. mangle_internal_symbol ( "__rust_dealloc" )
565
- || name == "miri_dealloc" =>
566
- {
551
+ "miri_dealloc" => {
567
552
let default = |ecx : & mut MiriInterpCx < ' tcx > | {
568
553
// See the comment for `__rust_alloc` why `check_shim` is only called in the
569
554
// default case.
@@ -573,29 +558,16 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
573
558
let old_size = ecx. read_target_usize ( old_size) ?;
574
559
let align = ecx. read_target_usize ( align) ?;
575
560
576
- let memory_kind = match link_name. as_str ( ) {
577
- "miri_dealloc" => MiriMemoryKind :: Miri ,
578
- _ => MiriMemoryKind :: Rust ,
579
- } ;
580
-
581
561
// No need to check old_size/align; we anyway check that they match the allocation.
582
562
ecx. deallocate_ptr (
583
563
ptr,
584
564
Some ( ( Size :: from_bytes ( old_size) , Align :: from_bytes ( align) . unwrap ( ) ) ) ,
585
- memory_kind . into ( ) ,
565
+ MiriMemoryKind :: Miri . into ( ) ,
586
566
)
587
567
} ;
588
568
589
- match link_name. as_str ( ) {
590
- "miri_dealloc" => {
591
- default ( this) ?;
592
- return interp_ok ( EmulateItemResult :: NeedsReturn ) ;
593
- }
594
- _ => return this. emulate_allocator ( ) ,
595
- }
596
- }
597
- name if name == this. mangle_internal_symbol ( "__rust_realloc" ) => {
598
- return this. emulate_allocator ( ) ;
569
+ default ( this) ?;
570
+ return interp_ok ( EmulateItemResult :: NeedsReturn ) ;
599
571
}
600
572
601
573
// C memory handling functions
0 commit comments