Make an initial pass through clippy warnings.
This commit is contained in:
@@ -13,7 +13,7 @@ use region::protect;
|
|||||||
use region::Protection;
|
use region::Protection;
|
||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
use std::ptr::write_unaligned;
|
use std::ptr::write_unaligned;
|
||||||
use wasmtime_runtime::Compilation;
|
use wasmtime_runtime::{Compilation, Relocation};
|
||||||
|
|
||||||
/// Executes a module that has been translated with the `standalone::Runtime` runtime implementation.
|
/// Executes a module that has been translated with the `standalone::Runtime` runtime implementation.
|
||||||
pub fn compile_module<'data, 'module>(
|
pub fn compile_module<'data, 'module>(
|
||||||
@@ -35,7 +35,7 @@ pub fn compile_module<'data, 'module>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Performs the relocations inside the function bytecode, provided the necessary metadata
|
/// Performs the relocations inside the function bytecode, provided the necessary metadata
|
||||||
fn relocate(compilation: &mut Compilation, relocations: &wasmtime_runtime::Relocations) {
|
fn relocate(compilation: &mut Compilation, relocations: &[Vec<Relocation>]) {
|
||||||
// The relocations are relative to the relocation's address plus four bytes
|
// The relocations are relative to the relocation's address plus four bytes
|
||||||
// TODO: Support architectures other than x64, and other reloc kinds.
|
// TODO: Support architectures other than x64, and other reloc kinds.
|
||||||
for (i, function_relocs) in relocations.iter().enumerate() {
|
for (i, function_relocs) in relocations.iter().enumerate() {
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ impl Instance {
|
|||||||
pub fn inspect_memory(&self, memory_index: usize, address: usize, len: usize) -> &[u8] {
|
pub fn inspect_memory(&self, memory_index: usize, address: usize, len: usize) -> &[u8] {
|
||||||
&self.memories
|
&self.memories
|
||||||
.get(memory_index)
|
.get(memory_index)
|
||||||
.expect(format!("no memory for index {}", memory_index).as_str())
|
.unwrap_or_else(|| panic!("no memory for index {}", memory_index))
|
||||||
[address..address + len]
|
[address..address + len]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ impl<'data, 'module> ModuleEnvironment<'data, 'module> {
|
|||||||
/// Allocates the runtime data structures with the given isa.
|
/// Allocates the runtime data structures with the given isa.
|
||||||
pub fn new(isa: &'module isa::TargetIsa, module: &'module mut Module) -> Self {
|
pub fn new(isa: &'module isa::TargetIsa, module: &'module mut Module) -> Self {
|
||||||
Self {
|
Self {
|
||||||
isa: isa,
|
isa,
|
||||||
module,
|
module,
|
||||||
lazy: LazyContents::new(),
|
lazy: LazyContents::new(),
|
||||||
}
|
}
|
||||||
@@ -242,16 +242,13 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
|||||||
fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalVariable {
|
fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalVariable {
|
||||||
let ptr_size = self.ptr_size();
|
let ptr_size = self.ptr_size();
|
||||||
let globals_base = self.globals_base.unwrap_or_else(|| {
|
let globals_base = self.globals_base.unwrap_or_else(|| {
|
||||||
let offset = 0 * ptr_size;
|
|
||||||
let offset32 = offset as i32;
|
|
||||||
debug_assert_eq!(offset32 as usize, offset);
|
|
||||||
let new_base = func.create_global_value(ir::GlobalValueData::VMContext {
|
let new_base = func.create_global_value(ir::GlobalValueData::VMContext {
|
||||||
offset: Offset32::new(offset32),
|
offset: Offset32::new(0),
|
||||||
});
|
});
|
||||||
self.globals_base = Some(new_base);
|
self.globals_base = Some(new_base);
|
||||||
new_base
|
new_base
|
||||||
});
|
});
|
||||||
let offset = index as usize * 8;
|
let offset = index as usize * ptr_size;
|
||||||
let offset32 = offset as i32;
|
let offset32 = offset as i32;
|
||||||
debug_assert_eq!(offset32 as usize, offset);
|
debug_assert_eq!(offset32 as usize, offset);
|
||||||
let gv = func.create_global_value(ir::GlobalValueData::Deref {
|
let gv = func.create_global_value(ir::GlobalValueData::Deref {
|
||||||
@@ -284,15 +281,14 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
|||||||
base: heap_base_addr,
|
base: heap_base_addr,
|
||||||
offset: Offset32::new(0),
|
offset: Offset32::new(0),
|
||||||
});
|
});
|
||||||
let h = func.create_heap(ir::HeapData {
|
func.create_heap(ir::HeapData {
|
||||||
base: ir::HeapBase::GlobalValue(heap_base),
|
base: ir::HeapBase::GlobalValue(heap_base),
|
||||||
min_size: 0.into(),
|
min_size: 0.into(),
|
||||||
guard_size: 0x8000_0000.into(),
|
guard_size: 0x8000_0000.into(),
|
||||||
style: ir::HeapStyle::Static {
|
style: ir::HeapStyle::Static {
|
||||||
bound: 0x1_0000_0000.into(),
|
bound: 0x1_0000_0000.into(),
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
h
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_indirect_sig(&mut self, func: &mut ir::Function, index: SignatureIndex) -> ir::SigRef {
|
fn make_indirect_sig(&mut self, func: &mut ir::Function, index: SignatureIndex) -> ir::SigRef {
|
||||||
|
|||||||
Reference in New Issue
Block a user