mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 05:08:19 +00:00
Some clippy cleanup.
This commit is contained in:
@@ -107,7 +107,6 @@ impl Memory for LinearMemory {
|
||||
/// of wasm pages.
|
||||
fn grow(&self, delta: Pages) -> Result<Pages, MemoryError> {
|
||||
// Optimization of memory.grow 0 calls.
|
||||
let delta: Pages = delta.into();
|
||||
let mut mmap = self.mmap.borrow_mut();
|
||||
if delta.0 == 0 {
|
||||
return Ok(mmap.size);
|
||||
|
||||
@@ -1290,12 +1290,12 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
}
|
||||
Operator::I8x16ExtractLaneS { lane } | Operator::I16x8ExtractLaneS { lane } => {
|
||||
let vector = pop1_with_bitcast(state, type_of(op), builder);
|
||||
let extracted = builder.ins().extractlane(vector, lane.clone());
|
||||
let extracted = builder.ins().extractlane(vector, *lane);
|
||||
state.push1(builder.ins().sextend(I32, extracted))
|
||||
}
|
||||
Operator::I8x16ExtractLaneU { lane } | Operator::I16x8ExtractLaneU { lane } => {
|
||||
let vector = pop1_with_bitcast(state, type_of(op), builder);
|
||||
let extracted = builder.ins().extractlane(vector, lane.clone());
|
||||
let extracted = builder.ins().extractlane(vector, *lane);
|
||||
state.push1(builder.ins().uextend(I32, extracted));
|
||||
// On x86, PEXTRB zeroes the upper bits of the destination register of extractlane so
|
||||
// uextend could be elided; for now, uextend is needed for Cranelift's type checks to
|
||||
@@ -1306,7 +1306,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
| Operator::F32x4ExtractLane { lane }
|
||||
| Operator::F64x2ExtractLane { lane } => {
|
||||
let vector = pop1_with_bitcast(state, type_of(op), builder);
|
||||
state.push1(builder.ins().extractlane(vector, lane.clone()))
|
||||
state.push1(builder.ins().extractlane(vector, *lane))
|
||||
}
|
||||
Operator::I8x16ReplaceLane { lane } | Operator::I16x8ReplaceLane { lane } => {
|
||||
let (vector, replacement) = state.pop2();
|
||||
|
||||
@@ -24,7 +24,7 @@ impl CraneliftUnwindInfo {
|
||||
/// main users of this function)
|
||||
pub fn maybe_into_to_windows_unwind(self) -> Option<CompiledFunctionUnwindInfo> {
|
||||
match self {
|
||||
CraneliftUnwindInfo::WindowsX64(unwind_info) => {
|
||||
Self::WindowsX64(unwind_info) => {
|
||||
Some(CompiledFunctionUnwindInfo::WindowsX64(unwind_info))
|
||||
}
|
||||
_ => None,
|
||||
|
||||
@@ -113,7 +113,7 @@ impl FuncTrampoline {
|
||||
if eh_frame_section_indices.len() != custom_sections.len() {
|
||||
all_sections_are_eh_sections = false;
|
||||
} else {
|
||||
let mut eh_frame_section_indices = eh_frame_section_indices.clone();
|
||||
let mut eh_frame_section_indices = eh_frame_section_indices;
|
||||
eh_frame_section_indices.sort_unstable();
|
||||
for (idx, section_idx) in eh_frame_section_indices.iter().enumerate() {
|
||||
if idx as u32 != section_idx.as_u32() {
|
||||
@@ -215,7 +215,7 @@ impl FuncTrampoline {
|
||||
if eh_frame_section_indices.len() != custom_sections.len() {
|
||||
all_sections_are_eh_sections = false;
|
||||
} else {
|
||||
let mut eh_frame_section_indices = eh_frame_section_indices.clone();
|
||||
let mut eh_frame_section_indices = eh_frame_section_indices;
|
||||
eh_frame_section_indices.sort_unstable();
|
||||
for (idx, section_idx) in eh_frame_section_indices.iter().enumerate() {
|
||||
if idx as u32 != section_idx.as_u32() {
|
||||
|
||||
@@ -408,7 +408,7 @@ impl<'a> FuncGen<'a> {
|
||||
let inner = |m: &mut Machine, a: &mut Assembler, src: Location| match dst {
|
||||
Location::Imm32(_) | Location::Imm64(_) => {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_relaxed_zx_sx dst Imm: unreachable code"),
|
||||
message: "emit_relaxed_zx_sx dst Imm: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
Location::Memory(_, _) => {
|
||||
@@ -425,7 +425,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_relaxed_zx_sx dst: unreachable code"),
|
||||
message: "emit_relaxed_zx_sx dst: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -446,7 +446,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_relaxed_zx_sx src: unreachable code"),
|
||||
message: "emit_relaxed_zx_sx src: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -582,7 +582,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_relaxed_avx_base src1: unreachable code"),
|
||||
message: "emit_relaxed_avx_base src1: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -611,7 +611,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_relaxed_avx_base src2: unreachable code"),
|
||||
message: "emit_relaxed_avx_base src2: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -626,7 +626,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_relaxed_avx_base dst: unreachable code"),
|
||||
message: "emit_relaxed_avx_base dst: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -701,7 +701,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_cmpop_i32_dynamic_b ret: unreachable code"),
|
||||
message: "emit_cmpop_i32_dynamic_b ret: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -748,7 +748,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_cmpop_i64_dynamic_b ret: unreachable code"),
|
||||
message: "emit_cmpop_i64_dynamic_b ret: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -808,7 +808,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_xcnt_i32 loc: unreachable code"),
|
||||
message: "emit_xcnt_i32 loc: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -861,7 +861,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_xcnt_i64 loc: unreachable code"),
|
||||
message: "emit_xcnt_i64 loc: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -965,7 +965,7 @@ impl<'a> FuncGen<'a> {
|
||||
self.machine.state.register_values[X64Register::GPR(*r).to_index().0].clone();
|
||||
if content == MachineValue::Undefined {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_call_sysv: Undefined used_gprs content"),
|
||||
message: "emit_call_sysv: Undefined used_gprs content".to_string(),
|
||||
});
|
||||
}
|
||||
self.machine.state.stack_values.push(content);
|
||||
@@ -992,7 +992,7 @@ impl<'a> FuncGen<'a> {
|
||||
self.machine.state.register_values[X64Register::XMM(*r).to_index().0].clone();
|
||||
if content == MachineValue::Undefined {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_call_sysv: Undefined used_xmms content"),
|
||||
message: "emit_call_sysv: Undefined used_xmms content".to_string(),
|
||||
});
|
||||
}
|
||||
self.machine.state.stack_values.push(content);
|
||||
@@ -1003,12 +1003,8 @@ impl<'a> FuncGen<'a> {
|
||||
|
||||
// Calculate stack offset.
|
||||
for (i, _param) in params.iter().enumerate() {
|
||||
let loc = Machine::get_param_location(1 + i);
|
||||
match loc {
|
||||
Location::Memory(_, _) => {
|
||||
stack_offset += 8;
|
||||
}
|
||||
_ => {}
|
||||
if let Location::Memory(_, _) = Machine::get_param_location(1 + i) {
|
||||
stack_offset += 8;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1060,7 +1056,8 @@ impl<'a> FuncGen<'a> {
|
||||
Location::Memory(reg, offset) => {
|
||||
if reg != GPR::RBP {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_call_sysv loc param: unreachable code"),
|
||||
message: "emit_call_sysv loc param: unreachable code"
|
||||
.to_string(),
|
||||
});
|
||||
}
|
||||
self.machine
|
||||
@@ -1110,7 +1107,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_call_sysv loc: unreachable code"),
|
||||
message: "emit_call_sysv loc: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1135,7 +1132,7 @@ impl<'a> FuncGen<'a> {
|
||||
|
||||
if (self.machine.state.stack_values.len() % 2) != 1 {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_call_sysv: explicit shadow takes one slot"),
|
||||
message: "emit_call_sysv: explicit shadow takes one slot".to_string(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1169,7 +1166,7 @@ impl<'a> FuncGen<'a> {
|
||||
);
|
||||
if (stack_offset % 8) != 0 {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_call_sysv: Bad restoring stack alignement"),
|
||||
message: "emit_call_sysv: Bad restoring stack alignement".to_string(),
|
||||
});
|
||||
}
|
||||
for _ in 0..stack_offset / 8 {
|
||||
@@ -1178,7 +1175,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
|
||||
// Restore XMMs.
|
||||
if used_xmms.len() > 0 {
|
||||
if !used_xmms.is_empty() {
|
||||
for (i, r) in used_xmms.iter().enumerate() {
|
||||
self.assembler.emit_mov(
|
||||
Size::S64,
|
||||
@@ -1204,7 +1201,7 @@ impl<'a> FuncGen<'a> {
|
||||
|
||||
if self.machine.state.stack_values.pop().unwrap() != MachineValue::ExplicitShadow {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_call_sysv: Popped value is not ExplicitShadow"),
|
||||
message: "emit_call_sysv: Popped value is not ExplicitShadow".to_string(),
|
||||
});
|
||||
}
|
||||
Ok(())
|
||||
@@ -1328,7 +1325,7 @@ impl<'a> FuncGen<'a> {
|
||||
3 => 8,
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_memory_op align: unreachable value"),
|
||||
message: "emit_memory_op align: unreachable value".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -1369,7 +1366,7 @@ impl<'a> FuncGen<'a> {
|
||||
) -> Result<(), CodegenError> {
|
||||
if memory_sz > stack_sz {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_compare_and_swap: memory size > stac size"),
|
||||
message: "emit_compare_and_swap: memory size > stack size".to_string(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1771,7 +1768,7 @@ impl<'a> FuncGen<'a> {
|
||||
|
||||
if self.machine.state.wasm_inst_offset != std::usize::MAX {
|
||||
return Err(CodegenError {
|
||||
message: format!("emit_head: wasm_inst_offset not std::usize::MAX"),
|
||||
message: "emit_head: wasm_inst_offset not std::usize::MAX".to_string(),
|
||||
});
|
||||
}
|
||||
Ok(())
|
||||
@@ -1840,7 +1837,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
|
||||
pub fn has_control_frames(&self) -> bool {
|
||||
self.control_stack.len() > 0
|
||||
!self.control_stack.is_empty()
|
||||
}
|
||||
|
||||
pub fn feed_operator(&mut self, op: Operator) -> Result<(), CodegenError> {
|
||||
@@ -2158,7 +2155,7 @@ impl<'a> FuncGen<'a> {
|
||||
Location::GPR(reg) => reg,
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("I32Clz src: unreachable code"),
|
||||
message: "I32Clz src: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -2175,7 +2172,7 @@ impl<'a> FuncGen<'a> {
|
||||
Location::GPR(reg) => reg,
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("I32Clz dst: unreachable code"),
|
||||
message: "I32Clz dst: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -2209,12 +2206,9 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
match ret {
|
||||
Location::Memory(_, _) => {
|
||||
self.assembler.emit_mov(Size::S32, Location::GPR(dst), ret);
|
||||
self.machine.release_temp_gpr(dst);
|
||||
}
|
||||
_ => {}
|
||||
if let Location::Memory(_, _) = ret {
|
||||
self.assembler.emit_mov(Size::S32, Location::GPR(dst), ret);
|
||||
self.machine.release_temp_gpr(dst);
|
||||
};
|
||||
}
|
||||
Operator::I32Ctz => {
|
||||
@@ -2228,7 +2222,7 @@ impl<'a> FuncGen<'a> {
|
||||
Location::GPR(reg) => reg,
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("I32Ctz src: unreachable code"),
|
||||
message: "I32Ctz src: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -2245,7 +2239,7 @@ impl<'a> FuncGen<'a> {
|
||||
Location::GPR(reg) => reg,
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("I32Ctz dst: unreachable code"),
|
||||
message: "I32Ctz dst: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -2277,12 +2271,9 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
match ret {
|
||||
Location::Memory(_, _) => {
|
||||
self.assembler.emit_mov(Size::S32, Location::GPR(dst), ret);
|
||||
self.machine.release_temp_gpr(dst);
|
||||
}
|
||||
_ => {}
|
||||
if let Location::Memory(_, _) = ret {
|
||||
self.assembler.emit_mov(Size::S32, Location::GPR(dst), ret);
|
||||
self.machine.release_temp_gpr(dst);
|
||||
};
|
||||
}
|
||||
Operator::I32Popcnt => self.emit_xcnt_i32(Assembler::emit_popcnt)?,
|
||||
@@ -2403,7 +2394,7 @@ impl<'a> FuncGen<'a> {
|
||||
Location::GPR(reg) => reg,
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("I64Clz src: unreachable code"),
|
||||
message: "I64Clz src: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -2420,7 +2411,7 @@ impl<'a> FuncGen<'a> {
|
||||
Location::GPR(reg) => reg,
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("I64Clz dst: unreachable code"),
|
||||
message: "I64Clz dst: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -2454,12 +2445,9 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
match ret {
|
||||
Location::Memory(_, _) => {
|
||||
self.assembler.emit_mov(Size::S64, Location::GPR(dst), ret);
|
||||
self.machine.release_temp_gpr(dst);
|
||||
}
|
||||
_ => {}
|
||||
if let Location::Memory(_, _) = ret {
|
||||
self.assembler.emit_mov(Size::S64, Location::GPR(dst), ret);
|
||||
self.machine.release_temp_gpr(dst);
|
||||
};
|
||||
}
|
||||
Operator::I64Ctz => {
|
||||
@@ -2473,7 +2461,7 @@ impl<'a> FuncGen<'a> {
|
||||
Location::GPR(reg) => reg,
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("I64Ctz src: unreachable code"),
|
||||
message: "I64Ctz src: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -2490,7 +2478,7 @@ impl<'a> FuncGen<'a> {
|
||||
Location::GPR(reg) => reg,
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("I64Ctz dst: unreachable code"),
|
||||
message: "I64Ctz dst: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -2522,12 +2510,9 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
match ret {
|
||||
Location::Memory(_, _) => {
|
||||
self.assembler.emit_mov(Size::S64, Location::GPR(dst), ret);
|
||||
self.machine.release_temp_gpr(dst);
|
||||
}
|
||||
_ => {}
|
||||
if let Location::Memory(_, _) = ret {
|
||||
self.assembler.emit_mov(Size::S64, Location::GPR(dst), ret);
|
||||
self.machine.release_temp_gpr(dst);
|
||||
};
|
||||
}
|
||||
Operator::I64Popcnt => self.emit_xcnt_i64(Assembler::emit_popcnt)?,
|
||||
@@ -2719,7 +2704,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("F32Max src1: unreachable code"),
|
||||
message: "F32Max src1: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -2752,7 +2737,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("F32Max src2: unreachable code"),
|
||||
message: "F32Max src2: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -2809,7 +2794,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("F32Max ret: unreachable code"),
|
||||
message: "F32Max ret: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -2863,7 +2848,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("F32Min src1: unreachable code"),
|
||||
message: "F32Min src1: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -2896,7 +2881,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("F32Min src2: unreachable code"),
|
||||
message: "F32Min src2: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -2962,7 +2947,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("F32Min ret: unreachable code"),
|
||||
message: "F32Min ret: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -3209,7 +3194,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("F64Max src1: unreachable code"),
|
||||
message: "F64Max src1: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -3242,7 +3227,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("F64Max src2: unreachable code"),
|
||||
message: "F64Max src2: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -3299,7 +3284,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("F64Max ret: unreachable code"),
|
||||
message: "F64Max ret: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -3354,7 +3339,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("F64Min src1: unreachable code"),
|
||||
message: "F64Min src1: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -3387,7 +3372,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("F64Min src2: unreachable code"),
|
||||
message: "F64Min src2: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -3453,7 +3438,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("F64Min ret: unreachable code"),
|
||||
message: "F64Min ret: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -5185,13 +5170,13 @@ impl<'a> FuncGen<'a> {
|
||||
|this| {
|
||||
this.assembler.emit_call_location(Location::GPR(GPR::RAX));
|
||||
},
|
||||
params.iter().map(|x| *x),
|
||||
params.iter().copied(),
|
||||
)?;
|
||||
|
||||
self.machine
|
||||
.release_locations_only_stack(&mut self.assembler, ¶ms);
|
||||
|
||||
if return_types.len() > 0 {
|
||||
if !return_types.is_empty() {
|
||||
let ret = self.machine.acquire_locations(
|
||||
&mut self.assembler,
|
||||
&[(
|
||||
@@ -5215,7 +5200,7 @@ impl<'a> FuncGen<'a> {
|
||||
Operator::CallIndirect { index, table_index } => {
|
||||
if table_index != 0 {
|
||||
return Err(CodegenError {
|
||||
message: format!("CallIndirect: table_index is not 0"),
|
||||
message: "CallIndirect: table_index is not 0".to_string(),
|
||||
});
|
||||
}
|
||||
let table_index = TableIndex::new(table_index as _);
|
||||
@@ -5385,13 +5370,13 @@ impl<'a> FuncGen<'a> {
|
||||
));
|
||||
}
|
||||
},
|
||||
params.iter().map(|x| *x),
|
||||
params.iter().copied(),
|
||||
)?;
|
||||
|
||||
self.machine
|
||||
.release_locations_only_stack(&mut self.assembler, ¶ms);
|
||||
|
||||
if return_types.len() > 0 {
|
||||
if !return_types.is_empty() {
|
||||
let ret = self.machine.acquire_locations(
|
||||
&mut self.assembler,
|
||||
&[(
|
||||
@@ -5427,7 +5412,7 @@ impl<'a> FuncGen<'a> {
|
||||
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("If: multi-value returns not yet implemented"),
|
||||
message: "If: multi-value returns not yet implemented".to_string(),
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -5443,7 +5428,7 @@ impl<'a> FuncGen<'a> {
|
||||
Operator::Else => {
|
||||
let frame = self.control_stack.last_mut().unwrap();
|
||||
|
||||
if !was_unreachable && frame.returns.len() > 0 {
|
||||
if !was_unreachable && !frame.returns.is_empty() {
|
||||
let first_return = frame.returns[0];
|
||||
let loc = *self.value_stack.last().unwrap();
|
||||
if first_return.is_float() {
|
||||
@@ -5495,7 +5480,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("Else: frame.if_else unreachable code"),
|
||||
message: "Else: frame.if_else unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -5568,7 +5553,8 @@ impl<'a> FuncGen<'a> {
|
||||
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("Block: multi-value returns not yet implemented"),
|
||||
message: "Block: multi-value returns not yet implemented"
|
||||
.to_string(),
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -5596,7 +5582,7 @@ impl<'a> FuncGen<'a> {
|
||||
let _activate_offset = self.assembler.get_offset().0;
|
||||
|
||||
self.control_stack.push(ControlFrame {
|
||||
label: label,
|
||||
label,
|
||||
loop_like: true,
|
||||
if_else: IfElseState::None,
|
||||
returns: match ty {
|
||||
@@ -5604,7 +5590,8 @@ impl<'a> FuncGen<'a> {
|
||||
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("Loop: multi-value returns not yet implemented"),
|
||||
message: "Loop: multi-value returns not yet implemented"
|
||||
.to_string(),
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -5625,7 +5612,7 @@ impl<'a> FuncGen<'a> {
|
||||
Location::Memory(
|
||||
Machine::get_vmctx_reg(),
|
||||
self.vmoffsets.vmctx_builtin_function(
|
||||
if let Some(_) = self.module.local_memory_index(memory_index) {
|
||||
if self.module.local_memory_index(memory_index).is_some() {
|
||||
VMBuiltinFunctionIndex::get_memory32_size_index()
|
||||
} else {
|
||||
VMBuiltinFunctionIndex::get_imported_memory32_size_index()
|
||||
@@ -5667,7 +5654,7 @@ impl<'a> FuncGen<'a> {
|
||||
Location::Memory(
|
||||
Machine::get_vmctx_reg(),
|
||||
self.vmoffsets.vmctx_builtin_function(
|
||||
if let Some(_) = self.module.local_memory_index(memory_index) {
|
||||
if self.module.local_memory_index(memory_index).is_some() {
|
||||
VMBuiltinFunctionIndex::get_memory32_grow_index()
|
||||
} else {
|
||||
VMBuiltinFunctionIndex::get_imported_memory32_grow_index()
|
||||
@@ -6033,7 +6020,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("I64Load32U ret: unreachable code"),
|
||||
message: "I64Load32U ret: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -6156,10 +6143,10 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
Operator::Return => {
|
||||
let frame = &self.control_stack[0];
|
||||
if frame.returns.len() > 0 {
|
||||
if !frame.returns.is_empty() {
|
||||
if frame.returns.len() != 1 {
|
||||
return Err(CodegenError {
|
||||
message: format!("Return: incorrect frame.returns"),
|
||||
message: "Return: incorrect frame.returns".to_string(),
|
||||
});
|
||||
}
|
||||
let first_return = frame.returns[0];
|
||||
@@ -6206,10 +6193,10 @@ impl<'a> FuncGen<'a> {
|
||||
Operator::Br { relative_depth } => {
|
||||
let frame =
|
||||
&self.control_stack[self.control_stack.len() - 1 - (relative_depth as usize)];
|
||||
if !frame.loop_like && frame.returns.len() > 0 {
|
||||
if !frame.loop_like && !frame.returns.is_empty() {
|
||||
if frame.returns.len() != 1 {
|
||||
return Err(CodegenError {
|
||||
message: format!("Br: incorrect frame.returns"),
|
||||
message: "Br: incorrect frame.returns".to_string(),
|
||||
});
|
||||
}
|
||||
let first_return = frame.returns[0];
|
||||
@@ -6260,10 +6247,10 @@ impl<'a> FuncGen<'a> {
|
||||
|
||||
let frame =
|
||||
&self.control_stack[self.control_stack.len() - 1 - (relative_depth as usize)];
|
||||
if !frame.loop_like && frame.returns.len() > 0 {
|
||||
if !frame.loop_like && !frame.returns.is_empty() {
|
||||
if frame.returns.len() != 1 {
|
||||
return Err(CodegenError {
|
||||
message: format!("BrIf: incorrect frame.returns"),
|
||||
message: "BrIf: incorrect frame.returns".to_string(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6343,7 +6330,7 @@ impl<'a> FuncGen<'a> {
|
||||
table.push(label);
|
||||
let frame =
|
||||
&self.control_stack[self.control_stack.len() - 1 - (*target as usize)];
|
||||
if !frame.loop_like && frame.returns.len() > 0 {
|
||||
if !frame.loop_like && !frame.returns.is_empty() {
|
||||
if frame.returns.len() != 1 {
|
||||
return Err(CodegenError {
|
||||
message: format!(
|
||||
@@ -6395,10 +6382,10 @@ impl<'a> FuncGen<'a> {
|
||||
{
|
||||
let frame = &self.control_stack
|
||||
[self.control_stack.len() - 1 - (default_target as usize)];
|
||||
if !frame.loop_like && frame.returns.len() > 0 {
|
||||
if !frame.loop_like && !frame.returns.is_empty() {
|
||||
if frame.returns.len() != 1 {
|
||||
return Err(CodegenError {
|
||||
message: format!("BrTable: incorrect frame.returns"),
|
||||
message: "BrTable: incorrect frame.returns".to_string(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6457,7 +6444,7 @@ impl<'a> FuncGen<'a> {
|
||||
Operator::End => {
|
||||
let frame = self.control_stack.pop().unwrap();
|
||||
|
||||
if !was_unreachable && frame.returns.len() > 0 {
|
||||
if !was_unreachable && !frame.returns.is_empty() {
|
||||
let loc = *self.value_stack.last().unwrap();
|
||||
if frame.returns[0].is_float() {
|
||||
let fp = self.fp_stack.peek1()?;
|
||||
@@ -6492,7 +6479,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
if self.control_stack.len() == 0 {
|
||||
if self.control_stack.is_empty() {
|
||||
self.assembler.emit_label(frame.label);
|
||||
self.machine
|
||||
.finalize_locals(&mut self.assembler, &self.locals);
|
||||
@@ -6530,10 +6517,10 @@ impl<'a> FuncGen<'a> {
|
||||
self.assembler.emit_label(label);
|
||||
}
|
||||
|
||||
if frame.returns.len() > 0 {
|
||||
if !frame.returns.is_empty() {
|
||||
if frame.returns.len() != 1 {
|
||||
return Err(CodegenError {
|
||||
message: format!("End: incorrect frame.returns"),
|
||||
message: "End: incorrect frame.returns".to_string(),
|
||||
});
|
||||
}
|
||||
let loc = self.machine.acquire_locations(
|
||||
@@ -6745,7 +6732,7 @@ impl<'a> FuncGen<'a> {
|
||||
}
|
||||
_ => {
|
||||
return Err(CodegenError {
|
||||
message: format!("I64AtomicLoad32U ret: unreachable code"),
|
||||
message: "I64AtomicLoad32U ret: unreachable code".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -8260,12 +8247,8 @@ pub fn gen_std_trampoline(sig: &FunctionType) -> FunctionBody {
|
||||
// Calculate stack offset.
|
||||
let mut stack_offset: u32 = 0;
|
||||
for (i, _param) in sig.params().iter().enumerate() {
|
||||
let loc = Machine::get_param_location(1 + i);
|
||||
match loc {
|
||||
Location::Memory(_, _) => {
|
||||
stack_offset += 8;
|
||||
}
|
||||
_ => {}
|
||||
if let Location::Memory(_, _) = Machine::get_param_location(1 + i) {
|
||||
stack_offset += 8;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8336,7 +8319,7 @@ pub fn gen_std_trampoline(sig: &FunctionType) -> FunctionBody {
|
||||
);
|
||||
|
||||
// Write return value.
|
||||
if sig.results().len() > 0 {
|
||||
if !sig.results().is_empty() {
|
||||
a.emit_mov(
|
||||
Size::S64,
|
||||
Location::GPR(GPR::RAX),
|
||||
@@ -8372,7 +8355,7 @@ pub fn gen_std_dynamic_import_trampoline(
|
||||
);
|
||||
|
||||
// Copy arguments.
|
||||
if sig.params().len() > 0 {
|
||||
if !sig.params().is_empty() {
|
||||
let mut argalloc = ArgumentRegisterAllocator::default();
|
||||
argalloc.next(Type::I64).unwrap(); // skip VMContext
|
||||
|
||||
@@ -8424,7 +8407,7 @@ pub fn gen_std_dynamic_import_trampoline(
|
||||
a.emit_call_location(Location::GPR(GPR::RAX));
|
||||
|
||||
// Fetch return value.
|
||||
if sig.results().len() > 0 {
|
||||
if !sig.results().is_empty() {
|
||||
assert_eq!(sig.results().len(), 1);
|
||||
a.emit_mov(
|
||||
Size::S64,
|
||||
@@ -8468,8 +8451,7 @@ pub fn gen_import_call_trampoline(
|
||||
if sig
|
||||
.params()
|
||||
.iter()
|
||||
.find(|&&x| x == Type::F32 || x == Type::F64)
|
||||
.is_some()
|
||||
.any(|&x| x == Type::F32 || x == Type::F64)
|
||||
{
|
||||
let mut param_locations: Vec<Location> = vec![];
|
||||
|
||||
@@ -8491,8 +8473,7 @@ pub fn gen_import_call_trampoline(
|
||||
for i in 0..sig.params().len() {
|
||||
let loc = match i {
|
||||
0..=4 => {
|
||||
static PARAM_REGS: &'static [GPR] =
|
||||
&[GPR::RSI, GPR::RDX, GPR::RCX, GPR::R8, GPR::R9];
|
||||
static PARAM_REGS: &[GPR] = &[GPR::RSI, GPR::RDX, GPR::RCX, GPR::R8, GPR::R9];
|
||||
let loc = Location::Memory(GPR::RSP, (i * 8) as i32);
|
||||
a.emit_mov(Size::S64, Location::GPR(PARAM_REGS[i]), loc);
|
||||
loc
|
||||
|
||||
@@ -161,7 +161,7 @@ impl MachineState {
|
||||
.enumerate()
|
||||
.find(|&(_, (a, b))| a != b)
|
||||
.map(|x| x.0)
|
||||
.unwrap_or(old.stack_values.len().min(self.stack_values.len()));
|
||||
.unwrap_or_else(|| old.stack_values.len().min(self.stack_values.len()));
|
||||
assert_eq!(self.register_values.len(), old.register_values.len());
|
||||
let reg_diff: Vec<_> = self
|
||||
.register_values
|
||||
@@ -196,7 +196,7 @@ impl MachineState {
|
||||
.enumerate()
|
||||
.find(|&(_, (a, b))| a != b)
|
||||
.map(|x| x.0)
|
||||
.unwrap_or(old.wasm_stack.len().min(self.wasm_stack.len()));
|
||||
.unwrap_or_else(|| old.wasm_stack.len().min(self.wasm_stack.len()));
|
||||
MachineStateDiff {
|
||||
last: None,
|
||||
stack_push: self.stack_values[first_diff_stack_depth..].to_vec(),
|
||||
|
||||
@@ -702,12 +702,9 @@ impl Emitter for Assembler {
|
||||
|
||||
fn emit_mov(&mut self, sz: Size, src: Location, dst: Location) {
|
||||
// fast path
|
||||
match (src, dst) {
|
||||
(Location::Imm32(0), Location::GPR(x)) => {
|
||||
dynasm!(self ; xor Rd(x as u8), Rd(x as u8));
|
||||
return;
|
||||
}
|
||||
_ => {}
|
||||
if let (Location::Imm32(0), Location::GPR(x)) = (src, dst) {
|
||||
dynasm!(self ; xor Rd(x as u8), Rd(x as u8));
|
||||
return;
|
||||
}
|
||||
|
||||
binop_all_nofp!(mov, self, sz, src, dst, {
|
||||
|
||||
@@ -50,7 +50,7 @@ impl Machine {
|
||||
/// This method does not mark the register as used.
|
||||
pub fn pick_gpr(&self) -> Option<GPR> {
|
||||
use GPR::*;
|
||||
static REGS: &'static [GPR] = &[RSI, RDI, R8, R9, R10, R11];
|
||||
static REGS: &[GPR] = &[RSI, RDI, R8, R9, R10, R11];
|
||||
for r in REGS {
|
||||
if !self.used_gprs.contains(r) {
|
||||
return Some(*r);
|
||||
@@ -64,7 +64,7 @@ impl Machine {
|
||||
/// This method does not mark the register as used.
|
||||
pub fn pick_temp_gpr(&self) -> Option<GPR> {
|
||||
use GPR::*;
|
||||
static REGS: &'static [GPR] = &[RAX, RCX, RDX];
|
||||
static REGS: &[GPR] = &[RAX, RCX, RDX];
|
||||
for r in REGS {
|
||||
if !self.used_gprs.contains(r) {
|
||||
return Some(*r);
|
||||
@@ -99,7 +99,7 @@ impl Machine {
|
||||
/// This method does not mark the register as used.
|
||||
pub fn pick_xmm(&self) -> Option<XMM> {
|
||||
use XMM::*;
|
||||
static REGS: &'static [XMM] = &[XMM3, XMM4, XMM5, XMM6, XMM7];
|
||||
static REGS: &[XMM] = &[XMM3, XMM4, XMM5, XMM6, XMM7];
|
||||
for r in REGS {
|
||||
if !self.used_xmms.contains(r) {
|
||||
return Some(*r);
|
||||
@@ -113,7 +113,7 @@ impl Machine {
|
||||
/// This method does not mark the register as used.
|
||||
pub fn pick_temp_xmm(&self) -> Option<XMM> {
|
||||
use XMM::*;
|
||||
static REGS: &'static [XMM] = &[XMM0, XMM1, XMM2];
|
||||
static REGS: &[XMM] = &[XMM0, XMM1, XMM2];
|
||||
for r in REGS {
|
||||
if !self.used_xmms.contains(r) {
|
||||
return Some(*r);
|
||||
@@ -260,20 +260,17 @@ impl Machine {
|
||||
let mut delta_stack_offset: usize = 0;
|
||||
|
||||
for loc in locs.iter().rev() {
|
||||
match *loc {
|
||||
Location::Memory(GPR::RBP, x) => {
|
||||
if x >= 0 {
|
||||
unreachable!();
|
||||
}
|
||||
let offset = (-x) as usize;
|
||||
if offset != self.stack_offset.0 {
|
||||
unreachable!();
|
||||
}
|
||||
self.stack_offset.0 -= 8;
|
||||
delta_stack_offset += 8;
|
||||
self.state.stack_values.pop().unwrap();
|
||||
if let Location::Memory(GPR::RBP, x) = *loc {
|
||||
if x >= 0 {
|
||||
unreachable!();
|
||||
}
|
||||
_ => {}
|
||||
let offset = (-x) as usize;
|
||||
if offset != self.stack_offset.0 {
|
||||
unreachable!();
|
||||
}
|
||||
self.stack_offset.0 -= 8;
|
||||
delta_stack_offset += 8;
|
||||
self.state.stack_values.pop().unwrap();
|
||||
}
|
||||
// Wasm state popping is deferred to `release_locations_only_osr_state`.
|
||||
}
|
||||
@@ -302,19 +299,16 @@ impl Machine {
|
||||
let mut stack_offset = self.stack_offset.0;
|
||||
|
||||
for loc in locs.iter().rev() {
|
||||
match *loc {
|
||||
Location::Memory(GPR::RBP, x) => {
|
||||
if x >= 0 {
|
||||
unreachable!();
|
||||
}
|
||||
let offset = (-x) as usize;
|
||||
if offset != stack_offset {
|
||||
unreachable!();
|
||||
}
|
||||
stack_offset -= 8;
|
||||
delta_stack_offset += 8;
|
||||
if let Location::Memory(GPR::RBP, x) = *loc {
|
||||
if x >= 0 {
|
||||
unreachable!();
|
||||
}
|
||||
_ => {}
|
||||
let offset = (-x) as usize;
|
||||
if offset != stack_offset {
|
||||
unreachable!();
|
||||
}
|
||||
stack_offset -= 8;
|
||||
delta_stack_offset += 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,7 @@ use wasmparser::{BinaryReader, Operator, Result as WpResult, Type};
|
||||
/// A shared builder for function middlewares.
|
||||
pub trait FunctionMiddlewareGenerator: Debug + Send + Sync {
|
||||
/// Generates a `FunctionMiddleware` for a given function.
|
||||
fn generate<'a>(&self, local_function_index: LocalFunctionIndex)
|
||||
-> Box<dyn FunctionMiddleware>;
|
||||
fn generate(&self, local_function_index: LocalFunctionIndex) -> Box<dyn FunctionMiddleware>;
|
||||
}
|
||||
|
||||
/// A function middleware specialized for a single function.
|
||||
|
||||
@@ -61,27 +61,24 @@ pub fn parse_type_section(
|
||||
environ.reserve_signatures(count)?;
|
||||
|
||||
for entry in types {
|
||||
match entry.map_err(to_wasm_error)? {
|
||||
WPFunctionType { params, returns } => {
|
||||
let sig_params: Vec<Type> = params
|
||||
.iter()
|
||||
.map(|ty| {
|
||||
wptype_to_type(*ty)
|
||||
.expect("only numeric types are supported in function signatures")
|
||||
})
|
||||
.collect();
|
||||
let sig_returns: Vec<Type> = returns
|
||||
.iter()
|
||||
.map(|ty| {
|
||||
wptype_to_type(*ty)
|
||||
.expect("only numeric types are supported in function signatures")
|
||||
})
|
||||
.collect();
|
||||
let sig = FunctionType::new(sig_params, sig_returns);
|
||||
environ.declare_signature(sig)?;
|
||||
module_translation_state.wasm_types.push((params, returns));
|
||||
}
|
||||
}
|
||||
let WPFunctionType { params, returns } = entry.map_err(to_wasm_error)?;
|
||||
let sig_params: Vec<Type> = params
|
||||
.iter()
|
||||
.map(|ty| {
|
||||
wptype_to_type(*ty)
|
||||
.expect("only numeric types are supported in function signatures")
|
||||
})
|
||||
.collect();
|
||||
let sig_returns: Vec<Type> = returns
|
||||
.iter()
|
||||
.map(|ty| {
|
||||
wptype_to_type(*ty)
|
||||
.expect("only numeric types are supported in function signatures")
|
||||
})
|
||||
.collect();
|
||||
let sig = FunctionType::new(sig_params, sig_returns);
|
||||
environ.declare_signature(sig)?;
|
||||
module_translation_state.wasm_types.push((params, returns));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
4
lib/emscripten/src/env/unix/mod.rs
vendored
4
lib/emscripten/src/env/unix/mod.rs
vendored
@@ -263,7 +263,7 @@ pub fn _getaddrinfo(
|
||||
.get_mut();
|
||||
|
||||
guest_sockaddr.sa_family = (*host_sockaddr_ptr).sa_family as i16;
|
||||
guest_sockaddr.sa_data = (*host_sockaddr_ptr).sa_data.clone();
|
||||
guest_sockaddr.sa_data = (*host_sockaddr_ptr).sa_data;
|
||||
guest_sockaddr_ptr
|
||||
};
|
||||
|
||||
@@ -308,7 +308,7 @@ pub fn _getaddrinfo(
|
||||
}
|
||||
// this frees all connected nodes on the linked list
|
||||
freeaddrinfo(out_ptr);
|
||||
head_of_list.unwrap_or(WasmPtr::new(0))
|
||||
head_of_list.unwrap_or_else(|| WasmPtr::new(0))
|
||||
};
|
||||
|
||||
res_val_ptr.deref(ctx.memory(0)).unwrap().set(head_of_list);
|
||||
|
||||
@@ -31,7 +31,7 @@ pub fn sigdelset(ctx: &mut EmEnv, set: i32, signum: i32) -> i32 {
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let ptr = emscripten_memory_pointer!(memory, set) as *mut i32;
|
||||
|
||||
unsafe { *ptr = *ptr & !(1 << (signum - 1)) }
|
||||
unsafe { *ptr &= !(1 << (signum - 1)) }
|
||||
|
||||
0
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ const STATIC_BUMP: u32 = 215_536;
|
||||
|
||||
lazy_static! {
|
||||
static ref OLD_ABORT_ON_CANNOT_GROW_MEMORY_SIG: FunctionType =
|
||||
{ FunctionType::new(vec![], vec![ValType::I32]) };
|
||||
FunctionType::new(vec![], vec![ValType::I32]);
|
||||
}
|
||||
|
||||
// The address globals begin at. Very low in memory, for code size and optimization opportunities.
|
||||
@@ -465,7 +465,7 @@ pub fn emscripten_call_main(
|
||||
}
|
||||
|
||||
/// Top level function to execute emscripten
|
||||
pub fn run_emscripten_instance<'a>(
|
||||
pub fn run_emscripten_instance(
|
||||
instance: &mut Instance,
|
||||
env: &mut EmEnv,
|
||||
globals: &mut EmscriptenGlobals,
|
||||
@@ -1105,7 +1105,7 @@ pub fn generate_emscripten_env(
|
||||
// Compatibility with newer versions of Emscripten
|
||||
let mut to_insert: Vec<(String, _)> = vec![];
|
||||
for (k, v) in env_ns.iter() {
|
||||
if k.starts_with("_") {
|
||||
if k.starts_with('_') {
|
||||
let k = &k[1..];
|
||||
if !env_ns.contains(k) {
|
||||
to_insert.push((k.to_string(), v.clone()));
|
||||
|
||||
@@ -93,7 +93,7 @@ pub fn sbrk(ctx: &mut EmEnv, increment: i32) -> i32 {
|
||||
}
|
||||
}
|
||||
ctx.memory(0).view::<u32>()[dynamictop_ptr].set(new_dynamic_top as u32);
|
||||
return old_dynamic_top as _;
|
||||
old_dynamic_top as _
|
||||
}
|
||||
|
||||
/// emscripten: getTotalMemory
|
||||
|
||||
@@ -33,11 +33,11 @@ pub fn _pthread_attr_setstacksize(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_cleanup_pop(_ctx: &mut EmEnv, _a: i32) -> () {
|
||||
pub fn _pthread_cleanup_pop(_ctx: &mut EmEnv, _a: i32) {
|
||||
trace!("emscripten::_pthread_cleanup_pop");
|
||||
}
|
||||
|
||||
pub fn _pthread_cleanup_push(_ctx: &mut EmEnv, _a: i32, _b: i32) -> () {
|
||||
pub fn _pthread_cleanup_push(_ctx: &mut EmEnv, _a: i32, _b: i32) {
|
||||
trace!("emscripten::_pthread_cleanup_push");
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ pub fn _pthread_equal(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_exit(_ctx: &mut EmEnv, _a: i32) -> () {
|
||||
pub fn _pthread_exit(_ctx: &mut EmEnv, _a: i32) {
|
||||
trace!("emscripten::_pthread_exit");
|
||||
}
|
||||
|
||||
|
||||
@@ -646,7 +646,7 @@ pub fn ___syscall102(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
|
||||
let address_addr = unsafe { address.deref_mut(ctx.memory(0)).unwrap().get_mut() };
|
||||
|
||||
address_addr.sa_family = host_address.sa_family as _;
|
||||
address_addr.sa_data = host_address.sa_data.clone();
|
||||
address_addr.sa_data = host_address.sa_data;
|
||||
|
||||
// why is this here?
|
||||
// set_cloexec
|
||||
@@ -686,7 +686,7 @@ pub fn ___syscall102(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
|
||||
// translate from host data into emscripten data
|
||||
let mut address_mut = unsafe { address.deref_mut(ctx.memory(0)).unwrap().get_mut() };
|
||||
address_mut.sa_family = sock_addr_host.sa_family as _;
|
||||
address_mut.sa_data = sock_addr_host.sa_data.clone();
|
||||
address_mut.sa_data = sock_addr_host.sa_data;
|
||||
|
||||
debug!(
|
||||
"=> socket: {}, address, {:?}, address_len: {}, result = {}",
|
||||
|
||||
@@ -241,7 +241,7 @@ pub fn _localtime(ctx: &mut EmEnv, time_p: u32) -> c_int {
|
||||
|
||||
let timespec = unsafe {
|
||||
let time_p_addr = emscripten_memory_pointer!(ctx.memory(0), time_p) as *mut i64;
|
||||
let seconds = *time_p_addr.clone();
|
||||
let seconds = *time_p_addr;
|
||||
time::Timespec::new(seconds, 0)
|
||||
};
|
||||
let result_tm = time::at(timespec);
|
||||
|
||||
@@ -31,7 +31,7 @@ pub fn get_emscripten_table_size(module: &Module) -> Result<(u32, Option<u32>),
|
||||
let ty = import.ty();
|
||||
Ok((ty.minimum, ty.maximum))
|
||||
} else {
|
||||
return Err("Emscripten requires at least one imported table".to_string());
|
||||
Err("Emscripten requires at least one imported table".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ pub fn get_emscripten_memory_size(module: &Module) -> Result<(Pages, Option<Page
|
||||
let ty = import.ty();
|
||||
Ok((ty.minimum, ty.maximum, ty.shared))
|
||||
} else {
|
||||
return Err("Emscripten requires at least one imported memory".to_string());
|
||||
Err("Emscripten requires at least one imported memory".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
//! Memory management for executable code.
|
||||
use crate::unwind::UnwindRegistry;
|
||||
use region;
|
||||
use std::mem::ManuallyDrop;
|
||||
use std::sync::Arc;
|
||||
use std::{cmp, mem};
|
||||
@@ -150,7 +149,7 @@ impl CodeMemory {
|
||||
Ok(self
|
||||
.read_sections
|
||||
.last_mut()
|
||||
.ok_or("Can't get last section".to_string())?)
|
||||
.ok_or_else(|| "Can't get last section".to_string())?)
|
||||
}
|
||||
|
||||
/// Make all allocated memory executable.
|
||||
|
||||
@@ -155,7 +155,7 @@ impl ModuleInfo {
|
||||
.iter()
|
||||
.filter_map(|(_name, export_index)| match export_index {
|
||||
ExportIndex::Function(i) => {
|
||||
let signature = self.functions.get(i.clone()).unwrap();
|
||||
let signature = self.functions.get(*i).unwrap();
|
||||
let func_type = self.signatures.get(signature.clone()).unwrap();
|
||||
Some(func_type.clone())
|
||||
}
|
||||
@@ -169,20 +169,20 @@ impl ModuleInfo {
|
||||
let iter = self.exports.iter().map(move |(name, export_index)| {
|
||||
let extern_type = match export_index {
|
||||
ExportIndex::Function(i) => {
|
||||
let signature = self.functions.get(i.clone()).unwrap();
|
||||
let func_type = self.signatures.get(signature.clone()).unwrap();
|
||||
let signature = self.functions.get(*i).unwrap();
|
||||
let func_type = self.signatures.get(*signature).unwrap();
|
||||
ExternType::Function(func_type.clone())
|
||||
}
|
||||
ExportIndex::Table(i) => {
|
||||
let table_type = self.tables.get(i.clone()).unwrap();
|
||||
let table_type = self.tables.get(*i).unwrap();
|
||||
ExternType::Table(*table_type)
|
||||
}
|
||||
ExportIndex::Memory(i) => {
|
||||
let memory_type = self.memories.get(i.clone()).unwrap();
|
||||
let memory_type = self.memories.get(*i).unwrap();
|
||||
ExternType::Memory(*memory_type)
|
||||
}
|
||||
ExportIndex::Global(i) => {
|
||||
let global_type = self.globals.get(i.clone()).unwrap();
|
||||
let global_type = self.globals.get(*i).unwrap();
|
||||
ExternType::Global(*global_type)
|
||||
}
|
||||
};
|
||||
@@ -202,20 +202,20 @@ impl ModuleInfo {
|
||||
.map(move |((module, field, _), import_index)| {
|
||||
let extern_type = match import_index {
|
||||
ImportIndex::Function(i) => {
|
||||
let signature = self.functions.get(i.clone()).unwrap();
|
||||
let func_type = self.signatures.get(signature.clone()).unwrap();
|
||||
let signature = self.functions.get(*i).unwrap();
|
||||
let func_type = self.signatures.get(*signature).unwrap();
|
||||
ExternType::Function(func_type.clone())
|
||||
}
|
||||
ImportIndex::Table(i) => {
|
||||
let table_type = self.tables.get(i.clone()).unwrap();
|
||||
let table_type = self.tables.get(*i).unwrap();
|
||||
ExternType::Table(*table_type)
|
||||
}
|
||||
ImportIndex::Memory(i) => {
|
||||
let memory_type = self.memories.get(i.clone()).unwrap();
|
||||
let memory_type = self.memories.get(*i).unwrap();
|
||||
ExternType::Memory(*memory_type)
|
||||
}
|
||||
ImportIndex::Global(i) => {
|
||||
let global_type = self.globals.get(i.clone()).unwrap();
|
||||
let global_type = self.globals.get(*i).unwrap();
|
||||
ExternType::Global(*global_type)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -679,7 +679,6 @@ mod test_wasm_type_list {
|
||||
mod test_func {
|
||||
use super::*;
|
||||
use crate::types::Type;
|
||||
use std::ptr;
|
||||
// WasmTypeList
|
||||
|
||||
fn func() {}
|
||||
|
||||
@@ -45,7 +45,7 @@ impl Compile {
|
||||
.fold(CpuFeature::set(), |a, b| a | b);
|
||||
// Cranelift requires SSE2, so we have this "hack" for now to facilitate
|
||||
// usage
|
||||
features = features | CpuFeature::SSE2;
|
||||
features |= CpuFeature::SSE2;
|
||||
Target::new(target_triple.clone(), features)
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
@@ -41,7 +41,7 @@ impl Config {
|
||||
/// Runs logic for the `config` subcommand
|
||||
pub fn execute(&self) -> Result<()> {
|
||||
self.inner_execute()
|
||||
.context(format!("failed to retrieve the wasmer config"))
|
||||
.context("failed to retrieve the wasmer config".to_string())
|
||||
}
|
||||
fn inner_execute(&self) -> Result<()> {
|
||||
let key = "WASMER_DIR";
|
||||
@@ -64,7 +64,7 @@ impl Config {
|
||||
println!("exec_prefix={}", bindir);
|
||||
println!("includedir={}", includedir);
|
||||
println!("libdir={}", libdir);
|
||||
println!("");
|
||||
println!();
|
||||
println!("Name: wasmer");
|
||||
println!("Description: The Wasmer library for running WebAssembly");
|
||||
println!("Version: {}", VERSION);
|
||||
|
||||
@@ -78,10 +78,10 @@ impl Run {
|
||||
format!(
|
||||
"failed to run `{}`{}",
|
||||
self.path.display(),
|
||||
if compilers.len() > 0 {
|
||||
""
|
||||
} else {
|
||||
if compilers.is_empty() {
|
||||
" (no compilers enabled)"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -33,7 +33,7 @@ pub fn parse_mapdir(entry: &str) -> Result<(String, PathBuf)> {
|
||||
/// Parses a mapdir from an env var
|
||||
pub fn parse_envvar(entry: &str) -> Result<(String, String)> {
|
||||
if let [env_var, value] = entry.split('=').collect::<Vec<&str>>()[..] {
|
||||
return Ok((env_var.to_string(), value.to_string()));
|
||||
Ok((env_var.to_string(), value.to_string()))
|
||||
} else {
|
||||
bail!(
|
||||
"Env vars must be of the form <var_name>=<value>. Found {}",
|
||||
|
||||
@@ -50,7 +50,7 @@ pub fn build_ignores_from_textfile(path: PathBuf) -> anyhow::Result<Ignores> {
|
||||
for line in reader.lines() {
|
||||
let line = line.unwrap();
|
||||
// If the line has a `#` we discard all the content that comes after
|
||||
let line = if line.contains("#") {
|
||||
let line = if line.contains('#') {
|
||||
let l: Vec<&str> = line.split('#').collect();
|
||||
l.get(0).unwrap().to_string()
|
||||
} else {
|
||||
|
||||
@@ -12,7 +12,7 @@ pub fn wast_processor(out: &mut Testsuite, p: PathBuf) -> Option<Test> {
|
||||
}
|
||||
|
||||
// Ignore files starting with `.`, which could be editor temporary files
|
||||
if p.file_stem()?.to_str()?.starts_with(".") {
|
||||
if p.file_stem()?.to_str()?.starts_with('.') {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ impl Wast {
|
||||
field: &str,
|
||||
args: &[Val],
|
||||
) -> Result<Vec<Val>> {
|
||||
let instance = self.get_instance(instance_name.as_ref().map(|x| &**x))?;
|
||||
let instance = self.get_instance(instance_name.as_deref())?;
|
||||
let func: &Function = instance.exports.get(field)?;
|
||||
match func.call(args) {
|
||||
Ok(result) => Ok(result.into()),
|
||||
@@ -350,7 +350,7 @@ impl Wast {
|
||||
|
||||
/// Get the value of an exported global from an instance.
|
||||
fn get(&mut self, instance_name: Option<&str>, field: &str) -> Result<Vec<Val>> {
|
||||
let instance = self.get_instance(instance_name.as_ref().map(|x| &**x))?;
|
||||
let instance = self.get_instance(instance_name.as_deref())?;
|
||||
let global: &Global = instance.exports.get(field)?;
|
||||
Ok(vec![global.get()])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user