Skip to content

Commit

Permalink
Implement some minor UX improvements (#1031)
Browse files Browse the repository at this point in the history
* impl Default for Store<T> where T: Default

* enable tail_call and extended_const for Config::default

* remove no longer needed code

* implement WasmTy for f32 and f64
  • Loading branch information
Robbepop committed May 12, 2024
1 parent 26ea8ad commit 5c17423
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 0 additions & 2 deletions crates/cli/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ impl Context {
compilation_mode: CompilationMode,
) -> Result<Self, Error> {
let mut config = Config::default();
config.wasm_tail_call(true);
config.wasm_extended_const(true);
if fuel.is_some() {
config.consume_fuel(true);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/wasmi/src/engine/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ impl Default for Config {
multi_value: true,
bulk_memory: true,
reference_types: true,
tail_call: false,
extended_const: false,
tail_call: true,
extended_const: true,
floats: true,
consume_fuel: false,
fuel_costs: FuelCosts::default(),
Expand Down
2 changes: 2 additions & 0 deletions crates/wasmi/src/func/into_func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ impl_wasm_type! {
type i64 = I64;
type F32 = F32;
type F64 = F64;
type f32 = F32;
type f64 = F64;
type FuncRef = FuncRef;
type ExternRef = ExternRef;
}
Expand Down
15 changes: 15 additions & 0 deletions crates/wasmi/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,21 @@ impl StoreInner {
}
}

impl<T> Default for Store<T>
where
T: Default,
{
fn default() -> Self {
let engine = Engine::default();
Self {
inner: StoreInner::new(&engine),
trampolines: Arena::new(),
data: T::default(),
limiter: None,
}
}
}

impl<T> Store<T> {
/// Creates a new store.
pub fn new(engine: &Engine, data: T) -> Self {
Expand Down

0 comments on commit 5c17423

Please sign in to comment.