Merge branch 'master' of github.com:wasmerio/wasmer into simd

This commit is contained in:
Nick Lewycky
2019-07-16 19:16:45 -07:00
56 changed files with 627 additions and 398 deletions

View File

@ -317,6 +317,7 @@ pub struct CodegenError {
struct CodegenConfig {
memory_bound_check_mode: MemoryBoundCheckMode,
enforce_stack_check: bool,
track_state: bool,
}
impl ModuleCodeGenerator<X64FunctionCode, X64ExecutionContext, CodegenError>
@ -366,7 +367,8 @@ impl ModuleCodeGenerator<X64FunctionCode, X64ExecutionContext, CodegenError>
begin_label_info.1 = Some(begin_offset);
let begin_label = begin_label_info.0;
let machine = Machine::new();
let mut machine = Machine::new();
machine.track_state = self.config.as_ref().unwrap().track_state;
dynasm!(
assembler
@ -532,6 +534,7 @@ impl ModuleCodeGenerator<X64FunctionCode, X64ExecutionContext, CodegenError>
self.config = Some(Arc::new(CodegenConfig {
memory_bound_check_mode: config.memory_bound_check_mode,
enforce_stack_check: config.enforce_stack_check,
track_state: config.track_state,
}));
Ok(())
}
@ -641,6 +644,13 @@ impl X64FunctionCode {
BothToGPR,
}
let mode = match (src, dst) {
(Location::GPR(_), Location::GPR(_))
if (op as *const u8 == Assembler::emit_imul as *const u8) =>
{
RelaxMode::Direct
}
_ if (op as *const u8 == Assembler::emit_imul as *const u8) => RelaxMode::BothToGPR,
(Location::Memory(_, _), Location::Memory(_, _)) => RelaxMode::SrcToGPR,
(Location::Imm64(_), Location::Imm64(_)) | (Location::Imm64(_), Location::Imm32(_)) => {
RelaxMode::BothToGPR
@ -653,7 +663,6 @@ impl X64FunctionCode {
RelaxMode::SrcToGPR
}
(_, Location::XMM(_)) => RelaxMode::SrcToGPR,
_ if (op as *const u8 == Assembler::emit_imul as *const u8) => RelaxMode::BothToGPR, // TODO: optimize this
_ => RelaxMode::Direct,
};
@ -1588,6 +1597,9 @@ impl X64FunctionCode {
fsm: &mut FunctionStateMap,
control_stack: &mut [ControlFrame],
) -> usize {
if !m.track_state {
return ::std::usize::MAX;
}
let last_frame = control_stack.last_mut().unwrap();
let mut diff = m.state.diff(&last_frame.state);
diff.last = Some(last_frame.state_diff_id);
@ -1763,7 +1775,7 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
.unwrap()
.insert(a.get_offset(), callback);
}
InternalEvent::FunctionBegin(_) | InternalEvent::FunctionEnd => {},
InternalEvent::FunctionBegin(_) | InternalEvent::FunctionEnd => {}
InternalEvent::GetInternal(idx) => {
let idx = idx as usize;
assert!(idx < INTERNALS_SIZE);
@ -1814,7 +1826,11 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
),
Location::GPR(tmp),
);
let loc = get_location_released(a, &mut self.machine, self.value_stack.pop().unwrap());
let loc = get_location_released(
a,
&mut self.machine,
self.value_stack.pop().unwrap(),
);
// Move internal into storage.
Self::emit_relaxed_binop(
@ -1826,8 +1842,7 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
Location::Memory(tmp, (idx * 8) as i32),
);
self.machine.release_temp_gpr(tmp);
}
//_ => unimplemented!(),
} //_ => unimplemented!(),
}
return Ok(());
}
@ -2405,7 +2420,14 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
loc_b,
);
a.emit_jmp(Condition::NotEqual, normal_path);
a.emit_mov(Size::S64, Location::Imm64(0), ret);
Self::emit_relaxed_binop(
a,
&mut self.machine,
Assembler::emit_mov,
Size::S64,
Location::Imm64(0),
ret,
);
a.emit_jmp(Condition::None, end);
a.emit_label(normal_path);
@ -4519,9 +4541,14 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
|a, m, addr| {
match ret {
Location::GPR(_) => {}
_ => {
a.emit_mov(Size::S64, Location::Imm64(0), ret);
Location::Memory(base, offset) => {
a.emit_mov(
Size::S32,
Location::Imm32(0),
Location::Memory(base, offset + 4),
); // clear upper bits
}
_ => unreachable!(),
}
Self::emit_relaxed_binop(
a,

View File

@ -13,6 +13,7 @@ pub struct Machine {
stack_offset: MachineStackOffset,
save_area_offset: Option<MachineStackOffset>,
pub state: MachineState,
pub(crate) track_state: bool,
}
impl Machine {
@ -23,6 +24,7 @@ impl Machine {
stack_offset: MachineStackOffset(0),
save_area_offset: None,
state: x64::new_machine_state(),
track_state: true,
}
}