1
0
mirror of https://github.com/fluencelabs/wasmer synced 2025-03-31 23:11:04 +00:00

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
lib/singlepass-backend/src

@ -557,6 +557,7 @@ impl X64FunctionCode {
fsm.trappable_offsets.insert( fsm.trappable_offsets.insert(
offset, offset,
OffsetInfo { OffsetInfo {
end_offset: offset + 1,
activate_offset: offset, activate_offset: offset,
diff_id: state_diff_id, diff_id: state_diff_id,
}, },
@ -1179,7 +1180,7 @@ impl X64FunctionCode {
let used_gprs = m.get_used_gprs(); let used_gprs = m.get_used_gprs();
for r in used_gprs.iter() { for r in used_gprs.iter() {
a.emit_push(Size::S64, Location::GPR(*r)); 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); assert!(content != MachineValue::Undefined);
m.state.stack_values.push(content); m.state.stack_values.push(content);
} }
@ -1204,7 +1205,7 @@ impl X64FunctionCode {
); );
} }
for r in used_xmms.iter().rev() { 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); assert!(content != MachineValue::Undefined);
m.state.stack_values.push(content); m.state.stack_values.push(content);
} }
@ -1244,7 +1245,8 @@ impl X64FunctionCode {
Location::Memory(_, _) => { Location::Memory(_, _) => {
match *param { match *param {
Location::GPR(x) => { 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. // 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. // Hopefully nothing would be incorrect at runtime.
@ -1252,7 +1254,8 @@ impl X64FunctionCode {
m.state.stack_values.push(content); m.state.stack_values.push(content);
} }
Location::XMM(x) => { 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); //assert!(content != MachineValue::Undefined);
m.state.stack_values.push(content); m.state.stack_values.push(content);
} }
@ -1335,6 +1338,7 @@ impl X64FunctionCode {
fsm.call_offsets.insert( fsm.call_offsets.insert(
offset, offset,
OffsetInfo { OffsetInfo {
end_offset: offset + 1,
activate_offset: offset, activate_offset: offset,
diff_id: state_diff_id, diff_id: state_diff_id,
}, },
@ -1694,6 +1698,7 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
self.fsm.loop_offsets.insert( self.fsm.loop_offsets.insert(
a.get_offset().0, a.get_offset().0,
OffsetInfo { OffsetInfo {
end_offset: a.get_offset().0 + 1,
activate_offset, activate_offset,
diff_id: state_diff_id, diff_id: state_diff_id,
}, },
@ -3958,6 +3963,7 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
self.fsm.loop_offsets.insert( self.fsm.loop_offsets.insert(
a.get_offset().0, a.get_offset().0,
OffsetInfo { OffsetInfo {
end_offset: a.get_offset().0 + 1,
activate_offset, activate_offset,
diff_id: state_diff_id, diff_id: state_diff_id,
}, },

@ -157,12 +157,12 @@ impl Machine {
}; };
if let Location::GPR(x) = loc { if let Location::GPR(x) = loc {
self.used_gprs.insert(x); 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 { } else if let Location::XMM(x) = loc {
self.used_xmms.insert(x); 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 { } else {
self.state.stack_values.push(*mv); self.state.stack_values.push(mv.clone());
} }
self.state.wasm_stack.push(WasmAbstractValue::Runtime); self.state.wasm_stack.push(WasmAbstractValue::Runtime);
ret.push(loc); ret.push(loc);