Migrate back to std:: stylistically (#554)

* Migrate back to `std::` stylistically

This commit moves away from idioms such as `alloc::` and `core::` as
imports of standard data structures and types. Instead it migrates all
crates to uniformly use `std::` for importing standard data structures
and types. This also removes the `std` and `core` features from all
crates to and removes any conditional checking for `feature = "std"`

All of this support was previously added in #407 in an effort to make
wasmtime/cranelift "`no_std` compatible". Unfortunately though this
change comes at a cost:

* The usage of `alloc` and `core` isn't idiomatic. Especially trying to
  dual between types like `HashMap` from `std` as well as from
  `hashbrown` causes imports to be surprising in some cases.
* Unfortunately there was no CI check that crates were `no_std`, so none
  of them actually were. Many crates still imported from `std` or
  depended on crates that used `std`.

It's important to note, however, that **this does not mean that wasmtime
will not run in embedded environments**. The style of the code today and
idioms aren't ready in Rust to support this degree of multiplexing and
makes it somewhat difficult to keep up with the style of `wasmtime`.
Instead it's intended that embedded runtime support will be added as
necessary. Currently only `std` is necessary to build `wasmtime`, and
platforms that natively need to execute `wasmtime` will need to use a
Rust target that supports `std`. Note though that not all of `std` needs
to be supported, but instead much of it could be configured off to
return errors, and `wasmtime` would be configured to gracefully handle
errors.

The goal of this PR is to move `wasmtime` back to idiomatic usage of
features/`std`/imports/etc and help development in the short-term.
Long-term when platform concerns arise (if any) they can be addressed by
moving back to `no_std` crates (but fixing the issues mentioned above)
or ensuring that the target in Rust has `std` available.

* Start filling out platform support doc
This commit is contained in:
Alex Crichton
2019-11-19 00:04:06 -06:00
committed by Dan Gohman
parent c423a1c2f0
commit 39e57e3e9a
99 changed files with 271 additions and 444 deletions

View File

@@ -26,23 +26,6 @@ target-lexicon = { version = "0.9.0", default-features = false }
anyhow = "1.0.19"
thiserror = "1.0.4"
region = "2.0.0"
hashbrown = { version = "0.6.0", optional = true }
[features]
default = ["std"]
std = [
"cranelift-codegen/std",
"cranelift-wasm/std",
"wasmtime-environ/std",
"wasmparser/std"
]
core = [
"hashbrown/nightly",
"cranelift-codegen/core",
"cranelift-wasm/core",
"wasmtime-environ/core",
"wasmparser/core"
]
[dev-dependencies]
# for wasmtime.rs

View File

@@ -1,7 +1,7 @@
//! Translation of hello example
use anyhow::{ensure, format_err, Context as _, Result};
use core::cell::Ref;
use std::cell::Ref;
use std::rc::Rc;
use wasmtime_api::*;

View File

@@ -4,8 +4,8 @@ use crate::trampoline::generate_func_export;
use crate::trap::Trap;
use crate::types::FuncType;
use crate::values::Val;
use alloc::{rc::Rc, vec::Vec};
use cranelift_codegen::ir;
use std::rc::Rc;
use wasmtime_jit::InstanceHandle;
use wasmtime_runtime::Export;
@@ -43,8 +43,8 @@ impl WasmtimeFn {
impl WrappedCallable for WasmtimeFn {
fn call(&self, params: &[Val], results: &mut [Val]) -> Result<(), HostRef<Trap>> {
use core::cmp::max;
use core::{mem, ptr};
use std::cmp::max;
use std::{mem, ptr};
let (vmctx, body, signature) = match self.wasmtime_export() {
Export::Function {

View File

@@ -1,7 +1,7 @@
use crate::Config;
use alloc::rc::Rc;
use core::cell::{RefCell, RefMut};
use core::hash::{Hash, Hasher};
use std::cell::{RefCell, RefMut};
use std::hash::{Hash, Hasher};
use std::rc::Rc;
use wasmtime_jit::{Compiler, Features};
#[derive(Clone)]

View File

@@ -5,10 +5,9 @@ use crate::trampoline::{generate_global_export, generate_memory_export, generate
use crate::trap::Trap;
use crate::types::{ExternType, FuncType, GlobalType, MemoryType, TableType, ValType};
use crate::values::{from_checked_anyfunc, into_checked_anyfunc, Val};
use alloc::boxed::Box;
use alloc::rc::Rc;
use core::result::Result;
use core::slice;
use std::fmt;
use std::rc::Rc;
use std::slice;
use wasmtime_runtime::InstanceHandle;
// Externals
@@ -172,8 +171,8 @@ impl Func {
}
}
impl core::fmt::Debug for Func {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
impl fmt::Debug for Func {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Func")
}
}

View File

@@ -4,11 +4,10 @@ use crate::module::Module;
use crate::r#ref::HostRef;
use crate::runtime::Store;
use crate::types::{ExportType, ExternType, Name};
use crate::{HashMap, HashSet};
use alloc::string::{String, ToString};
use alloc::{boxed::Box, rc::Rc, vec::Vec};
use anyhow::Result;
use core::cell::RefCell;
use std::cell::RefCell;
use std::collections::{HashMap, HashSet};
use std::rc::Rc;
use wasmtime_jit::{instantiate, Resolver};
use wasmtime_runtime::{Export, InstanceHandle};

View File

@@ -1,7 +1,6 @@
//! Wasmtime embed API. Based on wasm-c-api.
#![allow(improper_ctypes)]
#![cfg_attr(not(feature = "std"), no_std)]
mod callable;
mod context;
@@ -17,8 +16,6 @@ mod values;
pub mod wasm;
extern crate alloc;
pub use crate::callable::Callable;
pub use crate::externals::*;
pub use crate::instance::Instance;
@@ -28,8 +25,3 @@ pub use crate::runtime::{Config, Engine, Store};
pub use crate::trap::Trap;
pub use crate::types::*;
pub use crate::values::*;
#[cfg(not(feature = "std"))]
use hashbrown::{hash_map, HashMap, HashSet};
#[cfg(feature = "std")]
use std::collections::{hash_map, HashMap, HashSet};

View File

@@ -4,7 +4,6 @@ use crate::types::{
ExportType, ExternType, FuncType, GlobalType, ImportType, Limits, MemoryType, Mutability,
TableType, ValType,
};
use alloc::{boxed::Box, string::String, vec::Vec};
use anyhow::Result;
use wasmparser::{validate, ExternalKind, ImportSectionEntryType, ModuleReader, SectionCode};
@@ -12,7 +11,7 @@ fn into_memory_type(mt: wasmparser::MemoryType) -> MemoryType {
assert!(!mt.shared);
MemoryType::new(Limits::new(
mt.limits.initial,
mt.limits.maximum.unwrap_or(::core::u32::MAX),
mt.limits.maximum.unwrap_or(std::u32::MAX),
))
}
@@ -53,7 +52,7 @@ fn into_table_type(tt: wasmparser::TableType) -> TableType {
let ty = into_valtype(&tt.element_type);
let limits = Limits::new(
tt.limits.initial,
tt.limits.maximum.unwrap_or(::core::u32::MAX),
tt.limits.maximum.unwrap_or(std::u32::MAX),
);
TableType::new(ty, limits)
}

View File

@@ -1,8 +1,7 @@
use alloc::boxed::Box;
use alloc::rc::{Rc, Weak};
use core::any::Any;
use core::cell::{self, RefCell};
use core::fmt;
use std::any::Any;
use std::cell::{self, RefCell};
use std::fmt;
use std::rc::{Rc, Weak};
pub trait HostInfo {
fn finalize(&mut self) {}

View File

@@ -1,9 +1,9 @@
use crate::context::Context;
use crate::r#ref::HostRef;
use crate::HashMap;
use alloc::{rc::Rc, string::String};
use core::cell::RefCell;
use cranelift_codegen::{ir, settings};
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use wasmtime_jit::{CompilationStrategy, Features};
// Runtime Environment
@@ -143,7 +143,7 @@ impl Store {
&mut self,
signature: &ir::Signature,
) -> wasmtime_runtime::VMSharedSignatureIndex {
use crate::hash_map::Entry;
use std::collections::hash_map::Entry;
let index = self.context().compiler().signatures().register(signature);
match self.signature_cache.entry(index) {
Entry::Vacant(v) => {

View File

@@ -1,16 +1,13 @@
//! Support for a calling of an imported function.
use crate::runtime::Store;
use crate::{HashMap, HashSet};
use alloc::boxed::Box;
use alloc::rc::Rc;
use alloc::string::String;
use alloc::vec::Vec;
use anyhow::Result;
use core::any::Any;
use core::cell::{RefCell, RefMut};
use cranelift_entity::PrimaryMap;
use cranelift_wasm::DefinedFuncIndex;
use std::any::Any;
use std::cell::{RefCell, RefMut};
use std::collections::{HashMap, HashSet};
use std::rc::Rc;
use wasmtime_environ::Module;
use wasmtime_runtime::{Imports, InstanceHandle, VMFunctionBody};

View File

@@ -3,15 +3,15 @@
use super::create_handle::create_handle;
use crate::r#ref::HostRef;
use crate::{Callable, FuncType, Store, Trap, Val};
use alloc::{boxed::Box, rc::Rc, string::ToString, vec::Vec};
use anyhow::Result;
use core::cmp;
use cranelift_codegen::ir::{types, InstBuilder, StackSlotData, StackSlotKind, TrapCode};
use cranelift_codegen::print_errors::pretty_error;
use cranelift_codegen::{binemit, ir, isa, Context};
use cranelift_entity::{EntityRef, PrimaryMap};
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
use cranelift_wasm::{DefinedFuncIndex, FuncIndex};
use std::cmp;
use std::rc::Rc;
use wasmtime_environ::{CompiledFunction, Export, Module};
use wasmtime_jit::CodeMemory;
use wasmtime_runtime::{InstanceHandle, VMContext, VMFunctionBody};

View File

@@ -1,6 +1,5 @@
use super::create_handle::create_handle;
use crate::{GlobalType, Mutability, Val};
use alloc::boxed::Box;
use anyhow::Result;
use cranelift_entity::PrimaryMap;
use wasmtime_environ::Module;

View File

@@ -1,7 +1,5 @@
use super::create_handle::create_handle;
use crate::MemoryType;
use alloc::boxed::Box;
use alloc::string::ToString;
use anyhow::Result;
use cranelift_entity::PrimaryMap;
use wasmtime_environ::Module;
@@ -14,7 +12,7 @@ pub fn create_handle_with_memory(memory: &MemoryType) -> Result<InstanceHandle>
let memory = cranelift_wasm::Memory {
minimum: memory.limits().min(),
maximum: if memory.limits().max() == core::u32::MAX {
maximum: if memory.limits().max() == std::u32::MAX {
None
} else {
Some(memory.limits().max())

View File

@@ -12,8 +12,8 @@ use self::memory::create_handle_with_memory;
use self::table::create_handle_with_table;
use super::{Callable, FuncType, GlobalType, MemoryType, Store, TableType, Val};
use crate::r#ref::HostRef;
use alloc::rc::Rc;
use anyhow::Result;
use std::rc::Rc;
pub use self::global::GlobalState;

View File

@@ -1,7 +1,5 @@
use super::create_handle::create_handle;
use crate::{TableType, ValType};
use alloc::boxed::Box;
use alloc::string::ToString;
use anyhow::Result;
use cranelift_entity::PrimaryMap;
use cranelift_wasm::TableElementType;
@@ -13,7 +11,7 @@ pub fn create_handle_with_table(table: &TableType) -> Result<InstanceHandle> {
let table = cranelift_wasm::Table {
minimum: table.limits().min(),
maximum: if table.limits().max() == core::u32::MAX {
maximum: if table.limits().max() == std::u32::MAX {
None
} else {
Some(table.limits().max())

View File

@@ -1,4 +1,3 @@
use alloc::string::{String, ToString};
use thiserror::Error;
#[derive(Error, Debug)]

View File

@@ -1,7 +1,3 @@
use alloc::borrow::ToOwned;
use alloc::boxed::Box;
use alloc::string::String;
use alloc::vec::Vec;
use cranelift_codegen::ir;
// Type Representations
@@ -28,7 +24,7 @@ impl Limits {
pub fn at_least(min: u32) -> Limits {
Limits {
min,
max: ::core::u32::MAX,
max: ::std::u32::MAX,
}
}
@@ -277,7 +273,7 @@ impl TableType {
false
});
let ty = ValType::FuncRef;
let limits = Limits::new(table.minimum, table.maximum.unwrap_or(::core::u32::MAX));
let limits = Limits::new(table.minimum, table.maximum.unwrap_or(::std::u32::MAX));
TableType::new(ty, limits)
}
}
@@ -300,7 +296,7 @@ impl MemoryType {
pub(crate) fn from_cranelift_memory(memory: &cranelift_wasm::Memory) -> MemoryType {
MemoryType::new(Limits::new(
memory.minimum,
memory.maximum.unwrap_or(::core::u32::MAX),
memory.maximum.unwrap_or(::std::u32::MAX),
))
}
}
@@ -326,7 +322,7 @@ impl From<String> for Name {
}
}
impl ::alloc::string::ToString for Name {
impl ToString for Name {
fn to_string(&self) -> String {
self.0.to_owned()
}

View File

@@ -2,8 +2,8 @@ use crate::externals::Func;
use crate::r#ref::{AnyRef, HostRef};
use crate::runtime::Store;
use crate::types::ValType;
use core::ptr;
use cranelift_codegen::ir;
use std::ptr;
use wasmtime_jit::RuntimeValue;
#[derive(Debug, Clone)]

View File

@@ -10,9 +10,8 @@ use super::{
HostInfo, HostRef, ImportType, Instance, Limits, Memory, MemoryType, Module, Name, Store,
Table, TableType, Trap, Val, ValType,
};
use alloc::boxed::Box;
use alloc::rc::Rc;
use core::{mem, ptr, slice};
use std::rc::Rc;
use std::{mem, ptr, slice};
macro_rules! declare_vec {
($name:ident, $elem_ty:path) => {
@@ -343,12 +342,12 @@ pub struct wasm_func_t {
func: HostRef<Func>,
ext: Option<Box<wasm_extern_t>>,
}
pub type wasm_func_callback_t = ::core::option::Option<
pub type wasm_func_callback_t = std::option::Option<
unsafe extern "C" fn(args: *const wasm_val_t, results: *mut wasm_val_t) -> *mut wasm_trap_t,
>;
pub type wasm_func_callback_with_env_t = ::core::option::Option<
pub type wasm_func_callback_with_env_t = std::option::Option<
unsafe extern "C" fn(
env: *mut ::core::ffi::c_void,
env: *mut std::ffi::c_void,
args: *const wasm_val_t,
results: *mut wasm_val_t,
) -> *mut wasm_trap_t,
@@ -567,8 +566,8 @@ impl Into<HostRef<Trap>> for wasm_trap_t {
struct CallbackWithEnv {
callback: wasm_func_callback_with_env_t,
env: *mut ::core::ffi::c_void,
finalizer: ::core::option::Option<unsafe extern "C" fn(env: *mut ::core::ffi::c_void)>,
env: *mut std::ffi::c_void,
finalizer: std::option::Option<unsafe extern "C" fn(env: *mut std::ffi::c_void)>,
}
impl Callable for CallbackWithEnv {
@@ -799,8 +798,8 @@ pub unsafe extern "C" fn wasm_func_new_with_env(
store: *mut wasm_store_t,
ty: *const wasm_functype_t,
callback: wasm_func_callback_with_env_t,
env: *mut ::core::ffi::c_void,
finalizer: ::core::option::Option<unsafe extern "C" fn(arg1: *mut ::core::ffi::c_void)>,
env: *mut std::ffi::c_void,
finalizer: std::option::Option<unsafe extern "C" fn(arg1: *mut std::ffi::c_void)>,
) -> *mut wasm_func_t {
let store = &(*store).store;
let ty = (*ty).functype.clone();
@@ -1614,8 +1613,8 @@ pub unsafe extern "C" fn wasm_tabletype_new(
}
struct HostInfoState {
info: *mut ::core::ffi::c_void,
finalizer: ::core::option::Option<unsafe extern "C" fn(arg1: *mut ::core::ffi::c_void)>,
info: *mut std::ffi::c_void,
finalizer: std::option::Option<unsafe extern "C" fn(arg1: *mut std::ffi::c_void)>,
}
impl HostInfo for HostInfoState {
@@ -1631,8 +1630,8 @@ impl HostInfo for HostInfoState {
#[no_mangle]
pub unsafe extern "C" fn wasm_instance_set_host_info_with_finalizer(
instance: *mut wasm_instance_t,
info: *mut ::core::ffi::c_void,
finalizer: ::core::option::Option<unsafe extern "C" fn(arg1: *mut ::core::ffi::c_void)>,
info: *mut std::ffi::c_void,
finalizer: std::option::Option<unsafe extern "C" fn(arg1: *mut std::ffi::c_void)>,
) {
let info = if info.is_null() && finalizer.is_none() {
None

View File

@@ -18,17 +18,11 @@ cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] }
cranelift-entity = { version = "0.50.0", features = ["enable-serde"] }
cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] }
faerie = "0.13.0"
wasmtime-environ = { path = "../environ", default-features = false }
wasmtime-environ = { path = "../environ" }
target-lexicon = { version = "0.9.0", default-features = false }
anyhow = "1.0"
hashbrown = { version = "0.6.0", optional = true }
thiserror = "1.0.4"
more-asserts = "0.2.1"
[features]
default = ["std"]
std = ["cranelift-codegen/std", "cranelift-wasm/std", "wasmtime-environ/std"]
core = ["hashbrown/nightly", "cranelift-codegen/core", "cranelift-wasm/core"]
[badges]
maintenance = { status = "actively-developed" }

View File

@@ -1,9 +1,8 @@
use crate::transform::AddressTransform;
use crate::{HashMap, HashSet};
use alloc::vec::Vec;
use gimli::constants;
use gimli::read;
use gimli::{Reader, UnitSectionOffset};
use std::collections::{HashMap, HashSet};
#[derive(Debug)]
pub struct Dependencies {
@@ -20,7 +19,7 @@ impl Dependencies {
}
fn add_edge(&mut self, a: UnitSectionOffset, b: UnitSectionOffset) {
use crate::hash_map::Entry;
use std::collections::hash_map::Entry;
match self.edges.entry(a) {
Entry::Occupied(mut o) => {
o.get_mut().insert(b);

View File

@@ -2,16 +2,10 @@
#![allow(clippy::cast_ptr_alignment)]
use alloc::string::String;
use alloc::vec::Vec;
use anyhow::Error;
use cranelift_codegen::isa::TargetFrontendConfig;
use faerie::{Artifact, Decl};
#[cfg(not(feature = "std"))]
use hashbrown::{hash_map, HashMap, HashSet};
use more_asserts::assert_gt;
#[cfg(feature = "std")]
use std::collections::{hash_map, HashMap, HashSet};
use target_lexicon::{BinaryFormat, Triple};
use wasmtime_environ::{ModuleAddressMap, ModuleVmctxInfo, ValueLabelsRanges};
@@ -24,8 +18,6 @@ mod read_debuginfo;
mod transform;
mod write_debuginfo;
extern crate alloc;
struct FunctionRelocResolver {}
impl SymbolResolver for FunctionRelocResolver {
fn resolve_symbol(&self, symbol: usize, addend: i64) -> ResolvedSymbol {
@@ -80,12 +72,12 @@ pub fn emit_debugsections_image(
assert_gt!(funcs.len(), 0);
let mut segment_body: (usize, usize) = (!0, 0);
for (body_ptr, body_len) in funcs {
segment_body.0 = ::core::cmp::min(segment_body.0, *body_ptr as usize);
segment_body.1 = ::core::cmp::max(segment_body.1, *body_ptr as usize + body_len);
segment_body.0 = std::cmp::min(segment_body.0, *body_ptr as usize);
segment_body.1 = std::cmp::max(segment_body.1, *body_ptr as usize + body_len);
}
let segment_body = (segment_body.0 as *const u8, segment_body.1 - segment_body.0);
let body = unsafe { ::core::slice::from_raw_parts(segment_body.0, segment_body.1) };
let body = unsafe { std::slice::from_raw_parts(segment_body.0, segment_body.1) };
obj.declare_with("all", Decl::function(), body.to_vec())?;
emit_dwarf(&mut obj, dwarf, &resolver)?;

View File

@@ -1,4 +1,3 @@
use alloc::{boxed::Box, string::String, vec::Vec};
use gimli::{
DebugAbbrev, DebugAddr, DebugInfo, DebugLine, DebugLineStr, DebugLoc, DebugLocLists,
DebugRanges, DebugRngLists, DebugStr, DebugStrOffsets, DebugTypes, EndianSlice, LittleEndian,

View File

@@ -1,14 +1,12 @@
use crate::HashMap;
use crate::WasmFileInfo;
use alloc::boxed::Box;
use alloc::collections::BTreeMap;
use alloc::vec::Vec;
use core::iter::FromIterator;
use cranelift_codegen::ir::SourceLoc;
use cranelift_entity::{EntityRef, PrimaryMap};
use cranelift_wasm::DefinedFuncIndex;
use gimli::write;
use more_asserts::assert_le;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::iter::FromIterator;
use wasmtime_environ::{FunctionAddressMap, ModuleAddressMap};
pub type GeneratedAddress = usize;
@@ -163,7 +161,7 @@ fn build_function_lookup(
active_ranges.clone().into_boxed_slice(),
);
}
active_ranges.retain(|r| ranges[*r].wasm_end.cmp(&wasm_start) != core::cmp::Ordering::Less);
active_ranges.retain(|r| ranges[*r].wasm_end.cmp(&wasm_start) != std::cmp::Ordering::Less);
active_ranges.push(range_index);
last_wasm_pos = Some(wasm_start);
}
@@ -494,10 +492,10 @@ impl AddressTransform {
mod tests {
use super::{build_function_lookup, get_wasm_code_offset, AddressTransform};
use crate::read_debuginfo::WasmFileInfo;
use core::iter::FromIterator;
use cranelift_codegen::ir::SourceLoc;
use cranelift_entity::PrimaryMap;
use gimli::write::Address;
use std::iter::FromIterator;
use wasmtime_environ::{FunctionAddressMap, InstructionAddressMap, ModuleAddressMap};
#[test]

View File

@@ -3,12 +3,11 @@ use super::expression::{compile_expression, CompiledExpression, FunctionFrameInf
use super::range_info_builder::RangeInfoBuilder;
use super::unit::PendingDieRef;
use super::{DebugInputContext, Reader, TransformError};
use crate::HashMap;
use alloc::vec::Vec;
use anyhow::Error;
use gimli::{
write, AttributeValue, DebugLineOffset, DebugStr, DebuggingInformationEntry, UnitOffset,
};
use std::collections::HashMap;
pub(crate) enum FileAttributeContext<'a> {
Root(Option<DebugLineOffset>),

View File

@@ -1,6 +1,4 @@
use super::address_transform::AddressTransform;
use crate::{HashMap, HashSet};
use alloc::vec::Vec;
use anyhow::Error;
use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc};
use cranelift_codegen::isa::RegUnit;
@@ -9,6 +7,7 @@ use cranelift_entity::EntityRef;
use cranelift_wasm::{get_vmctx_value_label, DefinedFuncIndex};
use gimli::{self, write, Expression, Operation, Reader, ReaderOffset, Register, X86_64};
use more_asserts::{assert_le, assert_lt};
use std::collections::{HashMap, HashSet};
#[derive(Debug)]
pub struct FunctionFrameInfo<'a> {
@@ -201,7 +200,7 @@ impl CompiledExpression {
addr_tr: &AddressTransform,
frame_info: Option<&FunctionFrameInfo>,
endian: gimli::RunTimeEndian,
) -> alloc::vec::Vec<(write::Address, u64, write::Expression)> {
) -> Vec<(write::Address, u64, write::Expression)> {
if scope.is_empty() {
return vec![];
}

View File

@@ -1,15 +1,14 @@
use super::address_transform::AddressTransform;
use super::attr::clone_attr_string;
use super::{Reader, TransformError};
use alloc::collections::BTreeMap;
use alloc::vec::Vec;
use anyhow::Error;
use core::iter::FromIterator;
use cranelift_entity::EntityRef;
use gimli::{
write, DebugLine, DebugLineOffset, DebugStr, DebuggingInformationEntry, LineEncoding, Unit,
};
use more_asserts::assert_le;
use std::collections::BTreeMap;
use std::iter::FromIterator;
#[derive(Debug)]
enum SavedLineProgramRow {

View File

@@ -1,5 +1,5 @@
use crate::gc::build_dependencies;
use crate::{DebugInfoData, HashSet};
use crate::DebugInfoData;
use anyhow::Error;
use cranelift_codegen::isa::TargetFrontendConfig;
use gimli::{
@@ -7,6 +7,7 @@ use gimli::{
UnitSectionOffset,
};
use simulate::generate_simulated_dwarf;
use std::collections::HashSet;
use thiserror::Error;
use unit::clone_unit;
use wasmtime_environ::{ModuleAddressMap, ModuleVmctxInfo, ValueLabelsRanges};

View File

@@ -1,6 +1,5 @@
use super::address_transform::AddressTransform;
use super::{DebugInputContext, Reader};
use alloc::vec::Vec;
use anyhow::Error;
use cranelift_entity::EntityRef;
use cranelift_wasm::DefinedFuncIndex;

View File

@@ -2,14 +2,12 @@ use super::expression::{CompiledExpression, FunctionFrameInfo};
use super::utils::{add_internal_types, append_vmctx_info, get_function_frame_info};
use super::AddressTransform;
use crate::read_debuginfo::WasmFileInfo;
use crate::{HashMap, HashSet};
use alloc::string::String;
use alloc::vec::Vec;
use anyhow::Error;
use cranelift_entity::EntityRef;
use cranelift_wasm::get_vmctx_value_label;
use gimli::write;
use gimli::{self, LineEncoding};
use std::collections::{HashMap, HashSet};
use std::path::PathBuf;
use wasmtime_environ::{ModuleVmctxInfo, ValueLabelsRanges};

View File

@@ -5,12 +5,11 @@ use super::line_program::clone_line_program;
use super::range_info_builder::RangeInfoBuilder;
use super::utils::{add_internal_types, append_vmctx_info, get_function_frame_info};
use super::{DebugInputContext, Reader, TransformError};
use crate::{HashMap, HashSet};
use alloc::{string::String, vec::Vec};
use anyhow::Error;
use cranelift_entity::EntityRef;
use gimli::write;
use gimli::{AttributeValue, DebuggingInformationEntry, Unit, UnitOffset};
use std::collections::{HashMap, HashSet};
use wasmtime_environ::{ModuleVmctxInfo, ValueLabelsRanges};
pub(crate) type PendingDieRef = (write::UnitEntryId, gimli::DwAt, UnitOffset);

View File

@@ -1,6 +1,5 @@
use super::address_transform::AddressTransform;
use super::expression::{CompiledExpression, FunctionFrameInfo};
use alloc::vec::Vec;
use anyhow::Error;
use cranelift_wasm::DefinedFuncIndex;
use gimli::write;

View File

@@ -1,8 +1,8 @@
use alloc::{string::String, vec::Vec};
use faerie::artifact::{Decl, SectionKind};
use faerie::*;
use gimli::write::{Address, Dwarf, EndianVec, Result, Sections, Writer};
use gimli::{RunTimeEndian, SectionId};
use std::result;
#[derive(Clone)]
struct DebugReloc {

View File

@@ -48,10 +48,5 @@ rand = { version = "0.7.0", features = ["small_rng"] }
cranelift-codegen = { version = "0.50.0", features = ["enable-serde", "all-arch"] }
filetime = "0.2.7"
[features]
default = ["std"]
std = ["cranelift-codegen/std", "cranelift-wasm/std"]
core = ["cranelift-codegen/core", "cranelift-wasm/core"]
[badges]
maintenance = { status = "actively-developed" }

View File

@@ -1,7 +1,6 @@
//! Data structures to provide transformation of the source
// addresses of a WebAssembly module into the native code.
use alloc::vec::Vec;
use cranelift_codegen::ir;
use cranelift_entity::PrimaryMap;
use cranelift_wasm::DefinedFuncIndex;

View File

@@ -2,8 +2,6 @@ use crate::address_map::{ModuleAddressMap, ValueLabelsRanges};
use crate::compilation::{Compilation, Relocations, Traps};
use crate::module::Module;
use crate::module_environ::FunctionBodyData;
use alloc::string::{String, ToString};
use core::hash::Hasher;
use cranelift_codegen::{ir, isa};
use cranelift_entity::PrimaryMap;
use cranelift_wasm::DefinedFuncIndex;
@@ -12,6 +10,7 @@ use log::{debug, trace, warn};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::fs;
use std::hash::Hasher;
use std::io::Write;
use std::path::{Path, PathBuf};

View File

@@ -1,9 +1,6 @@
//! Module for configuring the cache system.
use super::worker;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::time::Duration;
use directories::ProjectDirs;
use lazy_static::lazy_static;
use log::{debug, error, trace, warn};
@@ -17,6 +14,7 @@ use std::fs;
use std::mem;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::Duration;
// wrapped, so we have named section in config,
// also, for possible future compatibility

View File

@@ -1,7 +1,7 @@
use super::CacheConfig;
use core::time::Duration;
use std::fs;
use std::path::PathBuf;
use std::time::Duration;
use tempfile::{self, TempDir};
// note: config loading during validation creates cache directory to canonicalize its path,

View File

@@ -3,15 +3,13 @@ use super::*;
use crate::address_map::{FunctionAddressMap, InstructionAddressMap};
use crate::compilation::{CompiledFunction, Relocation, RelocationTarget, TrapInformation};
use crate::module::{MemoryPlan, MemoryStyle, Module};
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::cmp::min;
use cranelift_codegen::{binemit, ir, isa, settings, ValueLocRange};
use cranelift_entity::EntityRef;
use cranelift_entity::{PrimaryMap, SecondaryMap};
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, Global, GlobalInit, Memory, SignatureIndex};
use rand::rngs::SmallRng;
use rand::{Rng, SeedableRng};
use std::cmp::min;
use std::fs;
use std::str::FromStr;
use target_lexicon::triple;

View File

@@ -6,12 +6,10 @@
//! Background tasks can be CPU intensive, but the worker thread has low priority.
use super::{cache_config, fs_write_atomic, CacheConfig};
use alloc::vec::Vec;
use core::cmp;
use core::time::Duration;
use log::{debug, info, trace, warn};
use serde::{Deserialize, Serialize};
use spin::Once;
use std::cmp;
use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs;
@@ -21,6 +19,7 @@ use std::sync::mpsc::{sync_channel, Receiver, SyncSender};
#[cfg(test)]
use std::sync::{Arc, Condvar, Mutex};
use std::thread;
use std::time::Duration;
#[cfg(not(test))]
use std::time::SystemTime;
#[cfg(test)]
@@ -234,7 +233,7 @@ impl WorkerThread {
#[cfg(target_os = "windows")]
fn lower_thread_priority() {
use core::convert::TryInto;
use std::convert::TryInto;
use winapi::um::processthreadsapi::{GetCurrentThread, SetThreadPriority};
use winapi::um::winbase::THREAD_MODE_BACKGROUND_BEGIN;

View File

@@ -1,7 +1,7 @@
use super::*;
use crate::cache::config::tests::test_prolog;
use core::iter::repeat;
use more_asserts::{assert_ge, assert_gt, assert_lt};
use std::iter::repeat;
use std::process;
// load_config! comes from crate::cache(::config::tests);

View File

@@ -4,7 +4,6 @@
use crate::address_map::{ModuleAddressMap, ValueLabelsRanges};
use crate::module;
use crate::module_environ::FunctionBodyData;
use alloc::vec::Vec;
use cranelift_codegen::{binemit, ir, isa};
use cranelift_entity::PrimaryMap;
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, ModuleTranslationState, WasmError};

View File

@@ -14,7 +14,6 @@ use crate::func_environ::{
};
use crate::module::Module;
use crate::module_environ::FunctionBodyData;
use alloc::vec::Vec;
use cranelift_codegen::binemit;
use cranelift_codegen::ir;
use cranelift_codegen::ir::ExternalName;

View File

@@ -1,9 +1,6 @@
use crate::module::{MemoryPlan, MemoryStyle, Module, TableStyle};
use crate::vmoffsets::VMOffsets;
use crate::WASM_PAGE_SIZE;
use alloc::vec::Vec;
use core::clone::Clone;
use core::convert::TryFrom;
use cranelift_codegen::cursor::FuncCursor;
use cranelift_codegen::ir;
use cranelift_codegen::ir::condcodes::*;
@@ -18,6 +15,7 @@ use cranelift_wasm::{
};
#[cfg(feature = "lightbeam")]
use cranelift_wasm::{DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex};
use std::convert::TryFrom;
/// Compute an `ir::ExternalName` for a given wasm function index.
pub fn get_func_name(func_index: FuncIndex) -> ir::ExternalName {

View File

@@ -5,7 +5,6 @@
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces)]
#![cfg_attr(feature = "std", deny(unstable_features))]
#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
#![cfg_attr(
feature = "cargo-clippy",
@@ -25,8 +24,6 @@
)
)]
extern crate alloc;
mod address_map;
mod compilation;
mod func_environ;

View File

@@ -2,10 +2,6 @@
use crate::module_environ::FunctionBodyData;
use crate::tunables::Tunables;
use alloc::boxed::Box;
use alloc::string::String;
use alloc::vec::Vec;
use core::hash::{Hash, Hasher};
use cranelift_codegen::ir;
use cranelift_entity::{EntityRef, PrimaryMap};
use cranelift_wasm::{
@@ -14,6 +10,7 @@ use cranelift_wasm::{
};
use indexmap::IndexMap;
use more_asserts::assert_ge;
use std::hash::{Hash, Hasher};
/// A WebAssembly table initializer.
#[derive(Clone, Debug, Hash)]

View File

@@ -1,10 +1,6 @@
use crate::func_environ::FuncEnvironment;
use crate::module::{Export, MemoryPlan, Module, TableElements, TablePlan};
use crate::tunables::Tunables;
use alloc::boxed::Box;
use alloc::string::String;
use alloc::vec::Vec;
use core::convert::TryFrom;
use cranelift_codegen::ir;
use cranelift_codegen::ir::{AbiParam, ArgumentPurpose};
use cranelift_codegen::isa::TargetFrontendConfig;
@@ -13,6 +9,7 @@ use cranelift_wasm::{
self, translate_module, DefinedFuncIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex,
ModuleTranslationState, SignatureIndex, Table, TableIndex, WasmResult,
};
use std::convert::TryFrom;
/// Contains function data: byte code and its offset in the module.
#[derive(Hash)]

View File

@@ -3,13 +3,13 @@
use crate::module::Module;
use crate::BuiltinFunctionIndex;
use core::convert::TryFrom;
use cranelift_codegen::ir;
use cranelift_wasm::{
DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex, GlobalIndex, MemoryIndex,
SignatureIndex, TableIndex,
};
use more_asserts::assert_lt;
use std::convert::TryFrom;
#[cfg(target_pointer_width = "32")]
fn cast_to_u32(sz: usize) -> u32 {

View File

@@ -17,8 +17,8 @@ walrus = "0.13"
wasmparser = { version = "0.39.2", default-features = false }
wasm-webidl-bindings = "0.6"
wasmtime = { path = '../api' }
wasmtime-jit = { path = '../jit', default-features = false }
wasmtime-runtime = { path = '../runtime', default-features = false }
wasmtime-jit = { path = '../jit' }
wasmtime-runtime = { path = '../runtime' }
wasmtime-wasi = { path = '../wasi' }
[badges]

View File

@@ -7,15 +7,10 @@
#![deny(missing_docs)]
extern crate alloc;
use alloc::boxed::Box;
use alloc::string::ToString;
use alloc::vec::Vec;
use anyhow::{bail, format_err, Result};
use core::convert::TryFrom;
use core::str;
use cranelift_codegen::ir;
use std::convert::TryFrom;
use std::str;
use wasm_webidl_bindings::ast;
use wasmtime_api as api;
use wasmtime_jit::RuntimeValue;

View File

@@ -1,6 +1,5 @@
use alloc::string::{String, ToString};
use core::convert::TryFrom;
use core::fmt;
use std::convert::TryFrom;
use std::fmt;
/// The set of all possible WebAssembly Interface Types
#[derive(Debug, Clone)]

View File

@@ -15,13 +15,12 @@ cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] }
cranelift-entity = { version = "0.50.0", features = ["enable-serde"] }
cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] }
cranelift-frontend = "0.50.0"
wasmtime-environ = { path = "../environ", default-features = false }
wasmtime-runtime = { path = "../runtime", default-features = false }
wasmtime-debug = { path = "../debug", default-features = false }
wasmtime-environ = { path = "../environ" }
wasmtime-runtime = { path = "../runtime" }
wasmtime-debug = { path = "../debug" }
region = "2.0.0"
thiserror = "1.0.4"
target-lexicon = { version = "0.9.0", default-features = false }
hashbrown = { version = "0.6.0", optional = true }
wasmparser = { version = "0.39.2", default-features = false }
more-asserts = "0.2.1"
anyhow = "1.0"
@@ -30,23 +29,6 @@ anyhow = "1.0"
winapi = { version = "0.3.7", features = ["winnt", "impl-default"] }
[features]
default = ["std"]
std = [
"cranelift-codegen/std",
"cranelift-wasm/std",
"wasmtime-environ/std",
"wasmtime-debug/std",
"wasmtime-runtime/std",
"wasmparser/std"
]
core = [
"hashbrown/nightly",
"cranelift-codegen/core",
"cranelift-wasm/core",
"wasmtime-environ/core",
"wasmtime-debug/core",
"wasmparser/core"
]
lightbeam = ["wasmtime-environ/lightbeam"]
[badges]

View File

@@ -2,11 +2,9 @@
use crate::compiler::Compiler;
use crate::instantiate::SetupError;
use alloc::string::String;
use alloc::vec::Vec;
use core::cmp::max;
use core::{fmt, mem, ptr, slice};
use cranelift_codegen::ir;
use std::cmp::max;
use std::{fmt, mem, ptr, slice};
use thiserror::Error;
use wasmtime_runtime::{wasmtime_call_trampoline, Export, InstanceHandle, VMInvokeArgument};

View File

@@ -1,11 +1,8 @@
//! Memory management for executable code.
use crate::function_table::FunctionTable;
use alloc::boxed::Box;
use alloc::string::String;
use alloc::vec::Vec;
use core::{cmp, mem};
use region;
use std::{cmp, mem};
use wasmtime_environ::{Compilation, CompiledFunction};
use wasmtime_runtime::{Mmap, VMFunctionBody};

View File

@@ -1,13 +1,8 @@
//! JIT compilation.
use super::HashMap;
use crate::code_memory::CodeMemory;
use crate::instantiate::SetupError;
use crate::target_tunables::target_tunables;
use alloc::boxed::Box;
use alloc::string::String;
use alloc::vec::Vec;
use core::convert::TryFrom;
use cranelift_codegen::ir::InstBuilder;
use cranelift_codegen::isa::{TargetFrontendConfig, TargetIsa};
use cranelift_codegen::print_errors::pretty_error;
@@ -16,6 +11,8 @@ use cranelift_codegen::{binemit, ir};
use cranelift_entity::{EntityRef, PrimaryMap};
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
use cranelift_wasm::{DefinedFuncIndex, DefinedMemoryIndex, ModuleTranslationState};
use std::collections::HashMap;
use std::convert::TryFrom;
use wasmtime_debug::{emit_debugsections_image, DebugInfoData};
use wasmtime_environ::{
Compilation, CompileError, CompiledFunction, Compiler as _C, FunctionBodyData, Module,
@@ -202,7 +199,7 @@ impl Compiler {
signature: &ir::Signature,
value_size: usize,
) -> Result<*const VMFunctionBody, SetupError> {
use super::hash_map::Entry::{Occupied, Vacant};
use std::collections::hash_map::Entry::{Occupied, Vacant};
Ok(match self.trampoline_park.entry(callee_address) {
Occupied(entry) => *entry.get(),
Vacant(entry) => {

View File

@@ -1,14 +1,12 @@
use crate::action::{get, inspect_memory, invoke};
use crate::HashMap;
use crate::{
instantiate, ActionError, ActionOutcome, CompilationStrategy, CompiledModule, Compiler,
InstanceHandle, Namespace, RuntimeValue, SetupError,
};
use alloc::boxed::Box;
use alloc::rc::Rc;
use alloc::string::{String, ToString};
use core::cell::RefCell;
use cranelift_codegen::isa::TargetIsa;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use thiserror::Error;
use wasmparser::{validate, OperatorValidatorConfig, ValidatingParserConfig};

View File

@@ -3,19 +3,15 @@
//! `CompiledModule` to allow compiling and instantiating to be done as separate
//! steps.
use super::HashMap;
use crate::compiler::Compiler;
use crate::link::link_module;
use crate::resolver::Resolver;
use alloc::boxed::Box;
use alloc::rc::Rc;
use alloc::string::String;
use alloc::vec::Vec;
use core::cell::RefCell;
use cranelift_entity::{BoxedSlice, PrimaryMap};
use cranelift_wasm::{DefinedFuncIndex, SignatureIndex};
#[cfg(feature = "std")]
use std::cell::RefCell;
use std::collections::HashMap;
use std::io::Write;
use std::rc::Rc;
use thiserror::Error;
use wasmtime_debug::read_debuginfo;
use wasmtime_environ::{
@@ -120,7 +116,6 @@ impl<'data> RawCompiledModule<'data> {
// Make all code compiled thus far executable.
compiler.publish_compiled_code();
#[cfg(feature = "std")]
let dbg_jit_registration = if let Some(img) = dbg_image {
let mut bytes = Vec::new();
bytes.write_all(&img).expect("all written");

View File

@@ -2,7 +2,6 @@
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces)]
#![cfg_attr(feature = "std", deny(unstable_features))]
#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
#![cfg_attr(
feature = "cargo-clippy",
@@ -22,13 +21,6 @@
)
)]
extern crate alloc;
#[cfg(not(feature = "std"))]
use hashbrown::{hash_map, HashMap, HashSet};
#[cfg(feature = "std")]
use std::collections::{hash_map, HashMap, HashSet};
mod action;
mod code_memory;
mod compiler;

View File

@@ -1,14 +1,13 @@
//! Linking for JIT-compiled code.
use crate::resolver::Resolver;
use crate::HashSet;
use alloc::vec::Vec;
use core::ptr::write_unaligned;
use cranelift_codegen::binemit::Reloc;
use cranelift_codegen::ir::JumpTableOffsets;
use cranelift_entity::PrimaryMap;
use cranelift_wasm::{DefinedFuncIndex, Global, GlobalInit, Memory, Table, TableElementType};
use more_asserts::assert_ge;
use std::collections::HashSet;
use std::ptr::write_unaligned;
use wasmtime_environ::{
MemoryPlan, MemoryStyle, Module, Relocation, RelocationTarget, Relocations, TablePlan,
};

View File

@@ -2,9 +2,8 @@
//! to exports. This file provides one possible way to manage multiple instances
//! and resolve imports to exports among them.
use super::HashMap;
use crate::resolver::Resolver;
use alloc::string::String;
use std::collections::HashMap;
use wasmtime_runtime::{Export, InstanceHandle};
/// A namespace containing instances keyed by name.

View File

@@ -1,4 +1,4 @@
use core::cmp::min;
use std::cmp::min;
use target_lexicon::{OperatingSystem, Triple};
use wasmtime_environ::Tunables;

View File

@@ -5,13 +5,13 @@ use crate::backend::{
use crate::error::Error;
use crate::microwasm::*;
use crate::module::{ModuleContext, SigType, Signature};
use core::{fmt, mem};
use cranelift_codegen::binemit;
use dynasmrt::DynasmApi;
use either::{Either, Left, Right};
use more_asserts::assert_ge;
use multi_mut::HashMapMultiMut;
use std::{collections::HashMap, hash::Hash};
use std::{fmt, mem};
#[derive(Debug)]
struct Block {

View File

@@ -2,13 +2,13 @@ use crate::backend::TranslatedCodeSection;
use crate::error::Error;
use crate::microwasm;
use crate::translate_sections;
use core::{convert::TryInto, mem};
use cranelift_codegen::{
ir::{self, AbiParam, Signature as CraneliftSignature},
isa,
};
use memoffset::offset_of;
use more_asserts::assert_le;
use std::{convert::TryInto, mem};
use thiserror::Error;
use wasmparser::{FuncType, MemoryType, ModuleReader, SectionCode, Type};
@@ -167,7 +167,7 @@ impl ExecutableModule {
self.context
.as_ref()
.map(|ctx| (&**ctx) as *const VmCtx as *const u8)
.unwrap_or(core::ptr::null()),
.unwrap_or(std::ptr::null()),
)
}

View File

@@ -1,12 +1,10 @@
//! Support for a calling of a bounds (exported) function.
extern crate alloc;
use crate::value::{pyobj_to_value, value_to_pyobj};
use alloc::rc::Rc;
use pyo3::exceptions::Exception;
use pyo3::prelude::*;
use pyo3::types::{PyAny, PyDict, PyTuple};
use std::rc::Rc;
use wasmtime_api as api;
use wasmtime_interface_types::ModuleData;

View File

@@ -1,12 +1,10 @@
//! WebAssembly Instance API object.
extern crate alloc;
use crate::function::Function;
use crate::memory::Memory;
use alloc::rc::Rc;
use pyo3::prelude::*;
use pyo3::types::PyDict;
use std::rc::Rc;
use wasmtime_api as api;
use wasmtime_interface_types::ModuleData;

View File

@@ -1,14 +1,12 @@
//! WebAssembly Memory API object.
extern crate alloc;
use core::ptr;
use pyo3::class::PyBufferProtocol;
use pyo3::exceptions::BufferError;
use pyo3::ffi;
use pyo3::prelude::*;
use std::ffi::CStr;
use std::os::raw::{c_int, c_void};
use std::ptr;
use wasmtime_api as api;
#[pyclass]

View File

@@ -1,7 +1,5 @@
//! WebAssembly Module API object.
extern crate alloc;
use pyo3::prelude::*;
use wasmtime_api as api;

View File

@@ -1,14 +1,12 @@
#![allow(clippy::cast_ptr_alignment)]
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::ptr;
use cranelift_codegen::isa::TargetFrontendConfig;
use cranelift_entity::EntityRef;
use cranelift_wasm::GlobalInit;
use more_asserts::assert_le;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::ptr;
use wasmtime_environ::{Module, TargetSharedSignatureIndex, VMOffsets};
pub struct TableRelocation {
@@ -32,7 +30,7 @@ pub fn layout_vmcontext(
let target_index = match signature_registry.entry(sig) {
Entry::Occupied(o) => *o.get(),
Entry::Vacant(v) => {
assert_le!(signature_registry_len, ::core::u32::MAX as usize);
assert_le!(signature_registry_len, std::u32::MAX as usize);
let id = TargetSharedSignatureIndex::new(signature_registry_len as u32);
signature_registry_len += 1;
*v.insert(id)

View File

@@ -1,5 +1,3 @@
use alloc::string::String;
use alloc::vec::Vec;
use faerie::{Artifact, Decl};
use wasmtime_environ::DataInitializer;

View File

@@ -1,4 +1,3 @@
use alloc::string::String;
use cranelift_codegen::settings;
use cranelift_codegen::settings::Configurable;
use cranelift_entity::EntityRef;

View File

@@ -26,8 +26,6 @@
)
)]
extern crate alloc;
mod context;
mod data_segment;
mod function;

View File

@@ -2,7 +2,6 @@ use crate::context::layout_vmcontext;
use crate::data_segment::{declare_data_segment, emit_data_segment};
use crate::function::{declare_functions, emit_functions};
use crate::table::{declare_table, emit_table};
use alloc::string::String;
use cranelift_codegen::isa::TargetFrontendConfig;
use faerie::{Artifact, Decl, Link};
use wasmtime_environ::{Compilation, DataInitializer, Module, Relocations};

View File

@@ -1,5 +1,3 @@
use alloc::string::String;
use alloc::vec::Vec;
use faerie::{Artifact, Decl};
/// Declares data segment symbol

View File

@@ -14,14 +14,12 @@ edition = "2018"
cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] }
cranelift-entity = { version = "0.50.0", features = ["enable-serde"] }
cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] }
wasmtime-environ = { path = "../environ", default-features = false }
wasmtime-environ = { path = "../environ" }
region = "2.0.0"
lazy_static = "1.2.0"
libc = { version = "0.2.60", default-features = false }
memoffset = "0.5.3"
indexmap = "1.0.2"
hashbrown = { version = "0.6.0", optional = true }
spin = { version = "0.5.2", optional = true }
thiserror = "1.0.4"
more-asserts = "0.2.1"
@@ -31,16 +29,5 @@ winapi = { version = "0.3.7", features = ["winbase", "memoryapi"] }
[build-dependencies]
cc = "1.0"
[features]
default = ["std"]
std = ["cranelift-codegen/std", "cranelift-wasm/std", "wasmtime-environ/std"]
core = [
"hashbrown/nightly",
"cranelift-codegen/core",
"cranelift-wasm/core",
"wasmtime-environ/core",
"spin"
]
[badges]
maintenance = { status = "actively-developed" }

View File

@@ -1,8 +1,8 @@
use crate::instance::InstanceHandle;
use crate::vmcontext::{VMFunctionImport, VMGlobalImport, VMMemoryImport, VMTableImport};
use crate::HashSet;
use cranelift_entity::{BoxedSlice, PrimaryMap};
use cranelift_wasm::{FuncIndex, GlobalIndex, MemoryIndex, TableIndex};
use std::collections::HashSet;
/// Resolved import pointers.
#[derive(Clone)]

View File

@@ -15,16 +15,6 @@ use crate::vmcontext::{
VMGlobalDefinition, VMGlobalImport, VMMemoryDefinition, VMMemoryImport, VMSharedSignatureIndex,
VMTableDefinition, VMTableImport,
};
use crate::{HashMap, HashSet};
use alloc::borrow::ToOwned;
use alloc::boxed::Box;
use alloc::rc::Rc;
use alloc::string::{String, ToString};
use core::any::Any;
use core::borrow::Borrow;
use core::cell::RefCell;
use core::convert::TryFrom;
use core::{mem, ptr, slice};
use cranelift_entity::{BoxedSlice, EntityRef, PrimaryMap};
use cranelift_wasm::{
DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex,
@@ -32,6 +22,13 @@ use cranelift_wasm::{
};
use memoffset::offset_of;
use more_asserts::assert_lt;
use std::any::Any;
use std::borrow::Borrow;
use std::cell::RefCell;
use std::collections::{HashMap, HashSet};
use std::convert::TryFrom;
use std::rc::Rc;
use std::{mem, ptr, slice};
use thiserror::Error;
use wasmtime_environ::{DataInitializer, Module, TableElements, VMOffsets};
@@ -613,10 +610,8 @@ impl Instance {
}
pub(crate) fn lookup_global_export(&self, field: &str) -> Option<Export> {
let cell: &RefCell<HashMap<alloc::string::String, core::option::Option<Export>>> =
self.global_exports.borrow();
let map: &mut HashMap<alloc::string::String, core::option::Option<Export>> =
&mut cell.borrow_mut();
let cell: &RefCell<HashMap<String, Option<Export>>> = self.global_exports.borrow();
let map: &mut HashMap<String, Option<Export>> = &mut cell.borrow_mut();
if let Some(Some(export)) = map.get(field) {
return Some(export.clone());
}
@@ -790,11 +785,9 @@ impl InstanceHandle {
// Collect the exports for the global export map.
for (field, decl) in &instance.module.exports {
use crate::hash_map::Entry::*;
let cell: &RefCell<HashMap<alloc::string::String, core::option::Option<Export>>> =
instance.global_exports.borrow();
let map: &mut HashMap<alloc::string::String, core::option::Option<Export>> =
&mut cell.borrow_mut();
use std::collections::hash_map::Entry::*;
let cell: &RefCell<HashMap<String, Option<Export>>> = instance.global_exports.borrow();
let map: &mut HashMap<String, Option<Export>> = &mut cell.borrow_mut();
match map.entry(field.to_string()) {
Vacant(entry) => {
entry.insert(Some(lookup_by_declaration(

View File

@@ -2,9 +2,7 @@
//! the __jit_debug_register_code() and __jit_debug_descriptor to register
//! or unregister generated object images with debuggers.
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::ptr;
use std::ptr;
#[repr(C)]
struct JITCodeEntry {
@@ -41,7 +39,7 @@ extern "C" fn __jit_debug_register_code() {
// Hack to not allow inlining even when Rust wants to do it in release mode.
let x = 3;
unsafe {
core::ptr::read_volatile(&x);
std::ptr::read_volatile(&x);
}
}

View File

@@ -3,7 +3,6 @@
#![allow(improper_ctypes)]
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces)]
#![cfg_attr(feature = "std", deny(unstable_features))]
#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
#![cfg_attr(
feature = "cargo-clippy",
@@ -22,9 +21,6 @@
clippy::use_self
)
)]
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
mod export;
mod imports;
@@ -56,15 +52,5 @@ pub use crate::vmcontext::{
VMTableDefinition, VMTableImport,
};
#[cfg(not(feature = "std"))]
use hashbrown::{hash_map, HashMap, HashSet};
#[cfg(feature = "std")]
use std::collections::{hash_map, HashMap, HashSet};
#[cfg(not(feature = "std"))]
use spin::{RwLock, RwLockReadGuard, RwLockWriteGuard};
#[cfg(feature = "std")]
use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};
/// Version number of this crate.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

View File

@@ -4,9 +4,8 @@
use crate::mmap::Mmap;
use crate::vmcontext::VMMemoryDefinition;
use alloc::string::String;
use core::convert::TryFrom;
use more_asserts::{assert_ge, assert_le};
use std::convert::TryFrom;
use wasmtime_environ::{MemoryPlan, MemoryStyle, WASM_MAX_PAGES, WASM_PAGE_SIZE};
/// A linear memory instance.

View File

@@ -1,16 +1,14 @@
//! Low-level abstraction for allocating and managing zero-filled pages
//! of memory.
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::ptr;
use core::slice;
#[cfg(not(target_os = "windows"))]
use libc;
use more_asserts::assert_le;
use more_asserts::assert_lt;
use region;
use std::io;
use std::ptr;
use std::slice;
/// Round `size` up to the nearest multiple of `page_size`.
fn round_up_to_page_size(size: usize, page_size: usize) -> usize {

View File

@@ -2,10 +2,10 @@
//! signature checking.
use crate::vmcontext::VMSharedSignatureIndex;
use crate::{hash_map, HashMap};
use core::convert::TryFrom;
use cranelift_codegen::ir;
use more_asserts::{assert_lt, debug_assert_lt};
use std::collections::{hash_map, HashMap};
use std::convert::TryFrom;
/// WebAssembly requires that the caller and callee signatures in an indirect
/// call must match. To implement this efficiently, keep a registry of all
@@ -30,12 +30,12 @@ impl SignatureRegistry {
match self.signature_hash.entry(sig.clone()) {
hash_map::Entry::Occupied(entry) => *entry.get(),
hash_map::Entry::Vacant(entry) => {
// Keep `signature_hash` len under 2**32 -- VMSharedSignatureIndex::new(core::u32::MAX)
// Keep `signature_hash` len under 2**32 -- VMSharedSignatureIndex::new(std::u32::MAX)
// is reserved for VMSharedSignatureIndex::default().
debug_assert_lt!(
len,
core::u32::MAX as usize,
"Invariant check: signature_hash.len() < core::u32::MAX"
std::u32::MAX as usize,
"Invariant check: signature_hash.len() < std::u32::MAX"
);
let sig_id = VMSharedSignatureIndex::new(u32::try_from(len).unwrap());
entry.insert(sig_id);

View File

@@ -5,10 +5,10 @@
#![allow(non_snake_case)]
use crate::vmcontext::VMContext;
use crate::RwLock;
use core::borrow::{Borrow, BorrowMut};
use core::cell::Cell;
use lazy_static::lazy_static;
use std::borrow::{Borrow, BorrowMut};
use std::cell::Cell;
use std::sync::RwLock;
#[derive(Default)]
struct TrapContext {

View File

@@ -3,9 +3,8 @@
//! `Table` is to WebAssembly tables what `LinearMemory` is to WebAssembly linear memories.
use crate::vmcontext::{VMCallerCheckedAnyfunc, VMTableDefinition};
use alloc::vec::Vec;
use core::convert::{TryFrom, TryInto};
use cranelift_wasm::TableElementType;
use std::convert::{TryFrom, TryInto};
use wasmtime_environ::{TablePlan, TableStyle};
/// A table instance.

View File

@@ -1,7 +1,7 @@
use crate::HashMap;
use crate::{RwLock, RwLockReadGuard, RwLockWriteGuard};
use cranelift_codegen::ir;
use lazy_static::lazy_static;
use std::collections::HashMap;
use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};
lazy_static! {
static ref REGISTRY: RwLock<TrapRegistry> = RwLock::new(TrapRegistry::default());

View File

@@ -4,10 +4,9 @@
use crate::trap_registry::get_trap_registry;
use crate::trap_registry::TrapDescription;
use crate::vmcontext::{VMContext, VMFunctionBody};
use alloc::string::{String, ToString};
use core::cell::Cell;
use core::ptr;
use cranelift_codegen::ir;
use std::cell::Cell;
use std::ptr;
extern "C" {
fn WasmtimeCallTrampoline(

View File

@@ -2,8 +2,8 @@
//! fields that compiled wasm code accesses directly.
use crate::instance::Instance;
use core::any::Any;
use core::{ptr, u32};
use std::any::Any;
use std::{ptr, u32};
use wasmtime_environ::BuiltinFunctionIndex;
/// An imported function.
@@ -20,8 +20,8 @@ pub struct VMFunctionImport {
#[cfg(test)]
mod test_vmfunction_import {
use super::VMFunctionImport;
use core::mem::size_of;
use memoffset::offset_of;
use std::mem::size_of;
use wasmtime_environ::{Module, VMOffsets};
#[test]
@@ -53,7 +53,7 @@ pub struct VMFunctionBody(u8);
#[cfg(test)]
mod test_vmfunction_body {
use super::VMFunctionBody;
use core::mem::size_of;
use std::mem::size_of;
#[test]
fn check_vmfunction_body_offsets() {
@@ -76,8 +76,8 @@ pub struct VMTableImport {
#[cfg(test)]
mod test_vmtable_import {
use super::VMTableImport;
use core::mem::size_of;
use memoffset::offset_of;
use std::mem::size_of;
use wasmtime_environ::{Module, VMOffsets};
#[test]
@@ -114,8 +114,8 @@ pub struct VMMemoryImport {
#[cfg(test)]
mod test_vmmemory_import {
use super::VMMemoryImport;
use core::mem::size_of;
use memoffset::offset_of;
use std::mem::size_of;
use wasmtime_environ::{Module, VMOffsets};
#[test]
@@ -149,8 +149,8 @@ pub struct VMGlobalImport {
#[cfg(test)]
mod test_vmglobal_import {
use super::VMGlobalImport;
use core::mem::size_of;
use memoffset::offset_of;
use std::mem::size_of;
use wasmtime_environ::{Module, VMOffsets};
#[test]
@@ -184,8 +184,8 @@ pub struct VMMemoryDefinition {
#[cfg(test)]
mod test_vmmemory_definition {
use super::VMMemoryDefinition;
use core::mem::size_of;
use memoffset::offset_of;
use std::mem::size_of;
use wasmtime_environ::{Module, VMOffsets};
#[test]
@@ -228,8 +228,8 @@ pub struct VMTableDefinition {
#[cfg(test)]
mod test_vmtable_definition {
use super::VMTableDefinition;
use core::mem::size_of;
use memoffset::offset_of;
use std::mem::size_of;
use wasmtime_environ::{Module, VMOffsets};
#[test]
@@ -265,8 +265,8 @@ pub struct VMGlobalDefinition {
#[cfg(test)]
mod test_vmglobal_definition {
use super::VMGlobalDefinition;
use core::mem::{align_of, size_of};
use more_asserts::assert_ge;
use std::mem::{align_of, size_of};
use wasmtime_environ::{Module, VMOffsets};
#[test]
@@ -432,7 +432,7 @@ pub struct VMSharedSignatureIndex(u32);
#[cfg(test)]
mod test_vmshared_signature_index {
use super::VMSharedSignatureIndex;
use core::mem::size_of;
use std::mem::size_of;
use wasmtime_environ::{Module, TargetSharedSignatureIndex, VMOffsets};
#[test]
@@ -485,8 +485,8 @@ pub struct VMCallerCheckedAnyfunc {
#[cfg(test)]
mod test_vmcaller_checked_anyfunc {
use super::VMCallerCheckedAnyfunc;
use core::mem::size_of;
use memoffset::offset_of;
use std::mem::size_of;
use wasmtime_environ::{Module, VMOffsets};
#[test]
@@ -559,7 +559,7 @@ pub struct VMInvokeArgument([u8; 16]);
#[cfg(test)]
mod test_vm_invoke_argument {
use super::VMInvokeArgument;
use core::mem::{align_of, size_of};
use std::mem::{align_of, size_of};
use wasmtime_environ::{Module, VMOffsets};
#[test]

View File

@@ -3,17 +3,17 @@ use crate::host::{
fd_table, fd_table_init, fd_table_insert_existing,
};
use crate::syscalls;
use alloc::rc::Rc;
use core::cell::RefCell;
use cranelift_codegen::ir::types;
use cranelift_codegen::{ir, isa};
use cranelift_entity::PrimaryMap;
use cranelift_wasm::DefinedFuncIndex;
use std::cell::RefCell;
use std::collections::HashMap;
use std::ffi::CString;
use std::fs::File;
use std::mem;
use std::os::unix::io::AsRawFd;
use std::rc::Rc;
use target_lexicon::HOST;
use wasmtime_environ::{translate_signature, Export, Module};
use wasmtime_runtime::{Imports, InstanceHandle, InstantiationError, VMFunctionBody};

View File

@@ -1,6 +1,3 @@
extern crate alloc;
extern crate core;
mod host;
mod instantiate;
mod syscalls;

View File

@@ -2,9 +2,9 @@ use crate::host::{argv_environ_values, fd_prestats, fd_table};
use crate::instantiate::WASIState;
use crate::translate::*;
use crate::{host, wasm32};
use core::convert::TryFrom;
use cranelift_codegen::ir::types::{Type, I32, I64};
use log::{log_enabled, trace};
use std::convert::TryFrom;
use std::{mem, ptr, slice, str};
use wasmtime_runtime::VMContext;

View File

@@ -1,7 +1,7 @@
use crate::{host, wasm32};
use core::convert::TryFrom;
use log::{debug, error};
use more_asserts::assert_le;
use std::convert::TryFrom;
use std::mem::{align_of, size_of, zeroed};
use std::slice;
use wasmtime_runtime::{Export, VMContext};

View File

@@ -108,7 +108,7 @@ fn bindgen_test_layout_fsid_t() {
concat!("Alignment of ", stringify!(fsid_t))
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<fsid_t>())).__val as *const _ as usize },
unsafe { &(*(std::ptr::null::<fsid_t>())).__val as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
@@ -167,7 +167,7 @@ fn bindgen_test_layout_wasi_dirent_t() {
concat!("Size of: ", stringify!(__wasi_dirent_t))
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_dirent_t>())).d_next as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_dirent_t>())).d_next as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
@@ -177,7 +177,7 @@ fn bindgen_test_layout_wasi_dirent_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_dirent_t>())).d_ino as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_dirent_t>())).d_ino as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
@@ -187,7 +187,7 @@ fn bindgen_test_layout_wasi_dirent_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_dirent_t>())).d_namlen as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_dirent_t>())).d_namlen as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
@@ -197,7 +197,7 @@ fn bindgen_test_layout_wasi_dirent_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_dirent_t>())).d_type as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_dirent_t>())).d_type as *const _ as usize },
20usize,
concat!(
"Offset of field: ",
@@ -249,7 +249,7 @@ fn bindgen_test_layout___wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t>()))
&(*(std::ptr::null::<__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t>()))
.nbytes as *const _ as usize
},
0usize,
@@ -262,7 +262,7 @@ fn bindgen_test_layout___wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t>()))
&(*(std::ptr::null::<__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t>()))
.flags as *const _ as usize
},
8usize,
@@ -288,7 +288,7 @@ fn bindgen_test_layout___wasi_event_t___wasi_event_u() {
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_event_t___wasi_event_u>())).fd_readwrite as *const _
&(*(std::ptr::null::<__wasi_event_t___wasi_event_u>())).fd_readwrite as *const _
as usize
},
0usize,
@@ -313,7 +313,7 @@ fn bindgen_test_layout___wasi_event_t() {
concat!("Alignment of ", stringify!(__wasi_event_t))
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_event_t>())).userdata as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_event_t>())).userdata as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
@@ -323,7 +323,7 @@ fn bindgen_test_layout___wasi_event_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_event_t>())).error as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_event_t>())).error as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
@@ -333,7 +333,7 @@ fn bindgen_test_layout___wasi_event_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_event_t>())).type_ as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_event_t>())).type_ as *const _ as usize },
10usize,
concat!(
"Offset of field: ",
@@ -343,7 +343,7 @@ fn bindgen_test_layout___wasi_event_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_event_t>())).u as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_event_t>())).u as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
@@ -389,7 +389,7 @@ fn bindgen_test_layout___wasi_prestat_t___wasi_prestat_u___wasi_prestat_u_dir_t(
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_prestat_t___wasi_prestat_u___wasi_prestat_u_dir_t>()))
&(*(std::ptr::null::<__wasi_prestat_t___wasi_prestat_u___wasi_prestat_u_dir_t>()))
.pr_name_len as *const _ as usize
},
0usize,
@@ -418,7 +418,7 @@ fn bindgen_test_layout___wasi_prestat_t___wasi_prestat_u() {
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_prestat_t___wasi_prestat_u>())).dir as *const _ as usize
&(*(std::ptr::null::<__wasi_prestat_t___wasi_prestat_u>())).dir as *const _ as usize
},
0usize,
concat!(
@@ -442,7 +442,7 @@ fn bindgen_test_layout___wasi_prestat_t() {
concat!("Alignment of ", stringify!(__wasi_prestat_t))
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_prestat_t>())).pr_type as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_prestat_t>())).pr_type as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
@@ -452,7 +452,7 @@ fn bindgen_test_layout___wasi_prestat_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_prestat_t>())).u as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_prestat_t>())).u as *const _ as usize },
4usize,
concat!(
"Offset of field: ",
@@ -489,8 +489,8 @@ fn bindgen_test_layout_wasi_event_t__bindgen_ty_1__bindgen_ty_1() {
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_event_t__bindgen_ty_1__bindgen_ty_1>())).nbytes
as *const _ as usize
&(*(std::ptr::null::<__wasi_event_t__bindgen_ty_1__bindgen_ty_1>())).nbytes as *const _
as usize
},
0usize,
concat!(
@@ -502,8 +502,8 @@ fn bindgen_test_layout_wasi_event_t__bindgen_ty_1__bindgen_ty_1() {
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_event_t__bindgen_ty_1__bindgen_ty_1>())).flags
as *const _ as usize
&(*(std::ptr::null::<__wasi_event_t__bindgen_ty_1__bindgen_ty_1>())).flags as *const _
as usize
},
8usize,
concat!(
@@ -541,8 +541,8 @@ fn bindgen_test_layout_wasi_event_t__bindgen_ty_1__bindgen_ty_2() {
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_event_t__bindgen_ty_1__bindgen_ty_2>())).signal
as *const _ as usize
&(*(std::ptr::null::<__wasi_event_t__bindgen_ty_1__bindgen_ty_2>())).signal as *const _
as usize
},
0usize,
concat!(
@@ -554,7 +554,7 @@ fn bindgen_test_layout_wasi_event_t__bindgen_ty_1__bindgen_ty_2() {
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_event_t__bindgen_ty_1__bindgen_ty_2>())).exitcode
&(*(std::ptr::null::<__wasi_event_t__bindgen_ty_1__bindgen_ty_2>())).exitcode
as *const _ as usize
},
4usize,
@@ -576,8 +576,7 @@ fn bindgen_test_layout_wasi_event_t__bindgen_ty_1() {
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_event_t__bindgen_ty_1>())).fd_readwrite as *const _
as usize
&(*(std::ptr::null::<__wasi_event_t__bindgen_ty_1>())).fd_readwrite as *const _ as usize
},
0usize,
concat!(
@@ -596,7 +595,7 @@ fn bindgen_test_layout_wasi_event_t() {
concat!("Size of: ", stringify!(__wasi_event_t))
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_event_t>())).userdata as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_event_t>())).userdata as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
@@ -606,7 +605,7 @@ fn bindgen_test_layout_wasi_event_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_event_t>())).error as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_event_t>())).error as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
@@ -616,7 +615,7 @@ fn bindgen_test_layout_wasi_event_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_event_t>())).type_ as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_event_t>())).type_ as *const _ as usize },
10usize,
concat!(
"Offset of field: ",
@@ -643,7 +642,7 @@ fn bindgen_test_layout_wasi_fdstat_t() {
concat!("Size of: ", stringify!(__wasi_fdstat_t))
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_fdstat_t>())).fs_filetype as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_fdstat_t>())).fs_filetype as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
@@ -653,7 +652,7 @@ fn bindgen_test_layout_wasi_fdstat_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_fdstat_t>())).fs_flags as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_fdstat_t>())).fs_flags as *const _ as usize },
2usize,
concat!(
"Offset of field: ",
@@ -663,7 +662,7 @@ fn bindgen_test_layout_wasi_fdstat_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_fdstat_t>())).fs_rights_base as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_fdstat_t>())).fs_rights_base as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
@@ -674,7 +673,7 @@ fn bindgen_test_layout_wasi_fdstat_t() {
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_fdstat_t>())).fs_rights_inheriting as *const _ as usize
&(*(std::ptr::null::<__wasi_fdstat_t>())).fs_rights_inheriting as *const _ as usize
},
16usize,
concat!(
@@ -705,7 +704,7 @@ fn bindgen_test_layout_wasi_filestat_t() {
concat!("Size of: ", stringify!(__wasi_filestat_t))
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_filestat_t>())).st_dev as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_filestat_t>())).st_dev as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
@@ -715,7 +714,7 @@ fn bindgen_test_layout_wasi_filestat_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_filestat_t>())).st_ino as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_filestat_t>())).st_ino as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
@@ -725,7 +724,7 @@ fn bindgen_test_layout_wasi_filestat_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_filestat_t>())).st_filetype as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_filestat_t>())).st_filetype as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
@@ -735,7 +734,7 @@ fn bindgen_test_layout_wasi_filestat_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_filestat_t>())).st_nlink as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_filestat_t>())).st_nlink as *const _ as usize },
20usize,
concat!(
"Offset of field: ",
@@ -745,7 +744,7 @@ fn bindgen_test_layout_wasi_filestat_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_filestat_t>())).st_size as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_filestat_t>())).st_size as *const _ as usize },
24usize,
concat!(
"Offset of field: ",
@@ -755,7 +754,7 @@ fn bindgen_test_layout_wasi_filestat_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_filestat_t>())).st_atim as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_filestat_t>())).st_atim as *const _ as usize },
32usize,
concat!(
"Offset of field: ",
@@ -765,7 +764,7 @@ fn bindgen_test_layout_wasi_filestat_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_filestat_t>())).st_mtim as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_filestat_t>())).st_mtim as *const _ as usize },
40usize,
concat!(
"Offset of field: ",
@@ -775,7 +774,7 @@ fn bindgen_test_layout_wasi_filestat_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_filestat_t>())).st_ctim as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_filestat_t>())).st_ctim as *const _ as usize },
48usize,
concat!(
"Offset of field: ",
@@ -804,7 +803,7 @@ fn bindgen_test_layout_wasi_ciovec_t() {
concat!("Alignment of ", stringify!(__wasi_ciovec_t))
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_ciovec_t>())).buf as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_ciovec_t>())).buf as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
@@ -814,7 +813,7 @@ fn bindgen_test_layout_wasi_ciovec_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_ciovec_t>())).buf_len as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_ciovec_t>())).buf_len as *const _ as usize },
4usize,
concat!(
"Offset of field: ",
@@ -843,7 +842,7 @@ fn bindgen_test_layout_wasi_iovec_t() {
concat!("Alignment of ", stringify!(__wasi_iovec_t))
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_iovec_t>())).buf as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_iovec_t>())).buf as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
@@ -853,7 +852,7 @@ fn bindgen_test_layout_wasi_iovec_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_iovec_t>())).buf_len as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_iovec_t>())).buf_len as *const _ as usize },
4usize,
concat!(
"Offset of field: ",
@@ -914,7 +913,7 @@ fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u___wasi_subscr
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<
&(*(std::ptr::null::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
>()))
.identifier as *const _ as usize
@@ -929,7 +928,7 @@ fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u___wasi_subscr
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<
&(*(std::ptr::null::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
>()))
.clock_id as *const _ as usize
@@ -944,7 +943,7 @@ fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u___wasi_subscr
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<
&(*(std::ptr::null::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
>()))
.timeout as *const _ as usize
@@ -959,7 +958,7 @@ fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u___wasi_subscr
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<
&(*(std::ptr::null::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
>()))
.precision as *const _ as usize
@@ -974,7 +973,7 @@ fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u___wasi_subscr
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<
&(*(std::ptr::null::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
>()))
.flags as *const _ as usize
@@ -1022,7 +1021,7 @@ fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u___wasi_subscr
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<
&(*(std::ptr::null::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t,
>()))
.fd as *const _ as usize
@@ -1058,8 +1057,8 @@ fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u() {
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_subscription_t___wasi_subscription_u>())).clock
as *const _ as usize
&(*(std::ptr::null::<__wasi_subscription_t___wasi_subscription_u>())).clock as *const _
as usize
},
0usize,
concat!(
@@ -1071,7 +1070,7 @@ fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u() {
);
assert_eq!(
unsafe {
&(*(::core::ptr::null::<__wasi_subscription_t___wasi_subscription_u>())).fd_readwrite
&(*(std::ptr::null::<__wasi_subscription_t___wasi_subscription_u>())).fd_readwrite
as *const _ as usize
},
0usize,
@@ -1096,7 +1095,7 @@ fn bindgen_test_layout___wasi_subscription_t() {
concat!("Alignment of ", stringify!(__wasi_subscription_t))
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_subscription_t>())).userdata as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_subscription_t>())).userdata as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
@@ -1106,7 +1105,7 @@ fn bindgen_test_layout___wasi_subscription_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_subscription_t>())).type_ as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_subscription_t>())).type_ as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
@@ -1116,7 +1115,7 @@ fn bindgen_test_layout___wasi_subscription_t() {
)
);
assert_eq!(
unsafe { &(*(::core::ptr::null::<__wasi_subscription_t>())).u as *const _ as usize },
unsafe { &(*(std::ptr::null::<__wasi_subscription_t>())).u as *const _ as usize },
16usize,
concat!(
"Offset of field: ",

View File

@@ -1,12 +1,12 @@
use super::syscalls;
use alloc::rc::Rc;
use core::cell::RefCell;
use cranelift_codegen::ir::types;
use cranelift_codegen::{ir, isa};
use cranelift_entity::PrimaryMap;
use cranelift_wasm::DefinedFuncIndex;
use std::cell::RefCell;
use std::collections::HashMap;
use std::fs::File;
use std::rc::Rc;
use target_lexicon::HOST;
use wasi_common::{WasiCtx, WasiCtxBuilder};
use wasmtime_api as api;

View File

@@ -1,7 +1,5 @@
#![allow(improper_ctypes)]
extern crate alloc;
mod instantiate;
mod syscalls;

View File

@@ -22,8 +22,6 @@
)
)]
extern crate alloc;
mod spectest;
mod wast;

View File

@@ -1,12 +1,12 @@
#![allow(improper_ctypes)]
use alloc::rc::Rc;
use core::cell::RefCell;
use cranelift_codegen::ir::types;
use cranelift_codegen::{ir, isa};
use cranelift_entity::PrimaryMap;
use cranelift_wasm::{DefinedFuncIndex, Global, GlobalInit, Memory, Table, TableElementType};
use std::cell::RefCell;
use std::collections::hash_map::HashMap;
use std::rc::Rc;
use target_lexicon::HOST;
use wasmtime_environ::{translate_signature, Export, MemoryPlan, Module, TablePlan};
use wasmtime_jit::target_tunables;