@@ -25,7 +25,7 @@ use rustc_target::{
25
25
26
26
use super :: backtrace:: EvalContextExt as _;
27
27
use crate :: * ;
28
- use helpers:: { check_abi , check_arg_count} ;
28
+ use helpers:: check_arg_count;
29
29
30
30
/// Returned by `emulate_foreign_item_by_name`.
31
31
pub enum EmulateByNameResult {
@@ -226,14 +226,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
226
226
let ( dest, ret) = match ret {
227
227
None => match link_name {
228
228
"miri_start_panic" => {
229
- check_abi ( this , abi, Abi :: Rust ) ?;
229
+ this . check_abi ( abi, Abi :: Rust ) ?;
230
230
this. handle_miri_start_panic ( args, unwind) ?;
231
231
return Ok ( None ) ;
232
232
}
233
233
// This matches calls to the foreign item `panic_impl`.
234
234
// The implementation is provided by the function with the `#[panic_handler]` attribute.
235
235
"panic_impl" => {
236
- check_abi ( this , abi, Abi :: Rust ) ?;
236
+ this . check_abi ( abi, Abi :: Rust ) ?;
237
237
let panic_impl_id = tcx. lang_items ( ) . panic_impl ( ) . unwrap ( ) ;
238
238
let panic_impl_instance = ty:: Instance :: mono ( tcx, panic_impl_id) ;
239
239
return Ok ( Some ( & * this. load_mir ( panic_impl_instance. def , None ) ?) ) ;
@@ -242,14 +242,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
242
242
| "exit"
243
243
| "ExitProcess"
244
244
=> {
245
- check_abi ( this , abi, if link_name == "exit" { Abi :: C { unwind : false } } else { Abi :: System { unwind : false } } ) ?;
245
+ this . check_abi ( abi, if link_name == "exit" { Abi :: C { unwind : false } } else { Abi :: System { unwind : false } } ) ?;
246
246
let & [ ref code] = check_arg_count ( args) ?;
247
247
// it's really u32 for ExitProcess, but we have to put it into the `Exit` variant anyway
248
248
let code = this. read_scalar ( code) ?. to_i32 ( ) ?;
249
249
throw_machine_stop ! ( TerminationInfo :: Exit ( code. into( ) ) ) ;
250
250
}
251
251
"abort" => {
252
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
252
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
253
253
throw_machine_stop ! ( TerminationInfo :: Abort (
254
254
"the program aborted execution" . to_owned( )
255
255
) )
@@ -298,7 +298,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
298
298
match link_name {
299
299
// Miri-specific extern functions
300
300
"miri_static_root" => {
301
- check_abi ( this , abi, Abi :: Rust ) ?;
301
+ this . check_abi ( abi, Abi :: Rust ) ?;
302
302
let & [ ref ptr] = check_arg_count ( args) ?;
303
303
let ptr = this. read_scalar ( ptr) ?. check_init ( ) ?;
304
304
let ptr = this. force_ptr ( ptr) ?;
@@ -310,27 +310,27 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
310
310
311
311
// Obtains a Miri backtrace. See the README for details.
312
312
"miri_get_backtrace" => {
313
- check_abi ( this , abi, Abi :: Rust ) ?;
313
+ this . check_abi ( abi, Abi :: Rust ) ?;
314
314
this. handle_miri_get_backtrace ( args, dest) ?;
315
315
}
316
316
317
317
// Resolves a Miri backtrace frame. See the README for details.
318
318
"miri_resolve_frame" => {
319
- check_abi ( this , abi, Abi :: Rust ) ?;
319
+ this . check_abi ( abi, Abi :: Rust ) ?;
320
320
this. handle_miri_resolve_frame ( args, dest) ?;
321
321
}
322
322
323
323
324
324
// Standard C allocation
325
325
"malloc" => {
326
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
326
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
327
327
let & [ ref size] = check_arg_count ( args) ?;
328
328
let size = this. read_scalar ( size) ?. to_machine_usize ( this) ?;
329
329
let res = this. malloc ( size, /*zero_init:*/ false , MiriMemoryKind :: C ) ;
330
330
this. write_scalar ( res, dest) ?;
331
331
}
332
332
"calloc" => {
333
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
333
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
334
334
let & [ ref items, ref len] = check_arg_count ( args) ?;
335
335
let items = this. read_scalar ( items) ?. to_machine_usize ( this) ?;
336
336
let len = this. read_scalar ( len) ?. to_machine_usize ( this) ?;
@@ -340,13 +340,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
340
340
this. write_scalar ( res, dest) ?;
341
341
}
342
342
"free" => {
343
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
343
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
344
344
let & [ ref ptr] = check_arg_count ( args) ?;
345
345
let ptr = this. read_scalar ( ptr) ?. check_init ( ) ?;
346
346
this. free ( ptr, MiriMemoryKind :: C ) ?;
347
347
}
348
348
"realloc" => {
349
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
349
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
350
350
let & [ ref old_ptr, ref new_size] = check_arg_count ( args) ?;
351
351
let old_ptr = this. read_scalar ( old_ptr) ?. check_init ( ) ?;
352
352
let new_size = this. read_scalar ( new_size) ?. to_machine_usize ( this) ?;
@@ -358,7 +358,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
358
358
// (Usually these would be forwarded to to `#[global_allocator]`; we instead implement a generic
359
359
// allocation that also checks that all conditions are met, such as not permitting zero-sized allocations.)
360
360
"__rust_alloc" => {
361
- check_abi ( this , abi, Abi :: Rust ) ?;
361
+ this . check_abi ( abi, Abi :: Rust ) ?;
362
362
let & [ ref size, ref align] = check_arg_count ( args) ?;
363
363
let size = this. read_scalar ( size) ?. to_machine_usize ( this) ?;
364
364
let align = this. read_scalar ( align) ?. to_machine_usize ( this) ?;
@@ -371,7 +371,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
371
371
this. write_scalar ( ptr, dest) ?;
372
372
}
373
373
"__rust_alloc_zeroed" => {
374
- check_abi ( this , abi, Abi :: Rust ) ?;
374
+ this . check_abi ( abi, Abi :: Rust ) ?;
375
375
let & [ ref size, ref align] = check_arg_count ( args) ?;
376
376
let size = this. read_scalar ( size) ?. to_machine_usize ( this) ?;
377
377
let align = this. read_scalar ( align) ?. to_machine_usize ( this) ?;
@@ -386,7 +386,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
386
386
this. write_scalar ( ptr, dest) ?;
387
387
}
388
388
"__rust_dealloc" => {
389
- check_abi ( this , abi, Abi :: Rust ) ?;
389
+ this . check_abi ( abi, Abi :: Rust ) ?;
390
390
let & [ ref ptr, ref old_size, ref align] = check_arg_count ( args) ?;
391
391
let ptr = this. read_scalar ( ptr) ?. check_init ( ) ?;
392
392
let old_size = this. read_scalar ( old_size) ?. to_machine_usize ( this) ?;
@@ -400,7 +400,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
400
400
) ?;
401
401
}
402
402
"__rust_realloc" => {
403
- check_abi ( this , abi, Abi :: Rust ) ?;
403
+ this . check_abi ( abi, Abi :: Rust ) ?;
404
404
let & [ ref ptr, ref old_size, ref align, ref new_size] = check_arg_count ( args) ?;
405
405
let ptr = this. force_ptr ( this. read_scalar ( ptr) ?. check_init ( ) ?) ?;
406
406
let old_size = this. read_scalar ( old_size) ?. to_machine_usize ( this) ?;
@@ -421,7 +421,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
421
421
422
422
// C memory handling functions
423
423
"memcmp" => {
424
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
424
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
425
425
let & [ ref left, ref right, ref n] = check_arg_count ( args) ?;
426
426
let left = this. read_scalar ( left) ?. check_init ( ) ?;
427
427
let right = this. read_scalar ( right) ?. check_init ( ) ?;
@@ -442,7 +442,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
442
442
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
443
443
}
444
444
"memrchr" => {
445
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
445
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
446
446
let & [ ref ptr, ref val, ref num] = check_arg_count ( args) ?;
447
447
let ptr = this. read_scalar ( ptr) ?. check_init ( ) ?;
448
448
let val = this. read_scalar ( val) ?. to_i32 ( ) ? as u8 ;
@@ -461,7 +461,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
461
461
}
462
462
}
463
463
"memchr" => {
464
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
464
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
465
465
let & [ ref ptr, ref val, ref num] = check_arg_count ( args) ?;
466
466
let ptr = this. read_scalar ( ptr) ?. check_init ( ) ?;
467
467
let val = this. read_scalar ( val) ?. to_i32 ( ) ? as u8 ;
@@ -479,7 +479,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
479
479
}
480
480
}
481
481
"strlen" => {
482
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
482
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
483
483
let & [ ref ptr] = check_arg_count ( args) ?;
484
484
let ptr = this. read_scalar ( ptr) ?. check_init ( ) ?;
485
485
let n = this. read_c_str ( ptr) ?. len ( ) ;
@@ -496,7 +496,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
496
496
| "asinf"
497
497
| "atanf"
498
498
=> {
499
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
499
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
500
500
let & [ ref f] = check_arg_count ( args) ?;
501
501
// FIXME: Using host floats.
502
502
let f = f32:: from_bits ( this. read_scalar ( f) ?. to_u32 ( ) ?) ;
@@ -517,7 +517,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
517
517
| "hypotf"
518
518
| "atan2f"
519
519
=> {
520
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
520
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
521
521
let & [ ref f1, ref f2] = check_arg_count ( args) ?;
522
522
// underscore case for windows, here and below
523
523
// (see https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/floating-point-primitives?view=vs-2019)
@@ -540,7 +540,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
540
540
| "asin"
541
541
| "atan"
542
542
=> {
543
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
543
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
544
544
let & [ ref f] = check_arg_count ( args) ?;
545
545
// FIXME: Using host floats.
546
546
let f = f64:: from_bits ( this. read_scalar ( f) ?. to_u64 ( ) ?) ;
@@ -561,7 +561,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
561
561
| "hypot"
562
562
| "atan2"
563
563
=> {
564
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
564
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
565
565
let & [ ref f1, ref f2] = check_arg_count ( args) ?;
566
566
// FIXME: Using host floats.
567
567
let f1 = f64:: from_bits ( this. read_scalar ( f1) ?. to_u64 ( ) ?) ;
@@ -578,7 +578,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
578
578
| "ldexp"
579
579
| "scalbn"
580
580
=> {
581
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
581
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
582
582
let & [ ref x, ref exp] = check_arg_count ( args) ?;
583
583
// For radix-2 (binary) systems, `ldexp` and `scalbn` are the same.
584
584
let x = this. read_scalar ( x) ?. to_f64 ( ) ?;
@@ -600,12 +600,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
600
600
601
601
// Architecture-specific shims
602
602
"llvm.x86.sse2.pause" if this. tcx . sess . target . arch == "x86" || this. tcx . sess . target . arch == "x86_64" => {
603
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
603
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
604
604
let & [ ] = check_arg_count ( args) ?;
605
605
this. yield_active_thread ( ) ;
606
606
}
607
607
"llvm.aarch64.isb" if this. tcx . sess . target . arch == "aarch64" => {
608
- check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
608
+ this . check_abi ( abi, Abi :: C { unwind : false } ) ?;
609
609
let & [ ref arg] = check_arg_count ( args) ?;
610
610
let arg = this. read_scalar ( arg) ?. to_i32 ( ) ?;
611
611
match arg {
0 commit comments