@@ -136,14 +136,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
136
136
let ( dest, ret) = match ret {
137
137
None => match link_name {
138
138
"miri_start_panic" => {
139
- check_abi ( abi, Abi :: Rust ) ?;
139
+ check_abi ( this , abi, Abi :: Rust ) ?;
140
140
this. handle_miri_start_panic ( args, unwind) ?;
141
141
return Ok ( None ) ;
142
142
}
143
143
// This matches calls to the foreign item `panic_impl`.
144
144
// The implementation is provided by the function with the `#[panic_handler]` attribute.
145
145
"panic_impl" => {
146
- check_abi ( abi, Abi :: Rust ) ?;
146
+ check_abi ( this , abi, Abi :: Rust ) ?;
147
147
let panic_impl_id = tcx. lang_items ( ) . panic_impl ( ) . unwrap ( ) ;
148
148
let panic_impl_instance = ty:: Instance :: mono ( tcx, panic_impl_id) ;
149
149
return Ok ( Some ( & * this. load_mir ( panic_impl_instance. def , None ) ?) ) ;
@@ -152,14 +152,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
152
152
| "exit"
153
153
| "ExitProcess"
154
154
=> {
155
- check_abi ( abi, if link_name == "exit" { Abi :: C { unwind : false } } else { Abi :: System { unwind : false } } ) ?;
155
+ check_abi ( this , abi, if link_name == "exit" { Abi :: C { unwind : false } } else { Abi :: System { unwind : false } } ) ?;
156
156
let & [ ref code] = check_arg_count ( args) ?;
157
157
// it's really u32 for ExitProcess, but we have to put it into the `Exit` variant anyway
158
158
let code = this. read_scalar ( code) ?. to_i32 ( ) ?;
159
159
throw_machine_stop ! ( TerminationInfo :: Exit ( code. into( ) ) ) ;
160
160
}
161
161
"abort" => {
162
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
162
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
163
163
throw_machine_stop ! ( TerminationInfo :: Abort (
164
164
"the program aborted execution" . to_owned( )
165
165
) )
@@ -180,7 +180,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
180
180
#[ rustfmt:: skip]
181
181
"__rust_start_panic" |
182
182
"__rust_panic_cleanup" => {
183
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
183
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
184
184
// This replicates some of the logic in `inject_panic_runtime`.
185
185
// FIXME: is there a way to reuse that logic?
186
186
let panic_runtime = match this. tcx . sess . panic_strategy ( ) {
@@ -221,7 +221,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
221
221
match link_name {
222
222
// Miri-specific extern functions
223
223
"miri_static_root" => {
224
- check_abi ( abi, Abi :: Rust ) ?;
224
+ check_abi ( this , abi, Abi :: Rust ) ?;
225
225
let & [ ref ptr] = check_arg_count ( args) ?;
226
226
let ptr = this. read_scalar ( ptr) ?. check_init ( ) ?;
227
227
let ptr = this. force_ptr ( ptr) ?;
@@ -233,27 +233,27 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
233
233
234
234
// Obtains a Miri backtrace. See the README for details.
235
235
"miri_get_backtrace" => {
236
- check_abi ( abi, Abi :: Rust ) ?;
236
+ check_abi ( this , abi, Abi :: Rust ) ?;
237
237
this. handle_miri_get_backtrace ( args, dest) ?;
238
238
}
239
239
240
240
// Resolves a Miri backtrace frame. See the README for details.
241
241
"miri_resolve_frame" => {
242
- check_abi ( abi, Abi :: Rust ) ?;
242
+ check_abi ( this , abi, Abi :: Rust ) ?;
243
243
this. handle_miri_resolve_frame ( args, dest) ?;
244
244
}
245
245
246
246
247
247
// Standard C allocation
248
248
"malloc" => {
249
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
249
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
250
250
let & [ ref size] = check_arg_count ( args) ?;
251
251
let size = this. read_scalar ( size) ?. to_machine_usize ( this) ?;
252
252
let res = this. malloc ( size, /*zero_init:*/ false , MiriMemoryKind :: C ) ;
253
253
this. write_scalar ( res, dest) ?;
254
254
}
255
255
"calloc" => {
256
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
256
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
257
257
let & [ ref items, ref len] = check_arg_count ( args) ?;
258
258
let items = this. read_scalar ( items) ?. to_machine_usize ( this) ?;
259
259
let len = this. read_scalar ( len) ?. to_machine_usize ( this) ?;
@@ -263,13 +263,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
263
263
this. write_scalar ( res, dest) ?;
264
264
}
265
265
"free" => {
266
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
266
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
267
267
let & [ ref ptr] = check_arg_count ( args) ?;
268
268
let ptr = this. read_scalar ( ptr) ?. check_init ( ) ?;
269
269
this. free ( ptr, MiriMemoryKind :: C ) ?;
270
270
}
271
271
"realloc" => {
272
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
272
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
273
273
let & [ ref old_ptr, ref new_size] = check_arg_count ( args) ?;
274
274
let old_ptr = this. read_scalar ( old_ptr) ?. check_init ( ) ?;
275
275
let new_size = this. read_scalar ( new_size) ?. to_machine_usize ( this) ?;
@@ -281,7 +281,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
281
281
// (Usually these would be forwarded to to `#[global_allocator]`; we instead implement a generic
282
282
// allocation that also checks that all conditions are met, such as not permitting zero-sized allocations.)
283
283
"__rust_alloc" => {
284
- check_abi ( abi, Abi :: Rust ) ?;
284
+ check_abi ( this , abi, Abi :: Rust ) ?;
285
285
let & [ ref size, ref align] = check_arg_count ( args) ?;
286
286
let size = this. read_scalar ( size) ?. to_machine_usize ( this) ?;
287
287
let align = this. read_scalar ( align) ?. to_machine_usize ( this) ?;
@@ -294,7 +294,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
294
294
this. write_scalar ( ptr, dest) ?;
295
295
}
296
296
"__rust_alloc_zeroed" => {
297
- check_abi ( abi, Abi :: Rust ) ?;
297
+ check_abi ( this , abi, Abi :: Rust ) ?;
298
298
let & [ ref size, ref align] = check_arg_count ( args) ?;
299
299
let size = this. read_scalar ( size) ?. to_machine_usize ( this) ?;
300
300
let align = this. read_scalar ( align) ?. to_machine_usize ( this) ?;
@@ -309,7 +309,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
309
309
this. write_scalar ( ptr, dest) ?;
310
310
}
311
311
"__rust_dealloc" => {
312
- check_abi ( abi, Abi :: Rust ) ?;
312
+ check_abi ( this , abi, Abi :: Rust ) ?;
313
313
let & [ ref ptr, ref old_size, ref align] = check_arg_count ( args) ?;
314
314
let ptr = this. read_scalar ( ptr) ?. check_init ( ) ?;
315
315
let old_size = this. read_scalar ( old_size) ?. to_machine_usize ( this) ?;
@@ -323,7 +323,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
323
323
) ?;
324
324
}
325
325
"__rust_realloc" => {
326
- check_abi ( abi, Abi :: Rust ) ?;
326
+ check_abi ( this , abi, Abi :: Rust ) ?;
327
327
let & [ ref ptr, ref old_size, ref align, ref new_size] = check_arg_count ( args) ?;
328
328
let ptr = this. force_ptr ( this. read_scalar ( ptr) ?. check_init ( ) ?) ?;
329
329
let old_size = this. read_scalar ( old_size) ?. to_machine_usize ( this) ?;
@@ -344,7 +344,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
344
344
345
345
// C memory handling functions
346
346
"memcmp" => {
347
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
347
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
348
348
let & [ ref left, ref right, ref n] = check_arg_count ( args) ?;
349
349
let left = this. read_scalar ( left) ?. check_init ( ) ?;
350
350
let right = this. read_scalar ( right) ?. check_init ( ) ?;
@@ -365,7 +365,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
365
365
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
366
366
}
367
367
"memrchr" => {
368
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
368
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
369
369
let & [ ref ptr, ref val, ref num] = check_arg_count ( args) ?;
370
370
let ptr = this. read_scalar ( ptr) ?. check_init ( ) ?;
371
371
let val = this. read_scalar ( val) ?. to_i32 ( ) ? as u8 ;
@@ -384,7 +384,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
384
384
}
385
385
}
386
386
"memchr" => {
387
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
387
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
388
388
let & [ ref ptr, ref val, ref num] = check_arg_count ( args) ?;
389
389
let ptr = this. read_scalar ( ptr) ?. check_init ( ) ?;
390
390
let val = this. read_scalar ( val) ?. to_i32 ( ) ? as u8 ;
@@ -402,7 +402,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
402
402
}
403
403
}
404
404
"strlen" => {
405
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
405
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
406
406
let & [ ref ptr] = check_arg_count ( args) ?;
407
407
let ptr = this. read_scalar ( ptr) ?. check_init ( ) ?;
408
408
let n = this. read_c_str ( ptr) ?. len ( ) ;
@@ -419,7 +419,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
419
419
| "asinf"
420
420
| "atanf"
421
421
=> {
422
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
422
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
423
423
let & [ ref f] = check_arg_count ( args) ?;
424
424
// FIXME: Using host floats.
425
425
let f = f32:: from_bits ( this. read_scalar ( f) ?. to_u32 ( ) ?) ;
@@ -440,7 +440,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
440
440
| "hypotf"
441
441
| "atan2f"
442
442
=> {
443
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
443
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
444
444
let & [ ref f1, ref f2] = check_arg_count ( args) ?;
445
445
// underscore case for windows, here and below
446
446
// (see https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/floating-point-primitives?view=vs-2019)
@@ -463,7 +463,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
463
463
| "asin"
464
464
| "atan"
465
465
=> {
466
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
466
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
467
467
let & [ ref f] = check_arg_count ( args) ?;
468
468
// FIXME: Using host floats.
469
469
let f = f64:: from_bits ( this. read_scalar ( f) ?. to_u64 ( ) ?) ;
@@ -484,7 +484,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
484
484
| "hypot"
485
485
| "atan2"
486
486
=> {
487
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
487
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
488
488
let & [ ref f1, ref f2] = check_arg_count ( args) ?;
489
489
// FIXME: Using host floats.
490
490
let f1 = f64:: from_bits ( this. read_scalar ( f1) ?. to_u64 ( ) ?) ;
@@ -501,7 +501,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
501
501
| "ldexp"
502
502
| "scalbn"
503
503
=> {
504
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
504
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
505
505
let & [ ref x, ref exp] = check_arg_count ( args) ?;
506
506
// For radix-2 (binary) systems, `ldexp` and `scalbn` are the same.
507
507
let x = this. read_scalar ( x) ?. to_f64 ( ) ?;
@@ -523,12 +523,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
523
523
524
524
// Architecture-specific shims
525
525
"llvm.x86.sse2.pause" if this. tcx . sess . target . arch == "x86" || this. tcx . sess . target . arch == "x86_64" => {
526
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
526
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
527
527
let & [ ] = check_arg_count ( args) ?;
528
528
this. yield_active_thread ( ) ;
529
529
}
530
530
"llvm.aarch64.isb" if this. tcx . sess . target . arch == "aarch64" => {
531
- check_abi ( abi, Abi :: C { unwind : false } ) ?;
531
+ check_abi ( this , abi, Abi :: C { unwind : false } ) ?;
532
532
let & [ ref arg] = check_arg_count ( args) ?;
533
533
let arg = this. read_scalar ( arg) ?. to_i32 ( ) ?;
534
534
match arg {
0 commit comments