Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Commit 9454509

Browse files
committed
Merge branch 'next' into async
2 parents d59d31f + 9f1bc8d commit 9454509

File tree

21 files changed

+420
-136
lines changed

21 files changed

+420
-136
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
### Changed
1515

1616
- **Breaking:**: New backwards-incompatible version of the twasm format (upgraded `rkyv` to 0.8.0)
17+
- **Breaking:**: `RefNull` has been removed and replaced with new `FuncRef` and `ExternRef` structs
1718
- Increased MSRV to 1.83.0
1819

1920
### Fixed
2021

2122
- Fixed archive **no_std** support which was broken in the previous release, and added more tests to ensure it stays working
23+
- Check returns in untyped host functions ([#27](https://github.com/explodingcamera/tinywasm/pull/27)) (thanks [@WhaleKit](https://github.com/WhaleKit))
2224

2325
## [0.8.0] - 2024-08-29
2426

Cargo.lock

Lines changed: 44 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ default-members=[".", "crates/tinywasm", "crates/types", "crates/parser"]
44
resolver="2"
55

66
[workspace.dependencies]
7-
wast="221"
8-
wat="1.221"
7+
wast="222"
8+
wat="1.222"
99
eyre="0.6"
1010
log="0.4"
1111
pretty_env_logger="0.5"

crates/parser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repository.workspace=true
99
rust-version.workspace=true
1010

1111
[dependencies]
12-
wasmparser={version="0.221", default-features=false, features=["validate", "features", "simd"]}
12+
wasmparser={version="0.222", default-features=false, features=["validate", "features", "simd"]}
1313
log={workspace=true, optional=true}
1414
tinywasm-types={version="0.9.0-alpha.0", path="../types", default-features=false}
1515

crates/parser/src/conversion.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,12 @@ pub(crate) fn process_const_operators(ops: OperatorsReader<'_>) -> Result<ConstI
251251
assert!(matches!(ops[ops.len() - 1], wasmparser::Operator::End));
252252

253253
match &ops[ops.len() - 2] {
254-
wasmparser::Operator::RefNull { hty } => Ok(ConstInstruction::RefNull(convert_heaptype(*hty))),
255-
wasmparser::Operator::RefFunc { function_index } => Ok(ConstInstruction::RefFunc(*function_index)),
254+
wasmparser::Operator::RefNull { hty } => match convert_heaptype(*hty) {
255+
ValType::RefFunc => Ok(ConstInstruction::RefFunc(None)),
256+
ValType::RefExtern => Ok(ConstInstruction::RefExtern(None)),
257+
_ => unimplemented!("Unsupported heap type: {:?}", hty),
258+
},
259+
wasmparser::Operator::RefFunc { function_index } => Ok(ConstInstruction::RefFunc(Some(*function_index))),
256260
wasmparser::Operator::I32Const { value } => Ok(ConstInstruction::I32Const(*value)),
257261
wasmparser::Operator::I64Const { value } => Ok(ConstInstruction::I64Const(*value)),
258262
wasmparser::Operator::F32Const { value } => Ok(ConstInstruction::F32Const(f32::from_bits(value.bits()))),

crates/parser/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ impl Parser {
6565
memory64: true,
6666
custom_page_sizes: true,
6767

68+
extended_const: false,
6869
wide_arithmetic: false,
6970
gc_types: true,
7071
stack_switching: false,
@@ -73,14 +74,14 @@ impl Parser {
7374
component_model_values: false,
7475
component_model_more_flags: false,
7576
exceptions: false,
76-
extended_const: false,
7777
gc: false,
7878
memory_control: false,
7979
relaxed_simd: false,
8080
threads: false,
8181
shared_everything_threads: false,
8282
component_model_multiple_returns: false,
8383
legacy_exceptions: false,
84+
component_model_async: false,
8485
};
8586
Validator::new_with_features(features.into())
8687
}

crates/tinywasm/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ tinywasm-types={version="0.9.0-alpha.0", path="../types", default-features=false
2020
libm={version="0.2", default-features=false}
2121

2222
[dev-dependencies]
23-
wasm-testsuite={version="0.3.3"}
23+
wasm-testsuite={version="0.4.0"}
2424
indexmap="2.7"
2525
wast={workspace=true}
26+
wat={workspace=true}
2627
eyre={workspace=true}
2728
pretty_env_logger={workspace=true}
2829
criterion={workspace=true}

crates/tinywasm/src/error.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use alloc::string::{String, ToString};
2+
use alloc::vec::Vec;
23
use core::{fmt::Display, ops::ControlFlow};
34
use tinywasm_types::FuncType;
45

@@ -22,12 +23,14 @@ pub enum Error {
2223
/// An unknown error occurred
2324
Other(String),
2425

25-
/// A function did not return a value
26-
FuncDidNotReturn,
27-
28-
/// A host function returned results that don't match it's signature
29-
HostFuncInvalidReturn,
30-
26+
/// A host function returned an invalid value
27+
InvalidHostFnReturn {
28+
/// The expected type
29+
expected: FuncType,
30+
/// The actual value
31+
actual: Vec<tinywasm_types::WasmValue>,
32+
},
33+
3134
/// An invalid label type was encountered
3235
InvalidLabelType,
3336

@@ -198,9 +201,9 @@ impl Display for Error {
198201
Self::InvalidLabelType => write!(f, "invalid label type"),
199202
Self::Other(message) => write!(f, "unknown error: {message}"),
200203
Self::UnsupportedFeature(feature) => write!(f, "unsupported feature: {feature}"),
201-
Self::FuncDidNotReturn => write!(f, "function did not return"),
202-
Self::HostFuncInvalidReturn => write!(f, "host function returned invalid types"),
203-
204+
Self::InvalidHostFnReturn { expected, actual } => {
205+
write!(f, "invalid host function return: expected={expected:?}, actual={actual:?}")
206+
}
204207
Self::InvalidStore => write!(f, "invalid store"),
205208

206209
Self::UnexpectedSuspend(_) => write!(f, "funtion yielded instead of returning"),

0 commit comments

Comments
 (0)