Browse Source

Begin work on no_std support.

This adds no_std support to a bunch of things, but more work is needed.
pull/28/head
Dan Gohman 6 years ago
parent
commit
e8201d0f93
  1. 5
      lib/environ/Cargo.toml
  2. 2
      lib/environ/src/compilation.rs
  3. 2
      lib/environ/src/environ.rs
  4. 20
      lib/environ/src/lib.rs
  5. 2
      lib/environ/src/module.rs
  6. 10
      lib/execute/Cargo.toml
  7. 4
      lib/execute/README.md
  8. 2
      lib/execute/src/execute.rs
  9. 1
      lib/execute/src/instance.rs
  10. 20
      lib/execute/src/lib.rs

5
lib/environ/Cargo.toml

@ -15,6 +15,11 @@ cranelift-entity = "0.24.0"
cranelift-wasm = "0.24.0"
memoffset = "0.2.1"
[features]
default = ["std"]
std = ["cranelift-codegen/std", "cranelift-wasm/std"]
core = ["cranelift-codegen/core", "cranelift-wasm/core"]
[badges]
maintenance = { status = "experimental" }
travis-ci = { repository = "CraneStation/wasmtime" }

2
lib/environ/src/compilation.rs

@ -9,6 +9,8 @@ use cranelift_codegen::Context;
use cranelift_entity::{EntityRef, PrimaryMap};
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, FuncTranslator};
use environ::{get_func_name, ModuleTranslation};
use std::string::{String, ToString};
use std::vec::Vec;
/// The result of compiling a WebAssemby module's functions.
#[derive(Debug)]

2
lib/environ/src/environ.rs

@ -13,6 +13,8 @@ use cranelift_wasm::{
};
use module::{DataInitializer, Export, LazyContents, Module, TableElements};
use std::mem;
use std::string::String;
use std::vec::Vec;
use vmcontext;
/// Compute a `ir::ExternalName` for a given wasm function index.

20
lib/environ/src/lib.rs

@ -3,13 +3,9 @@
//! the translation the base addresses of regions of memory that will hold the globals, tables and
//! linear memories.
#![deny(
missing_docs,
trivial_numeric_casts,
unused_extern_crates,
unstable_features
)]
#![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"))
@ -31,12 +27,17 @@
use_self
)
)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc))]
extern crate cranelift_codegen;
extern crate cranelift_entity;
extern crate cranelift_wasm;
#[macro_use]
extern crate memoffset;
#[cfg(not(feature = "std"))]
#[macro_use]
extern crate alloc;
mod compilation;
mod environ;
@ -46,3 +47,10 @@ mod vmcontext;
pub use compilation::{compile_module, Compilation, Relocation, RelocationTarget, Relocations};
pub use environ::{ModuleEnvironment, ModuleTranslation};
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};
}

2
lib/environ/src/module.rs

@ -7,6 +7,8 @@ use cranelift_wasm::{
TableIndex,
};
use std::collections::HashMap;
use std::string::String;
use std::vec::Vec;
/// A WebAssembly table initializer.
#[derive(Clone, Debug)]

10
lib/execute/Cargo.toml

@ -7,6 +7,7 @@ description = "JIT-style execution for WebAsssembly code in Cranelift"
categories = ["wasm"]
repository = "https://github.com/CraneStation/wasmtime"
license = "Apache-2.0 WITH LLVM-exception"
readme = "README.md"
[dependencies]
cranelift-codegen = "0.24.0"
@ -15,3 +16,12 @@ cranelift-wasm = "0.24.0"
region = "1.0.0"
wasmtime-environ = { path = "../environ" }
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

@ -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

2
lib/execute/src/execute.rs

@ -8,6 +8,8 @@ use region::protect;
use region::Protection;
use std::mem::transmute;
use std::ptr::{self, write_unaligned};
use std::string::String;
use std::vec::Vec;
use wasmtime_environ::{
compile_module, Compilation, Module, ModuleTranslation, Relocation, RelocationTarget,
};

1
lib/execute/src/instance.rs

@ -6,6 +6,7 @@ use cranelift_entity::EntityRef;
use cranelift_entity::PrimaryMap;
use cranelift_wasm::{GlobalIndex, MemoryIndex, TableIndex};
use memory::LinearMemory;
use std::vec::Vec;
use wasmtime_environ::{Compilation, DataInitializer, Module, TableElements};
/// An Instance of a WebAssemby module.

20
lib/execute/src/lib.rs

@ -1,12 +1,8 @@
//! JIT-style runtime for WebAssembly using Cranelift.
#![deny(
missing_docs,
trivial_numeric_casts,
unused_extern_crates,
unstable_features
)]
#![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"))
@ -28,6 +24,8 @@
use_self
)
)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc))]
extern crate cranelift_codegen;
extern crate cranelift_entity;
@ -35,6 +33,9 @@ extern crate cranelift_wasm;
extern crate memmap;
extern crate region;
extern crate wasmtime_environ;
#[cfg(not(feature = "std"))]
#[macro_use]
extern crate alloc;
mod execute;
mod instance;
@ -42,3 +43,10 @@ mod memory;
pub use execute::{compile_and_link_module, execute};
pub use instance::Instance;
#[cfg(not(feature = "std"))]
mod std {
pub use alloc::{string, vec};
pub use core::*;
pub use core::{i32, str, u32};
}

Loading…
Cancel
Save