summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/tinywasm/src/instance.rs5
-rw-r--r--crates/tinywasm/src/runtime/stack/call_stack.rs2
-rw-r--r--crates/tinywasm/src/runtime/stack/value_stack.rs6
-rw-r--r--crates/tinywasm/src/runtime/value.rs2
-rw-r--r--crates/tinywasm/src/store.rs13
-rw-r--r--crates/tinywasm/tests/generated/progress-mvp.svg8
-rw-r--r--crates/tinywasm/tests/testsuite/indexmap.rs4
-rw-r--r--crates/tinywasm/tests/testsuite/run.rs3
-rw-r--r--crates/tinywasm/tests/testsuite/util.rs2
9 files changed, 22 insertions, 23 deletions
diff --git a/crates/tinywasm/src/instance.rs b/crates/tinywasm/src/instance.rs
index c6fef46..7415d85 100644
--- a/crates/tinywasm/src/instance.rs
+++ b/crates/tinywasm/src/instance.rs
@@ -16,6 +16,7 @@ use crate::{
#[derive(Debug, Clone)]
pub struct ModuleInstance(Arc<ModuleInstanceInner>);
+#[allow(dead_code)]
#[derive(Debug)]
pub(crate) struct ModuleInstanceInner {
pub(crate) store_id: usize,
@@ -78,7 +79,7 @@ impl ModuleInstance {
&self.0.func_addrs
}
- pub(crate) fn global_addrs(&self) -> &[GlobalAddr] {
+ pub(crate) fn _global_addrs(&self) -> &[GlobalAddr] {
&self.0.global_addrs
}
@@ -100,7 +101,7 @@ impl ModuleInstance {
}
// resolve a table address to the global store address
- pub(crate) fn resolve_table_addr(&self, addr: TableAddr) -> TableAddr {
+ pub(crate) fn _resolve_table_addr(&self, addr: TableAddr) -> TableAddr {
self.0.table_addrs[addr as usize]
}
diff --git a/crates/tinywasm/src/runtime/stack/call_stack.rs b/crates/tinywasm/src/runtime/stack/call_stack.rs
index 36d30c4..7874c54 100644
--- a/crates/tinywasm/src/runtime/stack/call_stack.rs
+++ b/crates/tinywasm/src/runtime/stack/call_stack.rs
@@ -97,7 +97,7 @@ impl CallFrame {
.get_relative_to_top(break_to_relative as usize)
.ok_or(Error::LabelStackUnderflow)?;
- value_stack.break_to(break_to.stack_ptr, break_to.args.results as usize);
+ value_stack.break_to(break_to.stack_ptr, break_to.args.results);
// instr_ptr points to the label instruction, but the next step
// will increment it by 1 since we're changing the "current" instr_ptr
diff --git a/crates/tinywasm/src/runtime/stack/value_stack.rs b/crates/tinywasm/src/runtime/stack/value_stack.rs
index a45c33f..10054bc 100644
--- a/crates/tinywasm/src/runtime/stack/value_stack.rs
+++ b/crates/tinywasm/src/runtime/stack/value_stack.rs
@@ -2,7 +2,6 @@ use core::ops::Range;
use crate::{runtime::RawWasmValue, Error, Result};
use alloc::vec::Vec;
-use log::info;
// minimum stack size
pub(crate) const STACK_SIZE: usize = 1024;
@@ -25,11 +24,6 @@ impl Default for ValueStack {
}
impl ValueStack {
- #[cfg(test)]
- pub(crate) fn data(&self) -> &[RawWasmValue] {
- &self.stack
- }
-
#[inline]
pub(crate) fn extend_from_within(&mut self, range: Range<usize>) {
self.top += range.len();
diff --git a/crates/tinywasm/src/runtime/value.rs b/crates/tinywasm/src/runtime/value.rs
index 7217873..da79b0b 100644
--- a/crates/tinywasm/src/runtime/value.rs
+++ b/crates/tinywasm/src/runtime/value.rs
@@ -1,6 +1,6 @@
use core::fmt::Debug;
-use tinywasm_types::{ConstInstruction, ValType, WasmValue};
+use tinywasm_types::{ValType, WasmValue};
/// A raw wasm value.
///
diff --git a/crates/tinywasm/src/store.rs b/crates/tinywasm/src/store.rs
index dd945a6..289b5b6 100644
--- a/crates/tinywasm/src/store.rs
+++ b/crates/tinywasm/src/store.rs
@@ -1,3 +1,5 @@
+#![allow(dead_code)] // TODO: remove this
+
use core::{
cell::RefCell,
sync::atomic::{AtomicUsize, Ordering},
@@ -5,8 +7,8 @@ use core::{
use alloc::{format, rc::Rc, string::ToString, vec, vec::Vec};
use tinywasm_types::{
- Addr, Data, Element, ElementKind, FuncAddr, Function, Global, GlobalType, Import, Instruction, MemAddr, MemArg,
- MemoryArch, MemoryType, ModuleInstanceAddr, TableAddr, TableType, TypeAddr, ValType,
+ Addr, Data, Element, ElementKind, FuncAddr, Function, Global, GlobalType, Import, Instruction, MemAddr, MemoryArch,
+ MemoryType, ModuleInstanceAddr, TableAddr, TableType, TypeAddr, ValType,
};
use crate::{
@@ -155,6 +157,7 @@ impl Store {
idx: ModuleInstanceAddr,
) -> Result<Vec<Addr>> {
// TODO: initialize imported globals
+ #![allow(clippy::unnecessary_filter_map)] // this is cleaner
let imported_globals = wasm_imports
.iter()
.filter_map(|import| match &import.kind {
@@ -170,6 +173,8 @@ impl Store {
};
match global {
Extern::Global(global) => Ok(global),
+
+ #[allow(unreachable_patterns)] // this is non-exhaustive
_ => Err(Error::Other(format!(
"expected global import for {}::{}",
import.module, import.name
@@ -343,7 +348,7 @@ impl MemoryInstance {
}
}
- pub(crate) fn store(&mut self, addr: usize, align: usize, data: &[u8]) -> Result<()> {
+ pub(crate) fn store(&mut self, addr: usize, _align: usize, data: &[u8]) -> Result<()> {
if addr + data.len() > self.data.len() {
return Err(Error::Other(format!(
"memory store out of bounds: offset={}, len={}, mem_size={}",
@@ -358,7 +363,7 @@ impl MemoryInstance {
Ok(())
}
- pub(crate) fn load(&self, addr: usize, align: usize, len: usize) -> Result<&[u8]> {
+ pub(crate) fn load(&self, addr: usize, _align: usize, len: usize) -> Result<&[u8]> {
if addr + len > self.data.len() {
return Err(Error::Other(format!(
"memory load out of bounds: offset={}, len={}, mem_size={}",
diff --git a/crates/tinywasm/tests/generated/progress-mvp.svg b/crates/tinywasm/tests/generated/progress-mvp.svg
index 263a599..9f7e7a4 100644
--- a/crates/tinywasm/tests/generated/progress-mvp.svg
+++ b/crates/tinywasm/tests/generated/progress-mvp.svg
@@ -53,12 +53,12 @@ v0.1.0 (17630)
</text>
<polyline fill="none" opacity="1" stroke="#000000" stroke-width="1" points="716,345 716,350 "/>
<text x="898" y="355" dy="0.76em" text-anchor="middle" font-family="Victor Mono" font-size="12.096774193548388" opacity="1" fill="#000000">
-v0.2.0-alpha.0 (18027)
+v0.2.0-alpha.0 (18183)
</text>
<polyline fill="none" opacity="1" stroke="#000000" stroke-width="1" points="898,345 898,350 "/>
-<rect x="266" y="212" width="172" height="132" opacity="0.5" fill="#0000FF" stroke="none"/>
+<rect x="85" y="212" width="171" height="132" opacity="0.5" fill="#0000FF" stroke="none"/>
<rect x="630" y="92" width="172" height="252" opacity="0.5" fill="#0000FF" stroke="none"/>
-<rect x="812" y="86" width="172" height="258" opacity="0.5" fill="#0000FF" stroke="none"/>
+<rect x="812" y="84" width="172" height="260" opacity="0.5" fill="#0000FF" stroke="none"/>
<rect x="448" y="185" width="172" height="159" opacity="0.5" fill="#0000FF" stroke="none"/>
-<rect x="85" y="212" width="171" height="132" opacity="0.5" fill="#0000FF" stroke="none"/>
+<rect x="266" y="212" width="172" height="132" opacity="0.5" fill="#0000FF" stroke="none"/>
</svg>
diff --git a/crates/tinywasm/tests/testsuite/indexmap.rs b/crates/tinywasm/tests/testsuite/indexmap.rs
index de0de7e..d4e3869 100644
--- a/crates/tinywasm/tests/testsuite/indexmap.rs
+++ b/crates/tinywasm/tests/testsuite/indexmap.rs
@@ -15,8 +15,8 @@ where
}
pub fn insert(&mut self, key: K, value: V) -> Option<V> {
- if self.map.contains_key(&key) {
- return self.map.insert(key, value);
+ if let std::collections::hash_map::Entry::Occupied(mut e) = self.map.entry(key.clone()) {
+ return Some(e.insert(value));
}
self.keys.push(key.clone());
diff --git a/crates/tinywasm/tests/testsuite/run.rs b/crates/tinywasm/tests/testsuite/run.rs
index 70eb70c..0ed1d1e 100644
--- a/crates/tinywasm/tests/testsuite/run.rs
+++ b/crates/tinywasm/tests/testsuite/run.rs
@@ -82,8 +82,7 @@ impl TestSuite {
})
.expect("failed to instantiate module")
}))
- .map_err(|e| eyre!("failed to parse module: {:?}", try_downcast_panic(e)))
- .and_then(|res| Ok(res));
+ .map_err(|e| eyre!("failed to parse module: {:?}", try_downcast_panic(e)));
match &result {
Err(_) => last_module = None,
diff --git a/crates/tinywasm/tests/testsuite/util.rs b/crates/tinywasm/tests/testsuite/util.rs
index 2546ba3..6d0970e 100644
--- a/crates/tinywasm/tests/testsuite/util.rs
+++ b/crates/tinywasm/tests/testsuite/util.rs
@@ -52,7 +52,7 @@ pub fn exec_fn(
pub fn catch_unwind_silent<F: FnOnce() -> R, R>(f: F) -> std::thread::Result<R> {
let prev_hook = panic::take_hook();
panic::set_hook(Box::new(|_| {}));
- let result = panic::catch_unwind(AssertUnwindSafe(|| f()));
+ let result = panic::catch_unwind(AssertUnwindSafe(f));
panic::set_hook(prev_hook);
result
}