Update no_std support.
This `no_std` support isn't complete though, as some dependencies don't support it.
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
use crate::compiler::Compiler;
|
||||
use crate::instantiate::SetupError;
|
||||
use core::cmp::max;
|
||||
use core::{fmt, mem, ptr, slice};
|
||||
use cranelift_codegen::ir;
|
||||
use std::cmp::max;
|
||||
use std::string::String;
|
||||
use std::vec::Vec;
|
||||
use std::{fmt, mem, ptr, slice};
|
||||
use wasmtime_runtime::{wasmtime_call_trampoline, Export, Instance};
|
||||
|
||||
/// A runtime value.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Memory management for executable code.
|
||||
|
||||
use core::{cmp, mem};
|
||||
use region;
|
||||
use std::string::String;
|
||||
use std::vec::Vec;
|
||||
use std::{cmp, mem};
|
||||
use wasmtime_runtime::{Mmap, VMFunctionBody};
|
||||
|
||||
/// Memory manager for executable code.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! JIT compilation.
|
||||
|
||||
use super::HashMap;
|
||||
use crate::code_memory::CodeMemory;
|
||||
use crate::instantiate::SetupError;
|
||||
use crate::target_tunables::target_tunables;
|
||||
@@ -11,7 +12,6 @@ use cranelift_entity::PrimaryMap;
|
||||
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
|
||||
use cranelift_wasm::DefinedFuncIndex;
|
||||
use std::boxed::Box;
|
||||
use std::collections::HashMap;
|
||||
use std::string::String;
|
||||
use std::vec::Vec;
|
||||
use wasmtime_environ::cranelift;
|
||||
@@ -95,7 +95,7 @@ impl Compiler {
|
||||
signature: &ir::Signature,
|
||||
value_size: usize,
|
||||
) -> Result<*const VMFunctionBody, SetupError> {
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use super::hash_map::Entry::{Occupied, Vacant};
|
||||
Ok(match self.trampoline_park.entry(callee_address) {
|
||||
Occupied(entry) => *entry.get(),
|
||||
Vacant(entry) => {
|
||||
|
||||
@@ -21,18 +21,26 @@
|
||||
clippy::use_self
|
||||
)
|
||||
)]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![no_std]
|
||||
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[macro_use]
|
||||
extern crate alloc as std;
|
||||
#[cfg(feature = "std")]
|
||||
#[macro_use]
|
||||
extern crate std;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use hashmap_core::{map as hash_map, HashMap};
|
||||
#[cfg(feature = "std")]
|
||||
use std::collections::{hash_map, HashMap};
|
||||
|
||||
#[macro_use]
|
||||
extern crate cranelift_entity;
|
||||
|
||||
use region;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[macro_use]
|
||||
extern crate alloc;
|
||||
use failure;
|
||||
use region;
|
||||
|
||||
#[macro_use]
|
||||
extern crate failure_derive;
|
||||
@@ -57,10 +65,3 @@ pub use crate::target_tunables::target_tunables;
|
||||
// Re-export `Instance` so that users won't need to separately depend on
|
||||
// wasmtime-runtime in common cases.
|
||||
pub use wasmtime_runtime::{Instance, InstantiationError};
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
mod std {
|
||||
pub use alloc::{boxed, rc, string, vec};
|
||||
pub use core::*;
|
||||
pub use core::{i32, str, u32};
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//! Linking for JIT-compiled code.
|
||||
|
||||
use crate::resolver::Resolver;
|
||||
use core::ptr::write_unaligned;
|
||||
use cranelift_codegen::binemit::Reloc;
|
||||
use cranelift_entity::PrimaryMap;
|
||||
use cranelift_wasm::{DefinedFuncIndex, Global, GlobalInit, Memory, Table, TableElementType};
|
||||
use std::ptr::write_unaligned;
|
||||
use std::vec::Vec;
|
||||
use wasmtime_environ::{
|
||||
MemoryPlan, MemoryStyle, Module, Relocation, RelocationTarget, Relocations, TablePlan,
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
//! to exports. This file provides one possible way to manage multiple instances
|
||||
//! and resolve imports to exports among them.
|
||||
|
||||
use super::HashMap;
|
||||
use crate::action::{get, inspect_memory, invoke};
|
||||
use crate::action::{ActionError, ActionOutcome, RuntimeValue};
|
||||
use crate::compiler::Compiler;
|
||||
use crate::resolver::Resolver;
|
||||
use cranelift_entity::PrimaryMap;
|
||||
use std::collections::HashMap;
|
||||
use std::string::String;
|
||||
use wasmtime_runtime::{Export, Instance};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::cmp::min;
|
||||
use core::cmp::min;
|
||||
use target_lexicon::{OperatingSystem, Triple};
|
||||
use wasmtime_environ::Tunables;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user