Add .clone() to fix singlepass.

This commit is contained in:
losfair 2019-07-30 22:25:37 +08:00
parent 0a7f95ee06
commit 283676af2b
2 changed files with 13 additions and 7 deletions

View File

@ -557,6 +557,7 @@ impl X64FunctionCode {
fsm.trappable_offsets.insert(
offset,
OffsetInfo {
end_offset: offset + 1,
activate_offset: offset,
diff_id: state_diff_id,
},
@ -1179,7 +1180,7 @@ impl X64FunctionCode {
let used_gprs = m.get_used_gprs();
for r in used_gprs.iter() {
a.emit_push(Size::S64, Location::GPR(*r));
let content = m.state.register_values[X64Register::GPR(*r).to_index().0];
let content = m.state.register_values[X64Register::GPR(*r).to_index().0].clone();
assert!(content != MachineValue::Undefined);
m.state.stack_values.push(content);
}
@ -1204,7 +1205,7 @@ impl X64FunctionCode {
);
}
for r in used_xmms.iter().rev() {
let content = m.state.register_values[X64Register::XMM(*r).to_index().0];
let content = m.state.register_values[X64Register::XMM(*r).to_index().0].clone();
assert!(content != MachineValue::Undefined);
m.state.stack_values.push(content);
}
@ -1244,7 +1245,8 @@ impl X64FunctionCode {
Location::Memory(_, _) => {
match *param {
Location::GPR(x) => {
let content = m.state.register_values[X64Register::GPR(x).to_index().0];
let content =
m.state.register_values[X64Register::GPR(x).to_index().0].clone();
// FIXME: There might be some corner cases (release -> emit_call_sysv -> acquire?) that cause this assertion to fail.
// Hopefully nothing would be incorrect at runtime.
@ -1252,7 +1254,8 @@ impl X64FunctionCode {
m.state.stack_values.push(content);
}
Location::XMM(x) => {
let content = m.state.register_values[X64Register::XMM(x).to_index().0];
let content =
m.state.register_values[X64Register::XMM(x).to_index().0].clone();
//assert!(content != MachineValue::Undefined);
m.state.stack_values.push(content);
}
@ -1335,6 +1338,7 @@ impl X64FunctionCode {
fsm.call_offsets.insert(
offset,
OffsetInfo {
end_offset: offset + 1,
activate_offset: offset,
diff_id: state_diff_id,
},
@ -1694,6 +1698,7 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
self.fsm.loop_offsets.insert(
a.get_offset().0,
OffsetInfo {
end_offset: a.get_offset().0 + 1,
activate_offset,
diff_id: state_diff_id,
},
@ -3958,6 +3963,7 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
self.fsm.loop_offsets.insert(
a.get_offset().0,
OffsetInfo {
end_offset: a.get_offset().0 + 1,
activate_offset,
diff_id: state_diff_id,
},

View File

@ -157,12 +157,12 @@ impl Machine {
};
if let Location::GPR(x) = loc {
self.used_gprs.insert(x);
self.state.register_values[X64Register::GPR(x).to_index().0] = *mv;
self.state.register_values[X64Register::GPR(x).to_index().0] = mv.clone();
} else if let Location::XMM(x) = loc {
self.used_xmms.insert(x);
self.state.register_values[X64Register::XMM(x).to_index().0] = *mv;
self.state.register_values[X64Register::XMM(x).to_index().0] = mv.clone();
} else {
self.state.stack_values.push(*mv);
self.state.stack_values.push(mv.clone());
}
self.state.wasm_stack.push(WasmAbstractValue::Runtime);
ret.push(loc);