Begin work on no_std support.
This adds no_std support to a bunch of things, but more work is needed.
This commit is contained in:
@@ -15,6 +15,11 @@ cranelift-entity = "0.24.0"
|
|||||||
cranelift-wasm = "0.24.0"
|
cranelift-wasm = "0.24.0"
|
||||||
memoffset = "0.2.1"
|
memoffset = "0.2.1"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["std"]
|
||||||
|
std = ["cranelift-codegen/std", "cranelift-wasm/std"]
|
||||||
|
core = ["cranelift-codegen/core", "cranelift-wasm/core"]
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
maintenance = { status = "experimental" }
|
maintenance = { status = "experimental" }
|
||||||
travis-ci = { repository = "CraneStation/wasmtime" }
|
travis-ci = { repository = "CraneStation/wasmtime" }
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ use cranelift_codegen::Context;
|
|||||||
use cranelift_entity::{EntityRef, PrimaryMap};
|
use cranelift_entity::{EntityRef, PrimaryMap};
|
||||||
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, FuncTranslator};
|
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, FuncTranslator};
|
||||||
use environ::{get_func_name, ModuleTranslation};
|
use environ::{get_func_name, ModuleTranslation};
|
||||||
|
use std::string::{String, ToString};
|
||||||
|
use std::vec::Vec;
|
||||||
|
|
||||||
/// The result of compiling a WebAssemby module's functions.
|
/// The result of compiling a WebAssemby module's functions.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ use cranelift_wasm::{
|
|||||||
};
|
};
|
||||||
use module::{DataInitializer, Export, LazyContents, Module, TableElements};
|
use module::{DataInitializer, Export, LazyContents, Module, TableElements};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
use std::string::String;
|
||||||
|
use std::vec::Vec;
|
||||||
use vmcontext;
|
use vmcontext;
|
||||||
|
|
||||||
/// Compute a `ir::ExternalName` for a given wasm function index.
|
/// Compute a `ir::ExternalName` for a given wasm function index.
|
||||||
|
|||||||
@@ -3,13 +3,9 @@
|
|||||||
//! the translation the base addresses of regions of memory that will hold the globals, tables and
|
//! the translation the base addresses of regions of memory that will hold the globals, tables and
|
||||||
//! linear memories.
|
//! linear memories.
|
||||||
|
|
||||||
#![deny(
|
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
|
||||||
missing_docs,
|
|
||||||
trivial_numeric_casts,
|
|
||||||
unused_extern_crates,
|
|
||||||
unstable_features
|
|
||||||
)]
|
|
||||||
#![warn(unused_import_braces)]
|
#![warn(unused_import_braces)]
|
||||||
|
#![cfg_attr(feature = "std", deny(unstable_features))]
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
feature = "clippy",
|
feature = "clippy",
|
||||||
plugin(clippy(conf_file = "../../clippy.toml"))
|
plugin(clippy(conf_file = "../../clippy.toml"))
|
||||||
@@ -31,12 +27,17 @@
|
|||||||
use_self
|
use_self
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||||
|
|
||||||
extern crate cranelift_codegen;
|
extern crate cranelift_codegen;
|
||||||
extern crate cranelift_entity;
|
extern crate cranelift_entity;
|
||||||
extern crate cranelift_wasm;
|
extern crate cranelift_wasm;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate memoffset;
|
extern crate memoffset;
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
|
#[macro_use]
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
mod compilation;
|
mod compilation;
|
||||||
mod environ;
|
mod environ;
|
||||||
@@ -46,3 +47,10 @@ mod vmcontext;
|
|||||||
pub use compilation::{compile_module, Compilation, Relocation, RelocationTarget, Relocations};
|
pub use compilation::{compile_module, Compilation, Relocation, RelocationTarget, Relocations};
|
||||||
pub use environ::{ModuleEnvironment, ModuleTranslation};
|
pub use environ::{ModuleEnvironment, ModuleTranslation};
|
||||||
pub use module::{DataInitializer, Module, TableElements};
|
pub use module::{DataInitializer, Module, TableElements};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
|
mod std {
|
||||||
|
pub use alloc::{string, vec};
|
||||||
|
pub use core::*;
|
||||||
|
pub use core::{i32, str, u32};
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ use cranelift_wasm::{
|
|||||||
TableIndex,
|
TableIndex,
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::string::String;
|
||||||
|
use std::vec::Vec;
|
||||||
|
|
||||||
/// A WebAssembly table initializer.
|
/// A WebAssembly table initializer.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ description = "JIT-style execution for WebAsssembly code in Cranelift"
|
|||||||
categories = ["wasm"]
|
categories = ["wasm"]
|
||||||
repository = "https://github.com/CraneStation/wasmtime"
|
repository = "https://github.com/CraneStation/wasmtime"
|
||||||
license = "Apache-2.0 WITH LLVM-exception"
|
license = "Apache-2.0 WITH LLVM-exception"
|
||||||
|
readme = "README.md"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cranelift-codegen = "0.24.0"
|
cranelift-codegen = "0.24.0"
|
||||||
@@ -15,3 +16,12 @@ cranelift-wasm = "0.24.0"
|
|||||||
region = "1.0.0"
|
region = "1.0.0"
|
||||||
wasmtime-environ = { path = "../environ" }
|
wasmtime-environ = { path = "../environ" }
|
||||||
memmap = "0.7.0"
|
memmap = "0.7.0"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["std"]
|
||||||
|
std = ["cranelift-codegen/std", "cranelift-wasm/std"]
|
||||||
|
core = ["cranelift-codegen/core", "cranelift-wasm/core", "wasmtime-environ/core"]
|
||||||
|
|
||||||
|
[badges]
|
||||||
|
maintenance = { status = "experimental" }
|
||||||
|
travis-ci = { repository = "CraneStation/wasmtime" }
|
||||||
|
|||||||
4
lib/execute/README.md
Normal file
4
lib/execute/README.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
This is the `wasmtime-execute` crate, which contains wasm runtime support,
|
||||||
|
supporting the wasm ABI defined by [`wasmtime-environ`].
|
||||||
|
|
||||||
|
[`wasmtime-environ`]: https://crates.io/crates/wasmtime-environ
|
||||||
@@ -8,6 +8,8 @@ use region::protect;
|
|||||||
use region::Protection;
|
use region::Protection;
|
||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
use std::ptr::{self, write_unaligned};
|
use std::ptr::{self, write_unaligned};
|
||||||
|
use std::string::String;
|
||||||
|
use std::vec::Vec;
|
||||||
use wasmtime_environ::{
|
use wasmtime_environ::{
|
||||||
compile_module, Compilation, Module, ModuleTranslation, Relocation, RelocationTarget,
|
compile_module, Compilation, Module, ModuleTranslation, Relocation, RelocationTarget,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use cranelift_entity::EntityRef;
|
|||||||
use cranelift_entity::PrimaryMap;
|
use cranelift_entity::PrimaryMap;
|
||||||
use cranelift_wasm::{GlobalIndex, MemoryIndex, TableIndex};
|
use cranelift_wasm::{GlobalIndex, MemoryIndex, TableIndex};
|
||||||
use memory::LinearMemory;
|
use memory::LinearMemory;
|
||||||
|
use std::vec::Vec;
|
||||||
use wasmtime_environ::{Compilation, DataInitializer, Module, TableElements};
|
use wasmtime_environ::{Compilation, DataInitializer, Module, TableElements};
|
||||||
|
|
||||||
/// An Instance of a WebAssemby module.
|
/// An Instance of a WebAssemby module.
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
//! JIT-style runtime for WebAssembly using Cranelift.
|
//! JIT-style runtime for WebAssembly using Cranelift.
|
||||||
|
|
||||||
#![deny(
|
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
|
||||||
missing_docs,
|
|
||||||
trivial_numeric_casts,
|
|
||||||
unused_extern_crates,
|
|
||||||
unstable_features
|
|
||||||
)]
|
|
||||||
#![warn(unused_import_braces)]
|
#![warn(unused_import_braces)]
|
||||||
|
#![cfg_attr(feature = "std", deny(unstable_features))]
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
feature = "clippy",
|
feature = "clippy",
|
||||||
plugin(clippy(conf_file = "../../clippy.toml"))
|
plugin(clippy(conf_file = "../../clippy.toml"))
|
||||||
@@ -28,6 +24,8 @@
|
|||||||
use_self
|
use_self
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||||
|
|
||||||
extern crate cranelift_codegen;
|
extern crate cranelift_codegen;
|
||||||
extern crate cranelift_entity;
|
extern crate cranelift_entity;
|
||||||
@@ -35,6 +33,9 @@ extern crate cranelift_wasm;
|
|||||||
extern crate memmap;
|
extern crate memmap;
|
||||||
extern crate region;
|
extern crate region;
|
||||||
extern crate wasmtime_environ;
|
extern crate wasmtime_environ;
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
|
#[macro_use]
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
mod execute;
|
mod execute;
|
||||||
mod instance;
|
mod instance;
|
||||||
@@ -42,3 +43,10 @@ mod memory;
|
|||||||
|
|
||||||
pub use execute::{compile_and_link_module, execute};
|
pub use execute::{compile_and_link_module, execute};
|
||||||
pub use instance::Instance;
|
pub use instance::Instance;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
|
mod std {
|
||||||
|
pub use alloc::{string, vec};
|
||||||
|
pub use core::*;
|
||||||
|
pub use core::{i32, str, u32};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user