Merge pull request #534 from sunfishcode/macro_use
Miscellaneous cleanups
This commit is contained in:
@@ -1 +1 @@
|
|||||||
# This file tells tools we use rustfmt. We use the default settings.
|
# This file tells tools we use rustfmt. We use the default settings.
|
||||||
|
|||||||
5
build.rs
5
build.rs
@@ -58,7 +58,10 @@ fn main() -> anyhow::Result<()> {
|
|||||||
)
|
)
|
||||||
.expect("generating tests");
|
.expect("generating tests");
|
||||||
} else {
|
} else {
|
||||||
println!("cargo:warning=The spec testsuite is disabled. To enable, run `git submodule update --remote`.");
|
println!(
|
||||||
|
"cargo:warning=The spec testsuite is disabled. To enable, run `git submodule \
|
||||||
|
update --remote`."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeln!(out, "}}")?;
|
writeln!(out, "}}")?;
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ endif
|
|||||||
|
|
||||||
ifeq (${C_COMP},clang)
|
ifeq (${C_COMP},clang)
|
||||||
CC_COMP = clang++
|
CC_COMP = clang++
|
||||||
LD_GROUP_START =
|
LD_GROUP_START =
|
||||||
LD_GROUP_END =
|
LD_GROUP_END =
|
||||||
else ifeq (${C_COMP},gcc)
|
else ifeq (${C_COMP},gcc)
|
||||||
CC_COMP = g++
|
CC_COMP = g++
|
||||||
LD_GROUP_START = -Wl,--start-group
|
LD_GROUP_START = -Wl,--start-group
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
use crate::r#ref::HostRef;
|
use crate::r#ref::HostRef;
|
||||||
use crate::runtime::Store;
|
use crate::runtime::Store;
|
||||||
|
use crate::trampoline::generate_func_export;
|
||||||
use crate::trap::Trap;
|
use crate::trap::Trap;
|
||||||
use crate::types::FuncType;
|
use crate::types::FuncType;
|
||||||
use crate::values::Val;
|
use crate::values::Val;
|
||||||
use alloc::rc::Rc;
|
use alloc::{rc::Rc, vec::Vec};
|
||||||
use alloc::vec::Vec;
|
|
||||||
|
|
||||||
use crate::trampoline::generate_func_export;
|
|
||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
use wasmtime_jit::InstanceHandle;
|
use wasmtime_jit::InstanceHandle;
|
||||||
use wasmtime_runtime::Export;
|
use wasmtime_runtime::Export;
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use core::cell::{RefCell, RefMut};
|
use core::cell::{RefCell, RefMut};
|
||||||
use core::hash::{Hash, Hasher};
|
use core::hash::{Hash, Hasher};
|
||||||
|
|
||||||
use wasmtime_jit::{CompilationStrategy, Compiler, Features};
|
|
||||||
|
|
||||||
use cranelift_codegen::settings;
|
use cranelift_codegen::settings;
|
||||||
|
use wasmtime_jit::{CompilationStrategy, Compiler, Features};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Context {
|
pub struct Context {
|
||||||
|
|||||||
@@ -4,14 +4,10 @@ use crate::module::Module;
|
|||||||
use crate::r#ref::HostRef;
|
use crate::r#ref::HostRef;
|
||||||
use crate::runtime::Store;
|
use crate::runtime::Store;
|
||||||
use crate::{HashMap, HashSet};
|
use crate::{HashMap, HashSet};
|
||||||
use alloc::borrow::ToOwned;
|
|
||||||
use alloc::boxed::Box;
|
|
||||||
use alloc::rc::Rc;
|
|
||||||
use alloc::string::{String, ToString};
|
use alloc::string::{String, ToString};
|
||||||
use alloc::vec::Vec;
|
use alloc::{borrow::ToOwned, boxed::Box, rc::Rc, vec::Vec};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
|
||||||
use wasmtime_jit::{instantiate, Resolver};
|
use wasmtime_jit::{instantiate, Resolver};
|
||||||
use wasmtime_runtime::{Export, InstanceHandle};
|
use wasmtime_runtime::{Export, InstanceHandle};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ mod values;
|
|||||||
|
|
||||||
pub mod wasm;
|
pub mod wasm;
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
pub use crate::callable::Callable;
|
pub use crate::callable::Callable;
|
||||||
|
|||||||
@@ -4,11 +4,8 @@ use crate::types::{
|
|||||||
ExportType, ExternType, FuncType, GlobalType, ImportType, Limits, MemoryType, Mutability,
|
ExportType, ExternType, FuncType, GlobalType, ImportType, Limits, MemoryType, Mutability,
|
||||||
TableType, ValType,
|
TableType, ValType,
|
||||||
};
|
};
|
||||||
use alloc::boxed::Box;
|
use alloc::{boxed::Box, string::String, vec::Vec};
|
||||||
use alloc::string::String;
|
|
||||||
use alloc::vec::Vec;
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use wasmparser::{validate, ExternalKind, ImportSectionEntryType, ModuleReader, SectionCode};
|
use wasmparser::{validate, ExternalKind, ImportSectionEntryType, ModuleReader, SectionCode};
|
||||||
|
|
||||||
fn into_memory_type(mt: wasmparser::MemoryType) -> MemoryType {
|
fn into_memory_type(mt: wasmparser::MemoryType) -> MemoryType {
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
use crate::HashMap;
|
|
||||||
use alloc::boxed::Box;
|
|
||||||
use alloc::rc::Rc;
|
|
||||||
use alloc::string::String;
|
|
||||||
use core::cell::RefCell;
|
|
||||||
|
|
||||||
use crate::context::{create_compiler, Context};
|
use crate::context::{create_compiler, Context};
|
||||||
use crate::r#ref::HostRef;
|
use crate::r#ref::HostRef;
|
||||||
|
use crate::HashMap;
|
||||||
|
use alloc::{boxed::Box, rc::Rc, string::String};
|
||||||
|
use core::cell::RefCell;
|
||||||
use cranelift_codegen::{ir, settings};
|
use cranelift_codegen::{ir, settings};
|
||||||
use wasmtime_jit::{CompilationStrategy, Features};
|
use wasmtime_jit::{CompilationStrategy, Features};
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,18 @@
|
|||||||
//! Support for a calling of an imported function.
|
//! Support for a calling of an imported function.
|
||||||
|
|
||||||
use anyhow::Result;
|
use crate::runtime::Store;
|
||||||
use cranelift_entity::PrimaryMap;
|
|
||||||
use cranelift_wasm::DefinedFuncIndex;
|
|
||||||
//use target_lexicon::HOST;
|
|
||||||
use wasmtime_environ::Module;
|
|
||||||
use wasmtime_runtime::{Imports, InstanceHandle, VMFunctionBody};
|
|
||||||
|
|
||||||
use crate::{HashMap, HashSet};
|
use crate::{HashMap, HashSet};
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
use anyhow::Result;
|
||||||
use core::any::Any;
|
use core::any::Any;
|
||||||
use core::cell::{RefCell, RefMut};
|
use core::cell::{RefCell, RefMut};
|
||||||
|
use cranelift_entity::PrimaryMap;
|
||||||
use crate::runtime::Store;
|
use cranelift_wasm::DefinedFuncIndex;
|
||||||
|
use wasmtime_environ::Module;
|
||||||
|
use wasmtime_runtime::{Imports, InstanceHandle, VMFunctionBody};
|
||||||
|
|
||||||
pub(crate) fn create_handle(
|
pub(crate) fn create_handle(
|
||||||
module: Module,
|
module: Module,
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
//! Support for a calling of an imported function.
|
//! Support for a calling of an imported function.
|
||||||
|
|
||||||
|
use super::create_handle::create_handle;
|
||||||
use crate::r#ref::HostRef;
|
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 anyhow::Result;
|
||||||
use cranelift_codegen::ir::types;
|
use core::cmp;
|
||||||
use cranelift_codegen::ir::{InstBuilder, StackSlotData, StackSlotKind, TrapCode};
|
use cranelift_codegen::ir::{types, InstBuilder, StackSlotData, StackSlotKind, TrapCode};
|
||||||
use cranelift_codegen::Context;
|
use cranelift_codegen::{binemit, ir, isa, Context};
|
||||||
use cranelift_codegen::{binemit, ir, isa};
|
|
||||||
use cranelift_entity::{EntityRef, PrimaryMap};
|
use cranelift_entity::{EntityRef, PrimaryMap};
|
||||||
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
|
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
|
||||||
use cranelift_wasm::{DefinedFuncIndex, FuncIndex};
|
use cranelift_wasm::{DefinedFuncIndex, FuncIndex};
|
||||||
@@ -13,16 +15,6 @@ use wasmtime_environ::{CompiledFunction, Export, Module};
|
|||||||
use wasmtime_jit::CodeMemory;
|
use wasmtime_jit::CodeMemory;
|
||||||
use wasmtime_runtime::{InstanceHandle, VMContext, VMFunctionBody};
|
use wasmtime_runtime::{InstanceHandle, VMContext, VMFunctionBody};
|
||||||
|
|
||||||
use alloc::boxed::Box;
|
|
||||||
use alloc::rc::Rc;
|
|
||||||
use alloc::string::ToString;
|
|
||||||
use alloc::vec::Vec;
|
|
||||||
use core::cmp;
|
|
||||||
|
|
||||||
use crate::{Callable, FuncType, Store, Trap, Val};
|
|
||||||
|
|
||||||
use super::create_handle::create_handle;
|
|
||||||
|
|
||||||
struct TrampolineState {
|
struct TrampolineState {
|
||||||
func: Rc<dyn Callable + 'static>,
|
func: Rc<dyn Callable + 'static>,
|
||||||
trap: Option<HostRef<Trap>>,
|
trap: Option<HostRef<Trap>>,
|
||||||
@@ -58,7 +50,7 @@ unsafe extern "C" fn stub_fn(vmctx: *mut VMContext, call_id: u32, values_vec: *m
|
|||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
for i in 0..returns_len {
|
for i in 0..returns_len {
|
||||||
// TODO check signature.returns[i].value_type ?
|
// TODO check signature.returns[i].value_type ?
|
||||||
returns[i].write_value_to(values_vec.offset(i as isize));
|
returns[i].write_value_to(values_vec.add(i));
|
||||||
}
|
}
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
|
use super::create_handle::create_handle;
|
||||||
|
use crate::{GlobalType, Mutability, Val};
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use cranelift_entity::PrimaryMap;
|
use cranelift_entity::PrimaryMap;
|
||||||
use wasmtime_environ::Module;
|
use wasmtime_environ::Module;
|
||||||
use wasmtime_runtime::{InstanceHandle, VMGlobalDefinition};
|
use wasmtime_runtime::{InstanceHandle, VMGlobalDefinition};
|
||||||
|
|
||||||
use super::create_handle::create_handle;
|
|
||||||
use crate::{GlobalType, Mutability, Val};
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub struct GlobalState {
|
pub struct GlobalState {
|
||||||
definition: Box<VMGlobalDefinition>,
|
definition: Box<VMGlobalDefinition>,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use super::create_handle::create_handle;
|
||||||
|
use crate::MemoryType;
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@@ -5,9 +7,6 @@ use cranelift_entity::PrimaryMap;
|
|||||||
use wasmtime_environ::Module;
|
use wasmtime_environ::Module;
|
||||||
use wasmtime_runtime::InstanceHandle;
|
use wasmtime_runtime::InstanceHandle;
|
||||||
|
|
||||||
use super::create_handle::create_handle;
|
|
||||||
use crate::MemoryType;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
||||||
pub fn create_handle_with_memory(memory: &MemoryType) -> Result<InstanceHandle> {
|
pub fn create_handle_with_memory(memory: &MemoryType) -> Result<InstanceHandle> {
|
||||||
|
|||||||
@@ -6,15 +6,14 @@ mod global;
|
|||||||
mod memory;
|
mod memory;
|
||||||
mod table;
|
mod table;
|
||||||
|
|
||||||
use crate::r#ref::HostRef;
|
|
||||||
use alloc::rc::Rc;
|
|
||||||
use anyhow::Result;
|
|
||||||
|
|
||||||
use self::func::create_handle_with_function;
|
use self::func::create_handle_with_function;
|
||||||
use self::global::create_global;
|
use self::global::create_global;
|
||||||
use self::memory::create_handle_with_memory;
|
use self::memory::create_handle_with_memory;
|
||||||
use self::table::create_handle_with_table;
|
use self::table::create_handle_with_table;
|
||||||
use super::{Callable, FuncType, GlobalType, MemoryType, Store, TableType, Val};
|
use super::{Callable, FuncType, GlobalType, MemoryType, Store, TableType, Val};
|
||||||
|
use crate::r#ref::HostRef;
|
||||||
|
use alloc::rc::Rc;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
pub use self::global::GlobalState;
|
pub use self::global::GlobalState;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use super::create_handle::create_handle;
|
||||||
|
use crate::{TableType, ValType};
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@@ -6,9 +8,6 @@ use cranelift_wasm::TableElementType;
|
|||||||
use wasmtime_environ::Module;
|
use wasmtime_environ::Module;
|
||||||
use wasmtime_runtime::InstanceHandle;
|
use wasmtime_runtime::InstanceHandle;
|
||||||
|
|
||||||
use super::create_handle::create_handle;
|
|
||||||
use crate::{TableType, ValType};
|
|
||||||
|
|
||||||
pub fn create_handle_with_table(table: &TableType) -> Result<InstanceHandle> {
|
pub fn create_handle_with_table(table: &TableType) -> Result<InstanceHandle> {
|
||||||
let mut module = Module::new();
|
let mut module = Module::new();
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ use crate::r#ref::{AnyRef, HostRef};
|
|||||||
use crate::runtime::Store;
|
use crate::runtime::Store;
|
||||||
use crate::types::ValType;
|
use crate::types::ValType;
|
||||||
use core::ptr;
|
use core::ptr;
|
||||||
|
|
||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
use wasmtime_jit::RuntimeValue;
|
use wasmtime_jit::RuntimeValue;
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use core::mem;
|
use core::{mem, ptr, slice};
|
||||||
use core::ptr;
|
|
||||||
use core::slice;
|
|
||||||
|
|
||||||
macro_rules! declare_vec {
|
macro_rules! declare_vec {
|
||||||
($name:ident, $elem_ty:path) => {
|
($name:ident, $elem_ty:path) => {
|
||||||
@@ -460,13 +458,13 @@ pub unsafe extern "C" fn wasm_func_call(
|
|||||||
let func = (*func).func.borrow();
|
let func = (*func).func.borrow();
|
||||||
let mut params = Vec::with_capacity(func.param_arity());
|
let mut params = Vec::with_capacity(func.param_arity());
|
||||||
for i in 0..func.param_arity() {
|
for i in 0..func.param_arity() {
|
||||||
let val = &(*args.offset(i as isize));
|
let val = &(*args.add(i));
|
||||||
params.push(val.val());
|
params.push(val.val());
|
||||||
}
|
}
|
||||||
match func.call(¶ms) {
|
match func.call(¶ms) {
|
||||||
Ok(out) => {
|
Ok(out) => {
|
||||||
for i in 0..func.result_arity() {
|
for i in 0..func.result_arity() {
|
||||||
let val = &mut (*results.offset(i as isize));
|
let val = &mut (*results.add(i));
|
||||||
*val = wasm_val_t::from_val(&out[i]);
|
*val = wasm_val_t::from_val(&out[i]);
|
||||||
}
|
}
|
||||||
ptr::null_mut()
|
ptr::null_mut()
|
||||||
@@ -666,7 +664,7 @@ pub unsafe extern "C" fn wasm_instance_new(
|
|||||||
let store = &(*store).store;
|
let store = &(*store).store;
|
||||||
let mut externs: Vec<Extern> = Vec::with_capacity((*module).imports.len());
|
let mut externs: Vec<Extern> = Vec::with_capacity((*module).imports.len());
|
||||||
for i in 0..(*module).imports.len() {
|
for i in 0..(*module).imports.len() {
|
||||||
let import = *imports.offset(i as isize);
|
let import = *imports.add(i);
|
||||||
externs.push((*import).ext.clone());
|
externs.push((*import).ext.clone());
|
||||||
}
|
}
|
||||||
let module = &(*module).module;
|
let module = &(*module).module;
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
use alloc::boxed::Box;
|
use alloc::{boxed::Box, string::String, vec::Vec};
|
||||||
use alloc::string::String;
|
|
||||||
use alloc::vec::Vec;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use wasmparser::{self, ModuleReader, SectionCode};
|
|
||||||
|
|
||||||
use gimli;
|
|
||||||
|
|
||||||
use gimli::{
|
use gimli::{
|
||||||
DebugAbbrev, DebugAddr, DebugInfo, DebugLine, DebugLineStr, DebugLoc, DebugLocLists,
|
DebugAbbrev, DebugAddr, DebugInfo, DebugLine, DebugLineStr, DebugLoc, DebugLocLists,
|
||||||
DebugRanges, DebugRngLists, DebugStr, DebugStrOffsets, DebugTypes, EndianSlice, LittleEndian,
|
DebugRanges, DebugRngLists, DebugStr, DebugStrOffsets, DebugTypes, EndianSlice, LittleEndian,
|
||||||
LocationLists, RangeLists,
|
LocationLists, RangeLists,
|
||||||
};
|
};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use wasmparser::{self, ModuleReader, SectionCode};
|
||||||
|
|
||||||
trait Reader: gimli::Reader<Offset = usize, Endian = LittleEndian> {}
|
trait Reader: gimli::Reader<Offset = usize, Endian = LittleEndian> {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
use crate::HashMap;
|
|
||||||
use alloc::vec::Vec;
|
|
||||||
use failure::Error;
|
|
||||||
|
|
||||||
use gimli;
|
|
||||||
|
|
||||||
use gimli::{AttributeValue, DebugLineOffset, DebugStr, DebuggingInformationEntry, UnitOffset};
|
|
||||||
|
|
||||||
use gimli::write;
|
|
||||||
|
|
||||||
use super::address_transform::AddressTransform;
|
use super::address_transform::AddressTransform;
|
||||||
use super::expression::{compile_expression, CompiledExpression, FunctionFrameInfo};
|
use super::expression::{compile_expression, CompiledExpression, FunctionFrameInfo};
|
||||||
use super::range_info_builder::RangeInfoBuilder;
|
use super::range_info_builder::RangeInfoBuilder;
|
||||||
use super::unit::PendingDieRef;
|
use super::unit::PendingDieRef;
|
||||||
use super::{DebugInputContext, Reader, TransformError};
|
use super::{DebugInputContext, Reader, TransformError};
|
||||||
|
use crate::HashMap;
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
use failure::Error;
|
||||||
|
use gimli::{
|
||||||
|
write, AttributeValue, DebugLineOffset, DebugStr, DebuggingInformationEntry, UnitOffset,
|
||||||
|
};
|
||||||
|
|
||||||
pub(crate) enum FileAttributeContext<'a> {
|
pub(crate) enum FileAttributeContext<'a> {
|
||||||
Root(Option<DebugLineOffset>),
|
Root(Option<DebugLineOffset>),
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ use cranelift_codegen::ValueLabelsRanges;
|
|||||||
use cranelift_entity::EntityRef;
|
use cranelift_entity::EntityRef;
|
||||||
use cranelift_wasm::{get_vmctx_value_label, DefinedFuncIndex};
|
use cranelift_wasm::{get_vmctx_value_label, DefinedFuncIndex};
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use gimli::write;
|
use gimli::{self, write, Expression, Operation, Reader, ReaderOffset, Register, X86_64};
|
||||||
use gimli::{self, Expression, Operation, Reader, ReaderOffset, Register, X86_64};
|
|
||||||
use more_asserts::{assert_le, assert_lt};
|
use more_asserts::{assert_le, assert_lt};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ use alloc::vec::Vec;
|
|||||||
use core::iter::FromIterator;
|
use core::iter::FromIterator;
|
||||||
use cranelift_entity::EntityRef;
|
use cranelift_entity::EntityRef;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use gimli;
|
use gimli::{
|
||||||
use gimli::write;
|
write, DebugLine, DebugLineOffset, DebugStr, DebuggingInformationEntry, LineEncoding, Unit,
|
||||||
use gimli::{DebugLine, DebugLineOffset, DebugStr, DebuggingInformationEntry, LineEncoding, Unit};
|
};
|
||||||
use more_asserts::assert_le;
|
use more_asserts::assert_le;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
use crate::gc::build_dependencies;
|
use crate::gc::build_dependencies;
|
||||||
use crate::DebugInfoData;
|
use crate::{DebugInfoData, HashSet};
|
||||||
use crate::HashSet;
|
|
||||||
use cranelift_codegen::isa::TargetFrontendConfig;
|
use cranelift_codegen::isa::TargetFrontendConfig;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
use gimli::{
|
||||||
|
write, DebugAddr, DebugAddrBase, DebugLine, DebugStr, LocationLists, RangeLists,
|
||||||
|
UnitSectionOffset,
|
||||||
|
};
|
||||||
use simulate::generate_simulated_dwarf;
|
use simulate::generate_simulated_dwarf;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
use unit::clone_unit;
|
||||||
use wasmtime_environ::{ModuleAddressMap, ModuleVmctxInfo, ValueLabelsRanges};
|
use wasmtime_environ::{ModuleAddressMap, ModuleVmctxInfo, ValueLabelsRanges};
|
||||||
|
|
||||||
use gimli;
|
|
||||||
|
|
||||||
use gimli::{
|
|
||||||
DebugAddr, DebugAddrBase, DebugLine, DebugStr, LocationLists, RangeLists, UnitSectionOffset,
|
|
||||||
};
|
|
||||||
|
|
||||||
use gimli::write;
|
|
||||||
|
|
||||||
pub use address_transform::AddressTransform;
|
pub use address_transform::AddressTransform;
|
||||||
|
|
||||||
use unit::clone_unit;
|
|
||||||
|
|
||||||
mod address_transform;
|
mod address_transform;
|
||||||
mod attr;
|
mod attr;
|
||||||
mod expression;
|
mod expression;
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
use super::address_transform::AddressTransform;
|
use super::address_transform::AddressTransform;
|
||||||
use super::DebugInputContext;
|
use super::{DebugInputContext, Reader};
|
||||||
use super::Reader;
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use cranelift_entity::EntityRef;
|
use cranelift_entity::EntityRef;
|
||||||
use cranelift_wasm::DefinedFuncIndex;
|
use cranelift_wasm::DefinedFuncIndex;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use gimli;
|
use gimli::{write, AttributeValue, DebuggingInformationEntry, RangeListsOffset};
|
||||||
use gimli::write;
|
|
||||||
use gimli::{AttributeValue, DebuggingInformationEntry, RangeListsOffset};
|
|
||||||
use more_asserts::assert_lt;
|
use more_asserts::assert_lt;
|
||||||
|
|
||||||
pub(crate) enum RangeInfoBuilder {
|
pub(crate) enum RangeInfoBuilder {
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
|
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::read_debuginfo::WasmFileInfo;
|
||||||
pub use crate::read_debuginfo::{DebugInfoData, FunctionMetadata, WasmType};
|
|
||||||
use crate::{HashMap, HashSet};
|
use crate::{HashMap, HashSet};
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use cranelift_entity::EntityRef;
|
use cranelift_entity::EntityRef;
|
||||||
use cranelift_wasm::get_vmctx_value_label;
|
use cranelift_wasm::get_vmctx_value_label;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
use gimli::write;
|
||||||
|
use gimli::{self, LineEncoding};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use wasmtime_environ::{ModuleVmctxInfo, ValueLabelsRanges};
|
use wasmtime_environ::{ModuleVmctxInfo, ValueLabelsRanges};
|
||||||
|
|
||||||
use gimli::write;
|
pub use crate::read_debuginfo::{DebugInfoData, FunctionMetadata, WasmType};
|
||||||
use gimli::{self, LineEncoding};
|
|
||||||
|
|
||||||
use super::expression::{CompiledExpression, FunctionFrameInfo};
|
|
||||||
use super::utils::{add_internal_types, append_vmctx_info, get_function_frame_info};
|
|
||||||
use super::AddressTransform;
|
|
||||||
|
|
||||||
const PRODUCER_NAME: &str = "wasmtime";
|
const PRODUCER_NAME: &str = "wasmtime";
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
use crate::{HashMap, HashSet};
|
|
||||||
use alloc::string::String;
|
|
||||||
use alloc::vec::Vec;
|
|
||||||
use cranelift_entity::EntityRef;
|
|
||||||
use failure::Error;
|
|
||||||
use wasmtime_environ::{ModuleVmctxInfo, ValueLabelsRanges};
|
|
||||||
|
|
||||||
use gimli;
|
|
||||||
|
|
||||||
use gimli::{AttributeValue, DebuggingInformationEntry, Unit, UnitOffset};
|
|
||||||
|
|
||||||
use gimli::write;
|
|
||||||
|
|
||||||
use super::address_transform::AddressTransform;
|
use super::address_transform::AddressTransform;
|
||||||
use super::attr::{clone_die_attributes, FileAttributeContext};
|
use super::attr::{clone_die_attributes, FileAttributeContext};
|
||||||
use super::expression::compile_expression;
|
use super::expression::compile_expression;
|
||||||
@@ -18,6 +5,13 @@ use super::line_program::clone_line_program;
|
|||||||
use super::range_info_builder::RangeInfoBuilder;
|
use super::range_info_builder::RangeInfoBuilder;
|
||||||
use super::utils::{add_internal_types, append_vmctx_info, get_function_frame_info};
|
use super::utils::{add_internal_types, append_vmctx_info, get_function_frame_info};
|
||||||
use super::{DebugInputContext, Reader, TransformError};
|
use super::{DebugInputContext, Reader, TransformError};
|
||||||
|
use crate::{HashMap, HashSet};
|
||||||
|
use alloc::{string::String, vec::Vec};
|
||||||
|
use cranelift_entity::EntityRef;
|
||||||
|
use failure::Error;
|
||||||
|
use gimli::write;
|
||||||
|
use gimli::{AttributeValue, DebuggingInformationEntry, Unit, UnitOffset};
|
||||||
|
use wasmtime_environ::{ModuleVmctxInfo, ValueLabelsRanges};
|
||||||
|
|
||||||
pub(crate) type PendingDieRef = (write::UnitEntryId, gimli::DwAt, UnitOffset);
|
pub(crate) type PendingDieRef = (write::UnitEntryId, gimli::DwAt, UnitOffset);
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
|
use super::address_transform::AddressTransform;
|
||||||
|
use super::expression::{CompiledExpression, FunctionFrameInfo};
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use cranelift_wasm::DefinedFuncIndex;
|
use cranelift_wasm::DefinedFuncIndex;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use wasmtime_environ::{ModuleVmctxInfo, ValueLabelsRanges};
|
|
||||||
|
|
||||||
use gimli;
|
|
||||||
use gimli::write;
|
use gimli::write;
|
||||||
|
use wasmtime_environ::{ModuleVmctxInfo, ValueLabelsRanges};
|
||||||
use super::address_transform::AddressTransform;
|
|
||||||
use super::expression::{CompiledExpression, FunctionFrameInfo};
|
|
||||||
|
|
||||||
pub(crate) fn add_internal_types(
|
pub(crate) fn add_internal_types(
|
||||||
comp_unit: &mut write::Unit,
|
comp_unit: &mut write::Unit,
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
use alloc::string::String;
|
use alloc::{string::String, vec::Vec};
|
||||||
use alloc::vec::Vec;
|
|
||||||
use gimli::write::{Address, Dwarf, EndianVec, Result, Sections, Writer};
|
|
||||||
use gimli::{RunTimeEndian, SectionId};
|
|
||||||
|
|
||||||
use core::result;
|
use core::result;
|
||||||
use faerie::artifact::{Decl, SectionKind};
|
use faerie::artifact::{Decl, SectionKind};
|
||||||
use faerie::*;
|
use faerie::*;
|
||||||
|
use gimli::write::{Address, Dwarf, EndianVec, Result, Sections, Writer};
|
||||||
|
use gimli::{RunTimeEndian, SectionId};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct DebugReloc {
|
struct DebugReloc {
|
||||||
|
|||||||
57
crates/environ/src/cache/worker.rs
vendored
57
crates/environ/src/cache/worker.rs
vendored
@@ -265,7 +265,11 @@ impl WorkerThread {
|
|||||||
let errno_val = errno::errno().0;
|
let errno_val = errno::errno().0;
|
||||||
|
|
||||||
if errno_val != 0 {
|
if errno_val != 0 {
|
||||||
warn!("Failed to lower worker thread priority. It might affect application performance. errno: {}", errno_val);
|
warn!(
|
||||||
|
"Failed to lower worker thread priority. It might affect application performance. \
|
||||||
|
errno: {}",
|
||||||
|
errno_val
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
debug!("New nice value of worker thread: {}", current_nice);
|
debug!("New nice value of worker thread: {}", current_nice);
|
||||||
}
|
}
|
||||||
@@ -333,12 +337,9 @@ impl WorkerThread {
|
|||||||
.ok()
|
.ok()
|
||||||
})
|
})
|
||||||
.and_then(|cache_bytes| {
|
.and_then(|cache_bytes| {
|
||||||
zstd::encode_all(
|
zstd::encode_all(&cache_bytes[..], opt_compr_lvl)
|
||||||
&cache_bytes[..],
|
.map_err(|err| warn!("Failed to compress cached code: {}", err))
|
||||||
opt_compr_lvl,
|
.ok()
|
||||||
)
|
|
||||||
.map_err(|err| warn!("Failed to compress cached code: {}", err))
|
|
||||||
.ok()
|
|
||||||
})
|
})
|
||||||
.and_then(|recompressed_cache_bytes| {
|
.and_then(|recompressed_cache_bytes| {
|
||||||
fs::write(&lock_path, &recompressed_cache_bytes)
|
fs::write(&lock_path, &recompressed_cache_bytes)
|
||||||
@@ -379,21 +380,31 @@ impl WorkerThread {
|
|||||||
// the cache file and the stats file (they are not updated together atomically)
|
// the cache file and the stats file (they are not updated together atomically)
|
||||||
// Possible solution is to use directories per cache entry, but it complicates the system
|
// Possible solution is to use directories per cache entry, but it complicates the system
|
||||||
// and is not worth it.
|
// and is not worth it.
|
||||||
debug!("DETECTED task did more than once (or race with new file): recompression of {}. \
|
debug!(
|
||||||
Note: if optimized compression level setting has changed in the meantine, \
|
"DETECTED task did more than once (or race with new file): \
|
||||||
the stats file might contain inconsistent compression level due to race.", path.display());
|
recompression of {}. Note: if optimized compression level setting \
|
||||||
}
|
has changed in the meantine, the stats file might contain \
|
||||||
else {
|
inconsistent compression level due to race.",
|
||||||
|
path.display()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
new_stats.compression_level = opt_compr_lvl;
|
new_stats.compression_level = opt_compr_lvl;
|
||||||
let _ = write_stats_file(stats_path.as_ref(), &new_stats);
|
let _ = write_stats_file(stats_path.as_ref(), &new_stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
if new_stats.usages < stats.usages {
|
if new_stats.usages < stats.usages {
|
||||||
debug!("DETECTED lower usage count (new file or race with counter increasing): file {}", path.display());
|
debug!(
|
||||||
|
"DETECTED lower usage count (new file or race with counter \
|
||||||
|
increasing): file {}",
|
||||||
|
path.display()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
debug!(
|
||||||
debug!("Can't read stats file again to update compression level (it might got cleaned up): file {}", stats_path.display());
|
"Can't read stats file again to update compression level (it might got \
|
||||||
|
cleaned up): file {}",
|
||||||
|
stats_path.display()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -690,11 +701,15 @@ impl WorkerThread {
|
|||||||
add_unrecognized_and!(
|
add_unrecognized_and!(
|
||||||
[file: stats_path],
|
[file: stats_path],
|
||||||
unwrap_or!(
|
unwrap_or!(
|
||||||
mod_metadata.modified(),
|
mod_metadata.modified(),
|
||||||
add_unrecognized_and!([file: stats_path, file: mod_path], continue),
|
add_unrecognized_and!(
|
||||||
"Failed to get mtime, deleting BOTH module cache and stats files",
|
[file: stats_path, file: mod_path],
|
||||||
mod_path
|
continue
|
||||||
)
|
),
|
||||||
|
"Failed to get mtime, deleting BOTH module cache and stats \
|
||||||
|
files",
|
||||||
|
mod_path
|
||||||
|
)
|
||||||
),
|
),
|
||||||
"Failed to get metadata/mtime, deleting the file",
|
"Failed to get metadata/mtime, deleting the file",
|
||||||
stats_path
|
stats_path
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ pub fn link_module(
|
|||||||
if signature != *import_signature {
|
if signature != *import_signature {
|
||||||
// TODO: If the difference is in the calling convention,
|
// TODO: If the difference is in the calling convention,
|
||||||
// we could emit a wrapper function to fix it up.
|
// we could emit a wrapper function to fix it up.
|
||||||
return Err(LinkError(
|
return Err(LinkError(format!(
|
||||||
format!("{}/{}: incompatible import type: exported function with signature {} incompatible with function import with signature {}",
|
"{}/{}: incompatible import type: exported function with signature {} \
|
||||||
module_name, field,
|
incompatible with function import with signature {}",
|
||||||
signature, import_signature)
|
module_name, field, signature, import_signature
|
||||||
));
|
)));
|
||||||
}
|
}
|
||||||
dependencies.insert(unsafe { InstanceHandle::from_vmctx(vmctx) });
|
dependencies.insert(unsafe { InstanceHandle::from_vmctx(vmctx) });
|
||||||
function_imports.push(VMFunctionImport {
|
function_imports.push(VMFunctionImport {
|
||||||
@@ -81,7 +81,8 @@ pub fn link_module(
|
|||||||
let import_table = &module.table_plans[index];
|
let import_table = &module.table_plans[index];
|
||||||
if !is_table_compatible(&table, import_table) {
|
if !is_table_compatible(&table, import_table) {
|
||||||
return Err(LinkError(format!(
|
return Err(LinkError(format!(
|
||||||
"{}/{}: incompatible import type: exported table incompatible with table import",
|
"{}/{}: incompatible import type: exported table incompatible with \
|
||||||
|
table import",
|
||||||
module_name, field,
|
module_name, field,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -119,7 +120,8 @@ pub fn link_module(
|
|||||||
let import_memory = &module.memory_plans[index];
|
let import_memory = &module.memory_plans[index];
|
||||||
if !is_memory_compatible(&memory, import_memory) {
|
if !is_memory_compatible(&memory, import_memory) {
|
||||||
return Err(LinkError(format!(
|
return Err(LinkError(format!(
|
||||||
"{}/{}: incompatible import type: exported memory incompatible with memory import",
|
"{}/{}: incompatible import type: exported memory incompatible with \
|
||||||
|
memory import",
|
||||||
module_name, field
|
module_name, field
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -167,7 +169,8 @@ pub fn link_module(
|
|||||||
Some(export_value) => match export_value {
|
Some(export_value) => match export_value {
|
||||||
Export::Table { .. } | Export::Memory { .. } | Export::Function { .. } => {
|
Export::Table { .. } | Export::Memory { .. } | Export::Function { .. } => {
|
||||||
return Err(LinkError(format!(
|
return Err(LinkError(format!(
|
||||||
"{}/{}: incompatible import type: exported global incompatible with global import",
|
"{}/{}: incompatible import type: exported global incompatible with \
|
||||||
|
global import",
|
||||||
module_name, field
|
module_name, field
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -179,7 +182,8 @@ pub fn link_module(
|
|||||||
let imported_global = module.globals[index];
|
let imported_global = module.globals[index];
|
||||||
if !is_global_compatible(&global, &imported_global) {
|
if !is_global_compatible(&global, &imported_global) {
|
||||||
return Err(LinkError(format!(
|
return Err(LinkError(format!(
|
||||||
"{}/{}: incompatible import type: exported global incompatible with global import",
|
"{}/{}: incompatible import type: exported global incompatible with \
|
||||||
|
global import",
|
||||||
module_name, field
|
module_name, field
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -408,6 +412,6 @@ extern "C" {
|
|||||||
pub fn __chkstk();
|
pub fn __chkstk();
|
||||||
// ___chkstk (note the triple underscore) is implemented in compiler-builtins/src/x86_64.rs
|
// ___chkstk (note the triple underscore) is implemented in compiler-builtins/src/x86_64.rs
|
||||||
// by the Rust compiler for the MinGW target
|
// by the Rust compiler for the MinGW target
|
||||||
#[cfg(all(target_os = "windows", target_env = "gnu",))]
|
#[cfg(all(target_os = "windows", target_env = "gnu"))]
|
||||||
pub fn ___chkstk();
|
pub fn ___chkstk();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ fib:
|
|||||||
lea rsp, [rsp + 0x18]
|
lea rsp, [rsp + 0x18]
|
||||||
ja .Lloop
|
ja .Lloop
|
||||||
.Lreturn:
|
.Lreturn:
|
||||||
ret
|
ret
|
||||||
```
|
```
|
||||||
|
|
||||||
Now obviously I'm not advocating for replacing Firefox's optimising compiler with Lightbeam since the latter can only really produce better code when receiving optimised WebAssembly (and so debug-mode or hand-written WebAssembly may produce much worse output). However, this shows that even with the restrictions of a streaming compiler it's absolutely possible to produce high-quality assembly output. For the assembly above, the Lightbeam output runs within 15% of native speed. This is paramount for one of Lightbeam's intended usecases for real-time systems that want good runtime performance but cannot tolerate compiler bombs.
|
Now obviously I'm not advocating for replacing Firefox's optimising compiler with Lightbeam since the latter can only really produce better code when receiving optimised WebAssembly (and so debug-mode or hand-written WebAssembly may produce much worse output). However, this shows that even with the restrictions of a streaming compiler it's absolutely possible to produce high-quality assembly output. For the assembly above, the Lightbeam output runs within 15% of native speed. This is paramount for one of Lightbeam's intended usecases for real-time systems that want good runtime performance but cannot tolerate compiler bombs.
|
||||||
@@ -159,10 +159,10 @@ Now obviously I'm not advocating for replacing Firefox's optimising compiler wit
|
|||||||
## Specification compliance
|
## Specification compliance
|
||||||
|
|
||||||
Lightbeam passes 100% of the specification test suite, but that doesn't necessarily mean that it's 100% specification-compliant. Hopefully as we run a fuzzer against it we can find any issues and get Lightbeam to a state where it can be used in production.
|
Lightbeam passes 100% of the specification test suite, but that doesn't necessarily mean that it's 100% specification-compliant. Hopefully as we run a fuzzer against it we can find any issues and get Lightbeam to a state where it can be used in production.
|
||||||
|
|
||||||
## Getting involved
|
## Getting involved
|
||||||
|
|
||||||
Our [issue tracker][issue tracker] is pretty barren right now since this is currently more-or-less a one-person project, but if you want to get involved jump into the [CraneStation Gitter room][cranestation-gitter] and someone can direct you to the right place. I wish I could say "the most useful thing you can do is play with it and open issues where you find problems" but until it passes the spec suite that won't be very helpful.
|
You can file issues in the [Wasmtime issue tracker][issue tracker]. If you want to get involved jump into the [CraneStation Gitter room][cranestation-gitter] and someone can direct you to the right place. I wish I could say "the most useful thing you can do is play with it and open issues where you find problems" but until it passes the spec suite that won't be very helpful.
|
||||||
|
|
||||||
[cranestation-gitter]: https://gitter.im/CraneStation/Lobby
|
[cranestation-gitter]: https://gitter.im/CraneStation/Lobby
|
||||||
[issue tracker]: https://github.com/CraneStation/lightbeam/issues
|
[Wasmtime issue tracker]: https://github.com/CraneStation/wasmtime/issues
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
extern crate lightbeam;
|
|
||||||
|
|
||||||
use lightbeam::translate;
|
use lightbeam::translate;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ where
|
|||||||
actual_regs.mark_used(*gpr);
|
actual_regs.mark_used(*gpr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert_eq!(actual_regs, ctx.block_state.regs,);
|
assert_eq!(actual_regs, ctx.block_state.regs);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -486,7 +486,11 @@ where
|
|||||||
|
|
||||||
if block.calling_convention.is_some() {
|
if block.calling_convention.is_some() {
|
||||||
let new_cc = block.calling_convention.clone();
|
let new_cc = block.calling_convention.clone();
|
||||||
assert!(cc.is_none() || cc == new_cc, "Can't pass different params to different elements of `br_table` yet");
|
assert!(
|
||||||
|
cc.is_none() || cc == new_cc,
|
||||||
|
"Can't pass different params to different elements of `br_table` \
|
||||||
|
yet"
|
||||||
|
);
|
||||||
cc = new_cc;
|
cc = new_cc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,22 +504,22 @@ where
|
|||||||
.to_drop
|
.to_drop
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|t| t.clone().count())
|
.map(|t| t.clone().count())
|
||||||
.unwrap_or_default() as u32
|
.unwrap_or_default() as u32,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let cc = cc.map(|cc| {
|
let cc = cc
|
||||||
match cc {
|
.map(|cc| match cc {
|
||||||
Left(cc) => Left(ctx.serialize_block_args(&cc, max_params)),
|
Left(cc) => Left(ctx.serialize_block_args(&cc, max_params)),
|
||||||
Right(cc) => Right(cc),
|
Right(cc) => Right(cc),
|
||||||
}
|
})
|
||||||
}).unwrap_or_else(||
|
.unwrap_or_else(|| {
|
||||||
if max_num_callers.map(|callers| callers <= 1).unwrap_or(false) {
|
if max_num_callers.map(|callers| callers <= 1).unwrap_or(false) {
|
||||||
Right(ctx.virtual_calling_convention())
|
Right(ctx.virtual_calling_convention())
|
||||||
} else {
|
} else {
|
||||||
Left(ctx.serialize_args(max_params))
|
Left(ctx.serialize_args(max_params))
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
|
|
||||||
for target in targets.iter().chain(std::iter::once(&default)).unique() {
|
for target in targets.iter().chain(std::iter::once(&default)).unique() {
|
||||||
let block = blocks.get_mut(&target.target).unwrap();
|
let block = blocks.get_mut(&target.target).unwrap();
|
||||||
|
|||||||
@@ -1,19 +1,6 @@
|
|||||||
#![cfg_attr(test, feature(test))]
|
#![cfg_attr(test, feature(test))]
|
||||||
#![feature(proc_macro_hygiene)]
|
#![feature(proc_macro_hygiene)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate smallvec;
|
|
||||||
extern crate capstone;
|
|
||||||
extern crate either;
|
|
||||||
pub extern crate wasmparser;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate memoffset;
|
|
||||||
extern crate dynasm;
|
|
||||||
extern crate dynasmrt;
|
|
||||||
extern crate itertools;
|
|
||||||
// Just so we can implement `Signature` for `cranelift_codegen::ir::Signature`
|
|
||||||
extern crate cranelift_codegen;
|
|
||||||
extern crate multi_mut;
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::module::{ModuleContext, SigType, Signature};
|
use crate::module::{ModuleContext, SigType, Signature};
|
||||||
use smallvec::SmallVec;
|
use smallvec::{smallvec, SmallVec};
|
||||||
use std::{
|
use std::{
|
||||||
convert::TryInto,
|
convert::TryInto,
|
||||||
fmt,
|
fmt,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use cranelift_codegen::{
|
|||||||
ir::{self, AbiParam, Signature as CraneliftSignature},
|
ir::{self, AbiParam, Signature as CraneliftSignature},
|
||||||
isa,
|
isa,
|
||||||
};
|
};
|
||||||
|
use memoffset::offset_of;
|
||||||
use more_asserts::assert_le;
|
use more_asserts::assert_le;
|
||||||
use wasmparser::{FuncType, MemoryType, ModuleReader, SectionCode, Type};
|
use wasmparser::{FuncType, MemoryType, ModuleReader, SectionCode, Type};
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn gcd(m_: u32, n_: u32) -> u32
|
pub extern "C" fn gcd(m_: u32, n_: u32) -> u32 {
|
||||||
{
|
let mut m = m_;
|
||||||
let mut m = m_;
|
let mut n = n_;
|
||||||
let mut n = n_;
|
while m > 0 {
|
||||||
while m > 0 {
|
let tmp = m;
|
||||||
let tmp = m;
|
m = n % m;
|
||||||
m = n % m;
|
n = tmp;
|
||||||
n = tmp;
|
}
|
||||||
}
|
return n;
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn test() -> u32 {
|
pub extern "C" fn test() -> u32 {
|
||||||
gcd(24, 9)
|
gcd(24, 9)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn answer() -> u32;
|
fn answer() -> u32;
|
||||||
}
|
}
|
||||||
@@ -8,8 +7,8 @@ extern "C" {
|
|||||||
static mut PLACE: u32 = 23;
|
static mut PLACE: u32 = 23;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn bar() -> *const u32 {
|
pub extern "C" fn bar() -> *const u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
PLACE = answer();
|
PLACE = answer();
|
||||||
// Return a pointer to the exported memory.
|
// Return a pointer to the exported memory.
|
||||||
(&PLACE) as *const u32
|
(&PLACE) as *const u32
|
||||||
|
|||||||
@@ -2,14 +2,12 @@
|
|||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
|
||||||
use pyo3::types::PyTuple;
|
|
||||||
|
|
||||||
use crate::value::{pyobj_to_value, value_to_pyobj};
|
use crate::value::{pyobj_to_value, value_to_pyobj};
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
|
||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
|
use pyo3::prelude::*;
|
||||||
|
use pyo3::types::PyTuple;
|
||||||
use wasmtime_interface_types::ModuleData;
|
use wasmtime_interface_types::ModuleData;
|
||||||
use wasmtime_jit::{Context, InstanceHandle};
|
use wasmtime_jit::{Context, InstanceHandle};
|
||||||
use wasmtime_runtime::Export;
|
use wasmtime_runtime::Export;
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
|
||||||
use pyo3::types::{PyAny, PyDict, PyTuple};
|
|
||||||
|
|
||||||
use crate::function::Function;
|
use crate::function::Function;
|
||||||
use crate::memory::Memory;
|
use crate::memory::Memory;
|
||||||
use crate::value::{read_value_from, write_value_to};
|
use crate::value::{read_value_from, write_value_to};
|
||||||
|
use alloc::rc::Rc;
|
||||||
|
use core::cell::RefCell;
|
||||||
|
use core::cmp;
|
||||||
use cranelift_codegen::ir::types;
|
use cranelift_codegen::ir::types;
|
||||||
use cranelift_codegen::ir::{InstBuilder, StackSlotData, StackSlotKind};
|
use cranelift_codegen::ir::{InstBuilder, StackSlotData, StackSlotKind};
|
||||||
use cranelift_codegen::Context;
|
use cranelift_codegen::Context;
|
||||||
@@ -15,16 +15,14 @@ use cranelift_codegen::{binemit, ir, isa};
|
|||||||
use cranelift_entity::{EntityRef, PrimaryMap};
|
use cranelift_entity::{EntityRef, PrimaryMap};
|
||||||
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
|
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
|
||||||
use cranelift_wasm::{DefinedFuncIndex, FuncIndex};
|
use cranelift_wasm::{DefinedFuncIndex, FuncIndex};
|
||||||
|
use pyo3::prelude::*;
|
||||||
|
use pyo3::types::{PyAny, PyDict, PyTuple};
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
use target_lexicon::HOST;
|
use target_lexicon::HOST;
|
||||||
use wasmtime_environ::{CompiledFunction, Export, Module};
|
use wasmtime_environ::{CompiledFunction, Export, Module};
|
||||||
use wasmtime_jit::CodeMemory;
|
use wasmtime_jit::CodeMemory;
|
||||||
use wasmtime_runtime::{Imports, InstanceHandle, VMContext, VMFunctionBody};
|
use wasmtime_runtime::{Imports, InstanceHandle, VMContext, VMFunctionBody};
|
||||||
|
|
||||||
use alloc::rc::Rc;
|
|
||||||
use core::cell::RefCell;
|
|
||||||
use core::cmp;
|
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
|
|
||||||
struct BoundPyFunction {
|
struct BoundPyFunction {
|
||||||
name: String,
|
name: String,
|
||||||
obj: PyObject,
|
obj: PyObject,
|
||||||
@@ -71,12 +69,7 @@ unsafe extern "C" fn stub_fn(vmctx: *mut VMContext, call_id: u32, values_vec: *m
|
|||||||
}
|
}
|
||||||
result.clone_ref(py)
|
result.clone_ref(py)
|
||||||
};
|
};
|
||||||
write_value_to(
|
write_value_to(py, values_vec.add(i), signature.returns[i].value_type, val);
|
||||||
py,
|
|
||||||
values_vec.offset(i as isize),
|
|
||||||
signature.returns[i].value_type,
|
|
||||||
val,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,13 @@
|
|||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
|
||||||
use pyo3::types::PyDict;
|
|
||||||
|
|
||||||
use crate::function::Function;
|
use crate::function::Function;
|
||||||
use crate::memory::Memory;
|
use crate::memory::Memory;
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
use cranelift_codegen::ir::{self, types};
|
||||||
use cranelift_codegen::ir;
|
use pyo3::prelude::*;
|
||||||
use cranelift_codegen::ir::types;
|
use pyo3::types::PyDict;
|
||||||
use wasmtime_environ::Export;
|
use wasmtime_environ::Export;
|
||||||
use wasmtime_interface_types::ModuleData;
|
use wasmtime_interface_types::ModuleData;
|
||||||
use wasmtime_jit::{Context, InstanceHandle};
|
use wasmtime_jit::{Context, InstanceHandle};
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
use pyo3::exceptions::Exception;
|
|
||||||
use pyo3::prelude::*;
|
|
||||||
use pyo3::types::{PyBytes, PyDict, PySet};
|
|
||||||
use pyo3::wrap_pyfunction;
|
|
||||||
|
|
||||||
use crate::import::into_instance_from_obj;
|
use crate::import::into_instance_from_obj;
|
||||||
use crate::instance::Instance;
|
use crate::instance::Instance;
|
||||||
use crate::memory::Memory;
|
use crate::memory::Memory;
|
||||||
use crate::module::Module;
|
use crate::module::Module;
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
use pyo3::exceptions::Exception;
|
||||||
|
use pyo3::prelude::*;
|
||||||
|
use pyo3::types::{PyBytes, PyDict, PySet};
|
||||||
|
use pyo3::wrap_pyfunction;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use wasmtime_interface_types::ModuleData;
|
use wasmtime_interface_types::ModuleData;
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,15 @@
|
|||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
|
use alloc::rc::Rc;
|
||||||
|
use core::cell::RefCell;
|
||||||
|
use core::ptr;
|
||||||
use pyo3::class::PyBufferProtocol;
|
use pyo3::class::PyBufferProtocol;
|
||||||
use pyo3::exceptions::BufferError;
|
use pyo3::exceptions::BufferError;
|
||||||
use pyo3::ffi;
|
use pyo3::ffi;
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
use alloc::rc::Rc;
|
|
||||||
use core::cell::RefCell;
|
|
||||||
use core::ptr;
|
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::os::raw::{c_int, c_void};
|
use std::os::raw::{c_int, c_void};
|
||||||
|
|
||||||
use wasmtime_environ::MemoryPlan;
|
use wasmtime_environ::MemoryPlan;
|
||||||
use wasmtime_jit::{Context, InstanceHandle};
|
use wasmtime_jit::{Context, InstanceHandle};
|
||||||
use wasmtime_runtime::{Export, VMMemoryDefinition, VMMemoryImport};
|
use wasmtime_runtime::{Export, VMMemoryDefinition, VMMemoryImport};
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
|
||||||
|
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
#[pyclass]
|
#[pyclass]
|
||||||
pub struct Module {
|
pub struct Module {
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
//! Utility functions to handle values conversion between abstractions/targets.
|
//! Utility functions to handle values conversion between abstractions/targets.
|
||||||
|
|
||||||
use pyo3::exceptions::Exception;
|
|
||||||
use pyo3::prelude::*;
|
|
||||||
use pyo3::types::PyAny;
|
|
||||||
|
|
||||||
use core::ptr;
|
use core::ptr;
|
||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
|
use pyo3::exceptions::Exception;
|
||||||
|
use pyo3::prelude::*;
|
||||||
|
use pyo3::types::PyAny;
|
||||||
use wasmtime_interface_types::Value;
|
use wasmtime_interface_types::Value;
|
||||||
|
|
||||||
pub fn pyobj_to_value(_: Python, p: &PyAny) -> PyResult<Value> {
|
pub fn pyobj_to_value(_: Python, p: &PyAny) -> PyResult<Value> {
|
||||||
|
|||||||
@@ -24,15 +24,13 @@ use core::any::Any;
|
|||||||
use core::borrow::Borrow;
|
use core::borrow::Borrow;
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
use core::slice;
|
use core::{mem, ptr, slice};
|
||||||
use core::{mem, ptr};
|
use cranelift_entity::{BoxedSlice, EntityRef, PrimaryMap};
|
||||||
use cranelift_entity::EntityRef;
|
|
||||||
use cranelift_entity::{BoxedSlice, PrimaryMap};
|
|
||||||
use cranelift_wasm::{
|
use cranelift_wasm::{
|
||||||
DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex,
|
DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex,
|
||||||
GlobalIndex, GlobalInit, MemoryIndex, SignatureIndex, TableIndex,
|
GlobalIndex, GlobalInit, MemoryIndex, SignatureIndex, TableIndex,
|
||||||
};
|
};
|
||||||
use indexmap;
|
use memoffset::offset_of;
|
||||||
use more_asserts::assert_lt;
|
use more_asserts::assert_lt;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use wasmtime_environ::{DataInitializer, Module, TableElements, VMOffsets};
|
use wasmtime_environ::{DataInitializer, Module, TableElements, VMOffsets};
|
||||||
|
|||||||
@@ -23,10 +23,6 @@
|
|||||||
)]
|
)]
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate memoffset;
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
mod export;
|
mod export;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use crate::vmcontext::VMContext;
|
|||||||
use crate::RwLock;
|
use crate::RwLock;
|
||||||
use core::borrow::{Borrow, BorrowMut};
|
use core::borrow::{Borrow, BorrowMut};
|
||||||
use core::cell::Cell;
|
use core::cell::Cell;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct TrapContext {
|
struct TrapContext {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ pub struct VMFunctionImport {
|
|||||||
mod test_vmfunction_import {
|
mod test_vmfunction_import {
|
||||||
use super::VMFunctionImport;
|
use super::VMFunctionImport;
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
|
use memoffset::offset_of;
|
||||||
use wasmtime_environ::{Module, VMOffsets};
|
use wasmtime_environ::{Module, VMOffsets};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -76,6 +77,7 @@ pub struct VMTableImport {
|
|||||||
mod test_vmtable_import {
|
mod test_vmtable_import {
|
||||||
use super::VMTableImport;
|
use super::VMTableImport;
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
|
use memoffset::offset_of;
|
||||||
use wasmtime_environ::{Module, VMOffsets};
|
use wasmtime_environ::{Module, VMOffsets};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -113,6 +115,7 @@ pub struct VMMemoryImport {
|
|||||||
mod test_vmmemory_import {
|
mod test_vmmemory_import {
|
||||||
use super::VMMemoryImport;
|
use super::VMMemoryImport;
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
|
use memoffset::offset_of;
|
||||||
use wasmtime_environ::{Module, VMOffsets};
|
use wasmtime_environ::{Module, VMOffsets};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -147,6 +150,7 @@ pub struct VMGlobalImport {
|
|||||||
mod test_vmglobal_import {
|
mod test_vmglobal_import {
|
||||||
use super::VMGlobalImport;
|
use super::VMGlobalImport;
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
|
use memoffset::offset_of;
|
||||||
use wasmtime_environ::{Module, VMOffsets};
|
use wasmtime_environ::{Module, VMOffsets};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -181,6 +185,7 @@ pub struct VMMemoryDefinition {
|
|||||||
mod test_vmmemory_definition {
|
mod test_vmmemory_definition {
|
||||||
use super::VMMemoryDefinition;
|
use super::VMMemoryDefinition;
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
|
use memoffset::offset_of;
|
||||||
use wasmtime_environ::{Module, VMOffsets};
|
use wasmtime_environ::{Module, VMOffsets};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -224,6 +229,7 @@ pub struct VMTableDefinition {
|
|||||||
mod test_vmtable_definition {
|
mod test_vmtable_definition {
|
||||||
use super::VMTableDefinition;
|
use super::VMTableDefinition;
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
|
use memoffset::offset_of;
|
||||||
use wasmtime_environ::{Module, VMOffsets};
|
use wasmtime_environ::{Module, VMOffsets};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -480,6 +486,7 @@ pub struct VMCallerCheckedAnyfunc {
|
|||||||
mod test_vmcaller_checked_anyfunc {
|
mod test_vmcaller_checked_anyfunc {
|
||||||
use super::VMCallerCheckedAnyfunc;
|
use super::VMCallerCheckedAnyfunc;
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
|
use memoffset::offset_of;
|
||||||
use wasmtime_environ::{Module, VMOffsets};
|
use wasmtime_environ::{Module, VMOffsets};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
extern crate bindgen;
|
|
||||||
extern crate cmake;
|
|
||||||
|
|
||||||
use cmake::Config;
|
use cmake::Config;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<figure style="overflow:visible;" id="spinner"><div class="spinner"></div><center style="margin-top:0.5em"><strong>WASI</strong></center></figure>
|
<figure style="overflow:visible;" id="spinner"><div class="spinner"></div><center style="margin-top:0.5em"><strong>WASI</strong></center></figure>
|
||||||
<div class="wasi" id="status">Downloading...</div>
|
<div class="wasi" id="status">Downloading...</div>
|
||||||
<div class="wasi">
|
<div class="wasi">
|
||||||
<progress value="0" max="100" id="progress" hidden=1></progress>
|
<progress value="0" max="100" id="progress" hidden=1></progress>
|
||||||
</div>
|
</div>
|
||||||
<img class="wasi" src="WASI-small.png" width="200" height="200" border="0" alt="WASI logo">
|
<img class="wasi" src="WASI-small.png" width="200" height="200" border="0" alt="WASI logo">
|
||||||
<input class="wasi" type="file" id="input" onchange="_handleFiles(this.files)">
|
<input class="wasi" type="file" id="input" onchange="_handleFiles(this.files)">
|
||||||
|
|||||||
@@ -146,11 +146,8 @@ pub fn instantiate_wasi_c(
|
|||||||
let mut wasm_fd = 3;
|
let mut wasm_fd = 3;
|
||||||
for (dir, file) in preopened_dirs {
|
for (dir, file) in preopened_dirs {
|
||||||
assert!(fd_table_insert_existing(curfds, wasm_fd, file.as_raw_fd()));
|
assert!(fd_table_insert_existing(curfds, wasm_fd, file.as_raw_fd()));
|
||||||
assert!(fd_prestats_insert(
|
let dir_cstr = CString::new(dir.as_str()).unwrap();
|
||||||
prestats,
|
assert!(fd_prestats_insert(prestats, dir_cstr.as_ptr(), wasm_fd));
|
||||||
CString::new(dir.as_str()).unwrap().as_ptr(),
|
|
||||||
wasm_fd,
|
|
||||||
));
|
|
||||||
wasm_fd += 1;
|
wasm_fd += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#[macro_use]
|
|
||||||
extern crate log;
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
extern crate core;
|
extern crate core;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use crate::host;
|
|
||||||
use crate::host::{argv_environ_values, fd_prestats, fd_table};
|
use crate::host::{argv_environ_values, fd_prestats, fd_table};
|
||||||
use crate::instantiate::WASIState;
|
use crate::instantiate::WASIState;
|
||||||
use crate::translate::*;
|
use crate::translate::*;
|
||||||
use crate::wasm32;
|
use crate::{host, wasm32};
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
use cranelift_codegen::ir::types::{Type, I32, I64};
|
use cranelift_codegen::ir::types::{Type, I32, I64};
|
||||||
|
use log::{log_enabled, trace};
|
||||||
use std::{mem, ptr, slice, str};
|
use std::{mem, ptr, slice, str};
|
||||||
use wasmtime_runtime::VMContext;
|
use wasmtime_runtime::VMContext;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::host;
|
use crate::{host, wasm32};
|
||||||
use crate::wasm32;
|
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
|
use log::{debug, error};
|
||||||
use more_asserts::assert_le;
|
use more_asserts::assert_le;
|
||||||
use std::mem::{align_of, size_of, zeroed};
|
use std::mem::{align_of, size_of, zeroed};
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
#![allow(clippy::use_self)]
|
#![allow(clippy::use_self)]
|
||||||
use crate::wasi;
|
use crate::wasi;
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::fmt;
|
|
||||||
use std::num::TryFromIntError;
|
use std::num::TryFromIntError;
|
||||||
use std::str;
|
use std::{fmt, str};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Error, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Error, Eq, PartialEq)]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use std::{ffi, io};
|
|||||||
///
|
///
|
||||||
/// Unlike `std::fs::DirEntry`, this API has no `DirEntry::path`, because
|
/// Unlike `std::fs::DirEntry`, this API has no `DirEntry::path`, because
|
||||||
/// absolute paths don't interoperate well with the capability-oriented
|
/// absolute paths don't interoperate well with the capability-oriented
|
||||||
/// security model.
|
/// security model.
|
||||||
///
|
///
|
||||||
/// TODO: Not yet implemented.
|
/// TODO: Not yet implemented.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
use crate::ctx::WasiCtx;
|
use crate::ctx::WasiCtx;
|
||||||
use crate::{wasi, wasi32};
|
use crate::{wasi, wasi32};
|
||||||
use log::trace;
|
use log::trace;
|
||||||
|
|
||||||
use wasi_common_cbindgen::wasi_common_cbindgen;
|
use wasi_common_cbindgen::wasi_common_cbindgen;
|
||||||
|
|
||||||
#[wasi_common_cbindgen]
|
#[wasi_common_cbindgen]
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ pub(crate) fn enc_slice_of_wasi32_uintptr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! dec_enc_scalar {
|
macro_rules! dec_enc_scalar {
|
||||||
( $ty:ident, $dec_byref:ident, $enc_byref:ident) => {
|
($ty:ident, $dec_byref:ident, $enc_byref:ident) => {
|
||||||
pub(crate) fn $dec_byref(memory: &mut [u8], ptr: wasi32::uintptr_t) -> Result<wasi::$ty> {
|
pub(crate) fn $dec_byref(memory: &mut [u8], ptr: wasi32::uintptr_t) -> Result<wasi::$ty> {
|
||||||
dec_int_byref::<wasi::$ty>(memory, ptr)
|
dec_int_byref::<wasi::$ty>(memory, ptr)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@
|
|||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use wig::witx_wasi32_types;
|
|
||||||
|
|
||||||
use crate::wasi::*;
|
use crate::wasi::*;
|
||||||
|
use wig::witx_wasi32_types;
|
||||||
|
|
||||||
pub type uintptr_t = u32;
|
pub type uintptr_t = u32;
|
||||||
pub type size_t = u32;
|
pub type size_t = u32;
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
extern crate wasi_common_cbindgen;
|
|
||||||
|
|
||||||
pub use wasi_common_cbindgen::wasi_common_cbindgen;
|
pub use wasi_common_cbindgen::wasi_common_cbindgen;
|
||||||
|
|
||||||
#[wasi_common_cbindgen]
|
#[wasi_common_cbindgen]
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
extern crate wasi_common_cbindgen;
|
|
||||||
|
|
||||||
pub use wasi_common_cbindgen::wasi_common_cbindgen;
|
pub use wasi_common_cbindgen::wasi_common_cbindgen;
|
||||||
|
|
||||||
#[wasi_common_cbindgen]
|
#[wasi_common_cbindgen]
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
extern crate wasi_common_cbindgen;
|
|
||||||
|
|
||||||
pub use wasi_common_cbindgen::wasi_common_cbindgen;
|
pub use wasi_common_cbindgen::wasi_common_cbindgen;
|
||||||
|
|
||||||
#[wasi_common_cbindgen]
|
#[wasi_common_cbindgen]
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
extern crate wasi_common_cbindgen;
|
|
||||||
|
|
||||||
pub use wasi_common_cbindgen::wasi_common_cbindgen;
|
pub use wasi_common_cbindgen::wasi_common_cbindgen;
|
||||||
|
|
||||||
#[wasi_common_cbindgen]
|
#[wasi_common_cbindgen]
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
extern crate wasi_common_cbindgen;
|
|
||||||
|
|
||||||
pub use wasi_common_cbindgen::wasi_common_cbindgen;
|
pub use wasi_common_cbindgen::wasi_common_cbindgen;
|
||||||
|
|
||||||
#[wasi_common_cbindgen]
|
#[wasi_common_cbindgen]
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
extern crate proc_macro2;
|
|
||||||
extern crate quote;
|
|
||||||
extern crate witx;
|
|
||||||
|
|
||||||
mod raw_types;
|
mod raw_types;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
use crate::{winerror, Result};
|
use crate::{winerror, Result};
|
||||||
|
use bitflags::bitflags;
|
||||||
use cvt::cvt;
|
use cvt::cvt;
|
||||||
use std::ffi::{c_void, OsString};
|
use std::ffi::{c_void, OsString};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|||||||
@@ -21,9 +21,6 @@
|
|||||||
)]
|
)]
|
||||||
#![cfg(windows)]
|
#![cfg(windows)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate bitflags;
|
|
||||||
|
|
||||||
pub mod file;
|
pub mod file;
|
||||||
pub mod time;
|
pub mod time;
|
||||||
pub mod winerror;
|
pub mod winerror;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ The instance's exports can be used at this point. This wasm file has only one ex
|
|||||||
let answer_fn = instance.exports()[0].func().expect("answer function");
|
let answer_fn = instance.exports()[0].func().expect("answer function");
|
||||||
```
|
```
|
||||||
|
|
||||||
The exported function can be called using the `call` method. Remember that in most of the cases,
|
The exported function can be called using the `call` method. Remember that in most of the cases,
|
||||||
a `HostRef<_>` object will be returned, so `borrow()` or `borrow_mut()` method has to be used to refer the
|
a `HostRef<_>` object will be returned, so `borrow()` or `borrow_mut()` method has to be used to refer the
|
||||||
specific object. The exported "answer" function accepts no parameters and returns a single `i32` value.
|
specific object. The exported "answer" function accepts no parameters and returns a single `i32` value.
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ publish = false
|
|||||||
cargo-fuzz = true
|
cargo-fuzz = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wasmtime-environ = { path = "../wasmtime-environ" }
|
wasmtime-environ = { path = "../crates/environ" }
|
||||||
wasmtime-jit = { path = "../wasmtime-jit" }
|
wasmtime-jit = { path = "../crates/jit" }
|
||||||
cranelift-codegen = { version = "0.49", features = ["enable-serde"] }
|
cranelift-codegen = { version = "0.49", features = ["enable-serde"] }
|
||||||
cranelift-wasm = { version = "0.49", features = ["enable-serde"] }
|
cranelift-wasm = { version = "0.49", features = ["enable-serde"] }
|
||||||
cranelift-native = "0.49"
|
cranelift-native = "0.49"
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate libfuzzer_sys;
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
extern crate core;
|
extern crate core;
|
||||||
|
extern crate libfuzzer_sys;
|
||||||
|
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use cranelift_codegen::settings;
|
use cranelift_codegen::settings;
|
||||||
|
use libfuzzer_sys::fuzz_target;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use wasmparser::validate;
|
use wasmparser::validate;
|
||||||
use wasmtime_jit::{CompilationStrategy, CompiledModule, Compiler, NullResolver};
|
use wasmtime_jit::{CompilationStrategy, CompiledModule, Compiler, NullResolver};
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate libfuzzer_sys;
|
extern crate libfuzzer_sys;
|
||||||
extern crate cranelift_codegen;
|
|
||||||
extern crate cranelift_native;
|
|
||||||
extern crate wasmparser;
|
|
||||||
extern crate wasmtime_environ;
|
|
||||||
extern crate wasmtime_jit;
|
|
||||||
|
|
||||||
use cranelift_codegen::settings;
|
use cranelift_codegen::settings;
|
||||||
|
use libfuzzer_sys::fuzz_target;
|
||||||
use wasmparser::validate;
|
use wasmparser::validate;
|
||||||
use wasmtime_jit::{instantiate, CompilationStrategy, Compiler, NullResolver};
|
use wasmtime_jit::{instantiate, CompilationStrategy, Compiler, NullResolver};
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate libfuzzer_sys;
|
extern crate libfuzzer_sys;
|
||||||
extern crate cranelift_codegen;
|
|
||||||
extern crate cranelift_native;
|
|
||||||
extern crate wasmparser;
|
|
||||||
extern crate wasmtime_environ;
|
|
||||||
extern crate wasmtime_jit;
|
|
||||||
|
|
||||||
use cranelift_codegen::settings;
|
use cranelift_codegen::settings;
|
||||||
|
use libfuzzer_sys::fuzz_target;
|
||||||
use wasmtime_jit::{instantiate, CompilationStrategy, Compiler, NullResolver};
|
use wasmtime_jit::{instantiate, CompilationStrategy, Compiler, NullResolver};
|
||||||
|
|
||||||
fuzz_target!(|data: &[u8]| {
|
fuzz_target!(|data: &[u8]| {
|
||||||
|
|||||||
@@ -29,11 +29,9 @@
|
|||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
|
|
||||||
use cranelift_codegen::isa;
|
|
||||||
use cranelift_codegen::settings;
|
|
||||||
use cranelift_codegen::settings::Configurable;
|
use cranelift_codegen::settings::Configurable;
|
||||||
|
use cranelift_codegen::{isa, settings};
|
||||||
use cranelift_entity::EntityRef;
|
use cranelift_entity::EntityRef;
|
||||||
use cranelift_native;
|
|
||||||
use cranelift_wasm::DefinedMemoryIndex;
|
use cranelift_wasm::DefinedMemoryIndex;
|
||||||
use docopt::Docopt;
|
use docopt::Docopt;
|
||||||
use faerie::Artifact;
|
use faerie::Artifact;
|
||||||
@@ -41,21 +39,18 @@ use serde::Deserialize;
|
|||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt::format;
|
use std::fmt::format;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::process;
|
|
||||||
use std::str;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use std::{io, process, str};
|
||||||
use target_lexicon::Triple;
|
use target_lexicon::Triple;
|
||||||
use wasmtime_cli::pick_compilation_strategy;
|
use wasmtime_cli::pick_compilation_strategy;
|
||||||
use wasmtime_debug::{emit_debugsections, read_debuginfo};
|
use wasmtime_debug::{emit_debugsections, read_debuginfo};
|
||||||
#[cfg(feature = "lightbeam")]
|
#[cfg(feature = "lightbeam")]
|
||||||
use wasmtime_environ::Lightbeam;
|
use wasmtime_environ::Lightbeam;
|
||||||
use wasmtime_environ::{cache_create_new_config, cache_init};
|
|
||||||
use wasmtime_environ::{
|
use wasmtime_environ::{
|
||||||
Compiler, Cranelift, ModuleEnvironment, ModuleVmctxInfo, Tunables, VMOffsets,
|
cache_create_new_config, cache_init, Compiler, Cranelift, ModuleEnvironment, ModuleVmctxInfo,
|
||||||
|
Tunables, VMOffsets,
|
||||||
};
|
};
|
||||||
use wasmtime_jit::CompilationStrategy;
|
use wasmtime_jit::CompilationStrategy;
|
||||||
use wasmtime_obj::emit_module;
|
use wasmtime_obj::emit_module;
|
||||||
@@ -67,7 +62,8 @@ The translation is dependent on the environment chosen.
|
|||||||
The default is a dummy environment that produces placeholder values.
|
The default is a dummy environment that produces placeholder values.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
wasm2obj [--target TARGET] [-Odg] [--disable-cache | --cache-config=<cache_config_file>] [--enable-simd] [--lightbeam | --cranelift] <file> -o <output>
|
wasm2obj [--target TARGET] [-Odg] [--disable-cache | --cache-config=<cache_config_file>] \
|
||||||
|
[--enable-simd] [--lightbeam | --cranelift] <file> -o <output>
|
||||||
wasm2obj --create-cache-config [--cache-config=<cache_config_file>]
|
wasm2obj --create-cache-config [--cache-config=<cache_config_file>]
|
||||||
wasm2obj --help | --version
|
wasm2obj --help | --version
|
||||||
|
|
||||||
|
|||||||
@@ -34,13 +34,11 @@ use anyhow::{bail, Context as _, Result};
|
|||||||
use cranelift_codegen::settings;
|
use cranelift_codegen::settings;
|
||||||
use cranelift_codegen::settings::Configurable;
|
use cranelift_codegen::settings::Configurable;
|
||||||
use docopt::Docopt;
|
use docopt::Docopt;
|
||||||
use pretty_env_logger;
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Component;
|
use std::path::{Component, Path};
|
||||||
use std::path::Path;
|
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use wasi_common::preopen_dir;
|
use wasi_common::preopen_dir;
|
||||||
use wasmtime_api::{Config, Engine, HostRef, Instance, Module, Store};
|
use wasmtime_api::{Config, Engine, HostRef, Instance, Module, Store};
|
||||||
@@ -49,10 +47,9 @@ use wasmtime_environ::{cache_create_new_config, cache_init};
|
|||||||
use wasmtime_interface_types::ModuleData;
|
use wasmtime_interface_types::ModuleData;
|
||||||
use wasmtime_jit::Features;
|
use wasmtime_jit::Features;
|
||||||
use wasmtime_wasi::instantiate_wasi;
|
use wasmtime_wasi::instantiate_wasi;
|
||||||
use wasmtime_wast::instantiate_spectest;
|
|
||||||
|
|
||||||
#[cfg(feature = "wasi-c")]
|
#[cfg(feature = "wasi-c")]
|
||||||
use wasmtime_wasi_c::instantiate_wasi_c;
|
use wasmtime_wasi_c::instantiate_wasi_c;
|
||||||
|
use wasmtime_wast::instantiate_spectest;
|
||||||
|
|
||||||
const USAGE: &str = "
|
const USAGE: &str = "
|
||||||
Wasm runner.
|
Wasm runner.
|
||||||
@@ -62,8 +59,12 @@ including calling the start function if one is present. Additional functions
|
|||||||
given with --invoke are then called.
|
given with --invoke are then called.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
wasmtime [-odg] [--enable-simd] [--wasi-c] [--disable-cache | --cache-config=<cache_config_file>] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] [--lightbeam | --cranelift] <file> [<arg>...]
|
wasmtime [-odg] [--enable-simd] [--wasi-c] [--disable-cache | \
|
||||||
wasmtime [-odg] [--enable-simd] [--wasi-c] [--disable-cache | --cache-config=<cache_config_file>] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] --invoke=<fn> [--lightbeam | --cranelift] <file> [<arg>...]
|
--cache-config=<cache_config_file>] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] \
|
||||||
|
[--mapdir=<mapping>...] [--lightbeam | --cranelift] <file> [<arg>...]
|
||||||
|
wasmtime [-odg] [--enable-simd] [--wasi-c] [--disable-cache | \
|
||||||
|
--cache-config=<cache_config_file>] [--env=<env>...] [--dir=<dir>...] \
|
||||||
|
[--mapdir=<mapping>...] --invoke=<fn> [--lightbeam | --cranelift] <file> [<arg>...]
|
||||||
wasmtime --create-cache-config [--cache-config=<cache_config_file>]
|
wasmtime --create-cache-config [--cache-config=<cache_config_file>]
|
||||||
wasmtime --help | --version
|
wasmtime --help | --version
|
||||||
|
|
||||||
@@ -128,7 +129,10 @@ fn compute_preopen_dirs(flag_dir: &[String], flag_mapdir: &[String]) -> Vec<(Str
|
|||||||
for mapdir in flag_mapdir {
|
for mapdir in flag_mapdir {
|
||||||
let parts: Vec<&str> = mapdir.split("::").collect();
|
let parts: Vec<&str> = mapdir.split("::").collect();
|
||||||
if parts.len() != 2 {
|
if parts.len() != 2 {
|
||||||
println!("--mapdir argument must contain exactly one double colon ('::'), separating a guest directory name and a host directory name");
|
println!(
|
||||||
|
"--mapdir argument must contain exactly one double colon ('::'), separating a \
|
||||||
|
guest directory name and a host directory name"
|
||||||
|
);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
let (key, value) = (parts[0], parts[1]);
|
let (key, value) = (parts[0], parts[1]);
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ const USAGE: &str = "
|
|||||||
Wast test runner.
|
Wast test runner.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
wast [-do] [--enable-simd] [--disable-cache | --cache-config=<cache_config_file>] [--lightbeam | --cranelift] <file>...
|
wast [-do] [--enable-simd] [--disable-cache | --cache-config=<cache_config_file>] [--lightbeam \
|
||||||
|
| --cranelift] <file>...
|
||||||
wast --create-cache-config [--cache-config=<cache_config_file>]
|
wast --create-cache-config [--cache-config=<cache_config_file>]
|
||||||
wast --help | --version
|
wast --help | --version
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
use cranelift_native;
|
|
||||||
|
|
||||||
use cranelift_codegen::isa;
|
|
||||||
use cranelift_codegen::settings;
|
|
||||||
use cranelift_codegen::settings::Configurable;
|
use cranelift_codegen::settings::Configurable;
|
||||||
|
use cranelift_codegen::{isa, settings};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use wasmtime_jit::{CompilationStrategy, Compiler, Features};
|
use wasmtime_jit::{CompilationStrategy, Compiler, Features};
|
||||||
use wasmtime_wast::WastContext;
|
use wasmtime_wast::WastContext;
|
||||||
|
|||||||
Reference in New Issue
Block a user