Remove the Flags type from Config API (#769)

* Remove the `Flags` type from `Config` API

This commit removes the final foreign type from the `Config` API in the
`wasmtime` crate. The cranelift `Flags` type is now expanded into
various options on the `Config` structure itself, all prefixed with
`cranelift_` since they're only relevant to the Cranelift backend. The
various changes here were:

* The `avoid_div_traps` feature is enabled by default since it seemed
  that was done anywhere anyway.
* Enabling the wasm SIMD feature enables the requisite features in
  Cranelift as well.
* A method for enabling the debug verifier has been added.
* A method for configuring the Cranelift optimization level, as well as
  a corresponding enumeration, has been added.

* Assert that `Config` is both `Send` and `Sync`
This commit is contained in:
Alex Crichton
2020-01-07 14:07:48 -06:00
committed by GitHub
parent 9ead93684e
commit 41528c82bc
10 changed files with 82 additions and 71 deletions

View File

@@ -1,7 +1,5 @@
use std::path::Path;
use wasmtime::{Config, Engine, HostRef, Store, Strategy};
use wasmtime_environ::settings;
use wasmtime_environ::settings::Configurable;
use wasmtime_wast::WastContext;
include!(concat!(env!("OUT_DIR"), "/wast_testsuite_tests.rs"));
@@ -12,16 +10,11 @@ include!(concat!(env!("OUT_DIR"), "/wast_testsuite_tests.rs"));
fn run_wast(wast: &str, strategy: Strategy) -> anyhow::Result<()> {
let wast = Path::new(wast);
let mut flag_builder = settings::builder();
flag_builder.enable("enable_verifier").unwrap();
flag_builder.enable("avoid_div_traps").unwrap();
flag_builder.enable("enable_simd").unwrap();
let mut cfg = Config::new();
cfg.wasm_simd(wast.iter().any(|s| s == "simd"))
.wasm_multi_value(wast.iter().any(|s| s == "multi-value"))
.strategy(strategy)?
.flags(settings::Flags::new(flag_builder));
.cranelift_debug_verifier(true);
let store = HostRef::new(Store::new(&Engine::new(&cfg)));
let mut wast_context = WastContext::new(store);
wast_context.register_spectest()?;