Skip to content

Commit 5d8fbfc

Browse files
committed
rename memory kind: Env -> Machine
1 parent 340e14e commit 5d8fbfc

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/eval.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
9090
// Make space for `0` terminator.
9191
let size = arg.len() as u64 + 1;
9292
let arg_type = tcx.mk_array(tcx.types.u8, size);
93-
let arg_place = ecx.allocate(ecx.layout_of(arg_type)?, MiriMemoryKind::Env.into());
93+
let arg_place = ecx.allocate(ecx.layout_of(arg_type)?, MiriMemoryKind::Machine.into());
9494
ecx.write_os_str_to_c_str(OsStr::new(arg), arg_place.ptr, size)?;
9595
argvs.push(arg_place.ptr);
9696
}
9797
// Make an array with all these pointers, in the Miri memory.
9898
let argvs_layout =
9999
ecx.layout_of(tcx.mk_array(tcx.mk_imm_ptr(tcx.types.u8), argvs.len() as u64))?;
100-
let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Env.into());
100+
let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Machine.into());
101101
for (idx, arg) in argvs.into_iter().enumerate() {
102102
let place = ecx.mplace_field(argvs_place, idx as u64)?;
103103
ecx.write_scalar(arg, place.into())?;
@@ -108,13 +108,13 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
108108
// Store `argc` and `argv` for macOS `_NSGetArg{c,v}`.
109109
{
110110
let argc_place =
111-
ecx.allocate(ecx.layout_of(tcx.types.isize)?, MiriMemoryKind::Env.into());
111+
ecx.allocate(ecx.layout_of(tcx.types.isize)?, MiriMemoryKind::Machine.into());
112112
ecx.write_scalar(argc, argc_place.into())?;
113113
ecx.machine.argc = Some(argc_place.ptr);
114114

115115
let argv_place = ecx.allocate(
116116
ecx.layout_of(tcx.mk_imm_ptr(tcx.types.unit))?,
117-
MiriMemoryKind::Env.into(),
117+
MiriMemoryKind::Machine.into(),
118118
);
119119
ecx.write_scalar(argv, argv_place.into())?;
120120
ecx.machine.argv = Some(argv_place.ptr);
@@ -134,7 +134,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
134134

135135
let cmd_utf16: Vec<u16> = cmd.encode_utf16().collect();
136136
let cmd_type = tcx.mk_array(tcx.types.u16, cmd_utf16.len() as u64);
137-
let cmd_place = ecx.allocate(ecx.layout_of(cmd_type)?, MiriMemoryKind::Env.into());
137+
let cmd_place = ecx.allocate(ecx.layout_of(cmd_type)?, MiriMemoryKind::Machine.into());
138138
ecx.machine.cmd_line = Some(cmd_place.ptr);
139139
// Store the UTF-16 string. We just allocated so we know the bounds are fine.
140140
let char_size = Size::from_bytes(2);
@@ -147,7 +147,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
147147
};
148148

149149
// Return place (in static memory so that it does not count as leak).
150-
let ret_place = ecx.allocate(ecx.layout_of(tcx.types.isize)?, MiriMemoryKind::Env.into());
150+
let ret_place = ecx.allocate(ecx.layout_of(tcx.types.isize)?, MiriMemoryKind::Machine.into());
151151
// Call start function.
152152
ecx.call_function(
153153
start_instance,
@@ -158,7 +158,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
158158

159159
// Set the last_error to 0
160160
let errno_layout = ecx.layout_of(tcx.types.u32)?;
161-
let errno_place = ecx.allocate(errno_layout, MiriMemoryKind::Env.into());
161+
let errno_place = ecx.allocate(errno_layout, MiriMemoryKind::Machine.into());
162162
ecx.write_scalar(Scalar::from_u32(0), errno_place.into())?;
163163
ecx.machine.last_error = Some(errno_place);
164164

src/machine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ pub enum MiriMemoryKind {
4848
C,
4949
/// Windows `HeapAlloc` memory.
5050
WinHeap,
51-
/// Memory for env vars and args, errno and other parts of the machine-managed environment.
52-
Env,
51+
/// Memory for env vars and args, errno, extern statics and other parts of the machine-managed environment.
52+
Machine,
5353
/// Rust statics.
5454
Static,
5555
}
@@ -433,7 +433,7 @@ impl MayLeak for MiriMemoryKind {
433433
use self::MiriMemoryKind::*;
434434
match self {
435435
Rust | C | WinHeap => false,
436-
Env | Static => true,
436+
Machine | Static => true,
437437
}
438438
}
439439
}

src/shims/env.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn alloc_env_var_as_c_str<'mir, 'tcx>(
4040
let mut name_osstring = name.to_os_string();
4141
name_osstring.push("=");
4242
name_osstring.push(value);
43-
ecx.alloc_os_str_as_c_str(name_osstring.as_os_str(), MiriMemoryKind::Env.into())
43+
ecx.alloc_os_str_as_c_str(name_osstring.as_os_str(), MiriMemoryKind::Machine.into())
4444
}
4545

4646
impl<'mir, 'tcx> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
@@ -80,7 +80,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
8080
let var_ptr = alloc_env_var_as_c_str(&name, &value, &mut this);
8181
if let Some(var) = this.machine.env_vars.map.insert(name.to_owned(), var_ptr) {
8282
this.memory
83-
.deallocate(var, None, MiriMemoryKind::Env.into())?;
83+
.deallocate(var, None, MiriMemoryKind::Machine.into())?;
8484
}
8585
Ok(0)
8686
} else {
@@ -102,7 +102,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
102102
if let Some(old) = success {
103103
if let Some(var) = old {
104104
this.memory
105-
.deallocate(var, None, MiriMemoryKind::Env.into())?;
105+
.deallocate(var, None, MiriMemoryKind::Machine.into())?;
106106
}
107107
Ok(0)
108108
} else {

src/shims/panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
187187

188188
// First arg: Message.
189189
let msg = msg.description();
190-
let msg = this.allocate_str(msg, MiriMemoryKind::Env.into());
190+
let msg = this.allocate_str(msg, MiriMemoryKind::Machine.into());
191191

192192
// Call the lang item.
193193
let panic = this.tcx.lang_items().panic_fn().unwrap();

0 commit comments

Comments
 (0)