Skip to content

Commit ffd8cb8

Browse files
bjorn3RalfJung
andcommitted
Fix review comments
Co-authored-by: Ralf Jung <[email protected]>
1 parent 568deb7 commit ffd8cb8

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/tools/miri/src/shims/foreign_items.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
359359
match allocator_kind {
360360
AllocatorKind::Global => {
361361
// When `#[global_allocator]` is used, `__rust_*` is defined by the macro expansion
362-
// of this attribute rather than generated by the allocator shim. As such we have
363-
// to call the definition produced by `#[global_allocator]` instead of the shim like
364-
// in the case of `#[global_allocator]` not existing. Somewhat unintuitively doing
365-
// so is done by returning `NotSupported`.
362+
// of this attribute. As such we have to call an exported Rust function,
363+
// and not execute any Miri shim. Somewhat unintuitively doing so is done
364+
// by returning `NotSupported`, which triggers the `lookup_exported_symbol`
365+
// fallback case in `emulate_foreign_item`.
366366
return Ok(EmulateByNameResult::NotSupported);
367367
}
368368
AllocatorKind::Default => {
@@ -559,9 +559,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
559559
// Rust allocation
560560
"__rust_alloc" | "miri_alloc" => {
561561
let default = |this: &mut MiriInterpCx<'mir, 'tcx>| {
562-
// Only call `check_shim` when `#[global_allocator]` isn't used. The macro
563-
// expansion of `#[global_allocator]` defines this symbol and `check_shim`
564-
// checks that there exists no definition of a shim.
562+
// Only call `check_shim` when `#[global_allocator]` isn't used. When that
563+
// macro is used, we act like no shim exists, so that the exported function can run.
565564
let [size, align] = this.check_shim(abi, Abi::Rust, link_name, args)?;
566565
let size = this.read_target_usize(size)?;
567566
let align = this.read_target_usize(align)?;

0 commit comments

Comments
 (0)