Rename to wasmtime. It's wasmtime!
Also, update to Cretonne 0.13.0.
This commit is contained in:
26
Cargo.toml
26
Cargo.toml
@@ -1,15 +1,15 @@
|
||||
[package]
|
||||
name = "wasmstandalone_tools"
|
||||
name = "wasmtime_tools"
|
||||
authors = ["The Cretonne Project Developers"]
|
||||
version = "0.0.0"
|
||||
description = "Command-line interface for the wasmstandalone crate"
|
||||
description = "Command-line interface for the wasmtime crate"
|
||||
license = "MIT/Apache-2.0"
|
||||
documentation = "https://cretonne.readthedocs.io/"
|
||||
repository = "https://github.com/sunfishcode/wasmstandalone"
|
||||
repository = "https://github.com/sunfishcode/wasmtime"
|
||||
publish = false
|
||||
|
||||
[[bin]]
|
||||
name = "wasmstandalone"
|
||||
name = "wasmtime"
|
||||
path = "src/main.rs"
|
||||
|
||||
[[bin]]
|
||||
@@ -17,18 +17,18 @@ name = "wasm2obj"
|
||||
path = "src/wasm2obj.rs"
|
||||
|
||||
[dependencies]
|
||||
cretonne-codegen = "0.9.0"
|
||||
cretonne-frontend = "0.9.0"
|
||||
cretonne-reader = "0.9.0"
|
||||
cretonne-wasm = "0.9.0"
|
||||
cretonne-native = "0.9.0"
|
||||
wasmstandalone_runtime = { path = "lib/runtime" }
|
||||
wasmstandalone_execute = { path = "lib/execute" }
|
||||
wasmstandalone_obj = { path = "lib/obj" }
|
||||
cretonne-codegen = "0.13.0"
|
||||
cretonne-frontend = "0.13.0"
|
||||
cretonne-reader = "0.13.0"
|
||||
cretonne-wasm = "0.13.0"
|
||||
cretonne-native = "0.13.0"
|
||||
wasmtime_runtime = { path = "lib/runtime" }
|
||||
wasmtime_execute = { path = "lib/execute" }
|
||||
wasmtime_obj = { path = "lib/obj" }
|
||||
docopt = "1.0.0"
|
||||
serde = "1.0.55"
|
||||
serde_derive = "1.0.55"
|
||||
tempdir = "*"
|
||||
faerie = "0.4.1"
|
||||
faerie = "0.4.2"
|
||||
|
||||
[workspace]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# wasmstandalone
|
||||
# wasmtime
|
||||
Standalone JIT-style runtime support for WebAsssembly code in Cretonne
|
||||
|
||||
*This is a work in progress that is not currently functional.*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "wasmstandalone_fuzz"
|
||||
name = "wasmtime_fuzz"
|
||||
version = "0.0.1"
|
||||
authors = ["The Cretonne Project Developers"]
|
||||
publish = false
|
||||
@@ -7,10 +7,10 @@ publish = false
|
||||
[package.metadata]
|
||||
cargo-fuzz = true
|
||||
|
||||
[dependencies.wasmstandalone_runtime]
|
||||
[dependencies.wasmtime_runtime]
|
||||
path = "../lib/runtime"
|
||||
|
||||
[dependencies.wasmstandalone_execute]
|
||||
[dependencies.wasmtime_execute]
|
||||
path = "../lib/execute"
|
||||
|
||||
[dependencies.cretonne-codegen]
|
||||
|
||||
@@ -5,8 +5,8 @@ extern crate libfuzzer_sys;
|
||||
extern crate cretonne;
|
||||
extern crate cton_wasm;
|
||||
extern crate cton_native;
|
||||
extern crate wasmstandalone_runtime;
|
||||
extern crate wasmstandalone_execute;
|
||||
extern crate wasmtime_runtime;
|
||||
extern crate wasmtime_execute;
|
||||
|
||||
use cretonne::settings;
|
||||
use cton_wasm::translate_module;
|
||||
@@ -16,12 +16,12 @@ fuzz_target!(|data: &[u8]| {
|
||||
panic!("host machine is not a supported target");
|
||||
});
|
||||
let isa = isa_builder.finish(settings::Flags::new(&flag_builder));
|
||||
let mut runtime = wasmstandalone_runtime::Runtime::with_flags(isa.flags().clone());
|
||||
let mut runtime = wasmtime_runtime::Runtime::with_flags(isa.flags().clone());
|
||||
let translation = match translate_module(&data, &mut runtime) {
|
||||
Ok(x) => x,
|
||||
Err(_) => return,
|
||||
};
|
||||
let _exec = match wasmstandalone_execute::compile_module(&translation, &*isa, &runtime) {
|
||||
let _exec = match wasmtime_execute::compile_module(&translation, &*isa, &runtime) {
|
||||
Ok(x) => x,
|
||||
Err(_) => return,
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
[package]
|
||||
name = "wasmstandalone_execute"
|
||||
name = "wasmtime_execute"
|
||||
version = "0.0.0"
|
||||
authors = ["The Cretonne Project Developers"]
|
||||
publish = false
|
||||
description = "JIT-style runtime support for WebAsssembly code in Cretonne"
|
||||
repository = "https://github.com/sunfishcode/wasmstandalone"
|
||||
repository = "https://github.com/sunfishcode/wasmtime"
|
||||
license = "MIT/Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
cretonne-codegen = "0.9.0"
|
||||
cretonne-wasm = "0.9.0"
|
||||
cretonne-codegen = "0.13.0"
|
||||
cretonne-wasm = "0.13.0"
|
||||
region = "0.3.0"
|
||||
wasmstandalone_runtime = { path = "../runtime" }
|
||||
wasmtime_runtime = { path = "../runtime" }
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
extern crate cretonne_codegen;
|
||||
extern crate cretonne_wasm;
|
||||
extern crate region;
|
||||
extern crate wasmstandalone_runtime;
|
||||
extern crate wasmtime_runtime;
|
||||
|
||||
use cretonne_codegen::binemit::Reloc;
|
||||
use cretonne_codegen::isa::TargetIsa;
|
||||
@@ -13,13 +13,13 @@ use region::protect;
|
||||
use region::Protection;
|
||||
use std::mem::transmute;
|
||||
use std::ptr::write_unaligned;
|
||||
use wasmstandalone_runtime::Compilation;
|
||||
use wasmtime_runtime::Compilation;
|
||||
|
||||
/// Executes a module that has been translated with the `standalone::Runtime` runtime implementation.
|
||||
pub fn compile_module<'data, 'module>(
|
||||
isa: &TargetIsa,
|
||||
translation: &wasmstandalone_runtime::ModuleTranslation<'data, 'module>,
|
||||
) -> Result<wasmstandalone_runtime::Compilation<'module>, String> {
|
||||
translation: &wasmtime_runtime::ModuleTranslation<'data, 'module>,
|
||||
) -> Result<wasmtime_runtime::Compilation<'module>, String> {
|
||||
debug_assert!(
|
||||
translation.module.start_func.is_none()
|
||||
|| translation.module.start_func.unwrap() >= translation.module.imported_funcs.len(),
|
||||
@@ -35,7 +35,7 @@ pub fn compile_module<'data, 'module>(
|
||||
}
|
||||
|
||||
/// Performs the relocations inside the function bytecode, provided the necessary metadata
|
||||
fn relocate(compilation: &mut Compilation, relocations: &wasmstandalone_runtime::Relocations) {
|
||||
fn relocate(compilation: &mut Compilation, relocations: &wasmtime_runtime::Relocations) {
|
||||
// The relocations are relative to the relocation's address plus four bytes
|
||||
// TODO: Support architectures other than x64, and other reloc kinds.
|
||||
for (i, function_relocs) in relocations.iter().enumerate() {
|
||||
@@ -65,7 +65,7 @@ fn relocate(compilation: &mut Compilation, relocations: &wasmstandalone_runtime:
|
||||
|
||||
/// Create the VmCtx data structure for the JIT'd code to use. This must
|
||||
/// match the VmCtx layout in the runtime.
|
||||
fn make_vmctx(instance: &mut wasmstandalone_runtime::Instance) -> Vec<*mut u8> {
|
||||
fn make_vmctx(instance: &mut wasmtime_runtime::Instance) -> Vec<*mut u8> {
|
||||
let mut memories = Vec::new();
|
||||
let mut vmctx = Vec::new();
|
||||
vmctx.push(instance.globals.as_mut_ptr());
|
||||
@@ -78,8 +78,8 @@ fn make_vmctx(instance: &mut wasmstandalone_runtime::Instance) -> Vec<*mut u8> {
|
||||
|
||||
/// Jumps to the code region of memory and execute the start function of the module.
|
||||
pub fn execute(
|
||||
compilation: &wasmstandalone_runtime::Compilation,
|
||||
instance: &mut wasmstandalone_runtime::Instance,
|
||||
compilation: &wasmtime_runtime::Compilation,
|
||||
instance: &mut wasmtime_runtime::Instance,
|
||||
) -> Result<(), String> {
|
||||
let start_index = compilation
|
||||
.module
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
[package]
|
||||
name = "wasmstandalone_obj"
|
||||
name = "wasmtime_obj"
|
||||
version = "0.0.0"
|
||||
authors = ["The Cretonne Project Developers"]
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
cretonne-codegen = "0.9.0"
|
||||
cretonne-wasm = "0.9.0"
|
||||
wasmstandalone_runtime = { path = "../runtime" }
|
||||
faerie = "0.4.1"
|
||||
cretonne-codegen = "0.13.0"
|
||||
cretonne-wasm = "0.13.0"
|
||||
wasmtime_runtime = { path = "../runtime" }
|
||||
faerie = "0.4.2"
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
use cretonne_codegen::settings;
|
||||
use cretonne_codegen::settings::Configurable;
|
||||
use faerie::Artifact;
|
||||
use wasmstandalone_runtime;
|
||||
use wasmtime_runtime;
|
||||
|
||||
/// Emits a module that has been emitted with the `WasmRuntime` runtime
|
||||
/// implementation to a native object file.
|
||||
pub fn emit_module<'module>(
|
||||
obj: &mut Artifact,
|
||||
compilation: &wasmstandalone_runtime::Compilation<'module>,
|
||||
relocations: &wasmstandalone_runtime::Relocations,
|
||||
compilation: &wasmtime_runtime::Compilation<'module>,
|
||||
relocations: &wasmtime_runtime::Relocations,
|
||||
) -> Result<(), String> {
|
||||
debug_assert!(
|
||||
compilation.module.start_func.is_none()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extern crate cretonne_codegen;
|
||||
extern crate cretonne_wasm;
|
||||
extern crate faerie;
|
||||
extern crate wasmstandalone_runtime;
|
||||
extern crate wasmtime_runtime;
|
||||
|
||||
mod emit_module;
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
[package]
|
||||
name = "wasmstandalone_runtime"
|
||||
name = "wasmtime_runtime"
|
||||
version = "0.0.0"
|
||||
authors = ["The Cretonne Project Developers"]
|
||||
publish = false
|
||||
description = "Standalone runtime support for WebAsssembly code in Cretonne"
|
||||
repository = "https://github.com/sunfishcode/wasmstandalone"
|
||||
repository = "https://github.com/sunfishcode/wasmtime"
|
||||
license = "Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
cretonne-codegen = "0.9.0"
|
||||
cretonne-wasm = "0.9.0"
|
||||
wasmparser = "0.16.1"
|
||||
target-lexicon = "0.0.1"
|
||||
cretonne-codegen = "0.13.0"
|
||||
cretonne-wasm = "0.13.0"
|
||||
wasmparser = "0.17.0"
|
||||
target-lexicon = "0.0.2"
|
||||
|
||||
@@ -23,12 +23,16 @@ use cretonne_codegen::cursor::FuncCursor;
|
||||
use cretonne_codegen::ir;
|
||||
use cretonne_codegen::ir::immediates::Offset32;
|
||||
use cretonne_codegen::ir::types::*;
|
||||
use cretonne_codegen::ir::{AbiParam, ArgumentExtension, ArgumentLoc, ArgumentPurpose, ExtFuncData,
|
||||
ExternalName, FuncRef, Function, InstBuilder, Signature};
|
||||
use cretonne_codegen::ir::{
|
||||
AbiParam, ArgumentExtension, ArgumentLoc, ArgumentPurpose, ExtFuncData, ExternalName, FuncRef,
|
||||
Function, InstBuilder, Signature,
|
||||
};
|
||||
use cretonne_codegen::isa;
|
||||
use cretonne_codegen::settings;
|
||||
use cretonne_wasm::{FuncTranslator, FunctionIndex, Global, GlobalIndex, GlobalValue, Memory,
|
||||
MemoryIndex, SignatureIndex, Table, TableIndex, WasmResult};
|
||||
use cretonne_wasm::{
|
||||
FuncTranslator, FunctionIndex, Global, GlobalIndex, GlobalVariable, Memory, MemoryIndex,
|
||||
SignatureIndex, Table, TableIndex, WasmResult,
|
||||
};
|
||||
use target_lexicon::Triple;
|
||||
|
||||
/// Compute a `ir::ExternalName` for a given wasm function index.
|
||||
@@ -189,10 +193,10 @@ pub struct FuncEnvironment<'module_environment> {
|
||||
pub module: &'module_environment Module,
|
||||
|
||||
/// The Cretonne global holding the base address of the memories vector.
|
||||
pub memories_base: Option<ir::GlobalVar>,
|
||||
pub memories_base: Option<ir::GlobalValue>,
|
||||
|
||||
/// The Cretonne global holding the base address of the globals vector.
|
||||
pub globals_base: Option<ir::GlobalVar>,
|
||||
pub globals_base: Option<ir::GlobalValue>,
|
||||
|
||||
/// The external function declaration for implementing wasm's `current_memory`.
|
||||
pub current_memory_extfunc: Option<FuncRef>,
|
||||
@@ -235,13 +239,13 @@ impl<'module_environment> cretonne_wasm::FuncEnvironment for FuncEnvironment<'mo
|
||||
self.isa.triple()
|
||||
}
|
||||
|
||||
fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalValue {
|
||||
fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalVariable {
|
||||
let ptr_size = self.ptr_size();
|
||||
let globals_base = self.globals_base.unwrap_or_else(|| {
|
||||
let offset = 0 * ptr_size;
|
||||
let offset32 = offset as i32;
|
||||
debug_assert_eq!(offset32 as usize, offset);
|
||||
let new_base = func.create_global_var(ir::GlobalVarData::VMContext {
|
||||
let new_base = func.create_global_value(ir::GlobalValueData::VMContext {
|
||||
offset: Offset32::new(offset32),
|
||||
});
|
||||
self.globals_base = Some(new_base);
|
||||
@@ -250,11 +254,11 @@ impl<'module_environment> cretonne_wasm::FuncEnvironment for FuncEnvironment<'mo
|
||||
let offset = index as usize * 8;
|
||||
let offset32 = offset as i32;
|
||||
debug_assert_eq!(offset32 as usize, offset);
|
||||
let gv = func.create_global_var(ir::GlobalVarData::Deref {
|
||||
let gv = func.create_global_value(ir::GlobalValueData::Deref {
|
||||
base: globals_base,
|
||||
offset: Offset32::new(offset32),
|
||||
});
|
||||
GlobalValue::Memory {
|
||||
GlobalVariable::Memory {
|
||||
gv,
|
||||
ty: self.module.globals[index].ty,
|
||||
}
|
||||
@@ -263,7 +267,7 @@ impl<'module_environment> cretonne_wasm::FuncEnvironment for FuncEnvironment<'mo
|
||||
fn make_heap(&mut self, func: &mut ir::Function, index: MemoryIndex) -> ir::Heap {
|
||||
let ptr_size = self.ptr_size();
|
||||
let memories_base = self.memories_base.unwrap_or_else(|| {
|
||||
let new_base = func.create_global_var(ir::GlobalVarData::VMContext {
|
||||
let new_base = func.create_global_value(ir::GlobalValueData::VMContext {
|
||||
offset: Offset32::new(ptr_size as i32),
|
||||
});
|
||||
self.globals_base = Some(new_base);
|
||||
@@ -272,12 +276,16 @@ impl<'module_environment> cretonne_wasm::FuncEnvironment for FuncEnvironment<'mo
|
||||
let offset = index as usize * ptr_size;
|
||||
let offset32 = offset as i32;
|
||||
debug_assert_eq!(offset32 as usize, offset);
|
||||
let heap_base = func.create_global_var(ir::GlobalVarData::Deref {
|
||||
let heap_base_addr = func.create_global_value(ir::GlobalValueData::Deref {
|
||||
base: memories_base,
|
||||
offset: Offset32::new(offset32),
|
||||
});
|
||||
let heap_base = func.create_global_value(ir::GlobalValueData::Deref {
|
||||
base: heap_base_addr,
|
||||
offset: Offset32::new(0),
|
||||
});
|
||||
let h = func.create_heap(ir::HeapData {
|
||||
base: ir::HeapBase::GlobalVar(heap_base),
|
||||
base: ir::HeapBase::GlobalValue(heap_base),
|
||||
min_size: 0.into(),
|
||||
guard_size: 0x8000_0000.into(),
|
||||
style: ir::HeapStyle::Static {
|
||||
@@ -332,7 +340,7 @@ impl<'module_environment> cretonne_wasm::FuncEnvironment for FuncEnvironment<'mo
|
||||
Ok(pos.ins().call(callee, &real_call_args))
|
||||
}
|
||||
|
||||
fn translate_grow_memory(
|
||||
fn translate_memory_grow(
|
||||
&mut self,
|
||||
mut pos: FuncCursor,
|
||||
index: MemoryIndex,
|
||||
@@ -362,7 +370,7 @@ impl<'module_environment> cretonne_wasm::FuncEnvironment for FuncEnvironment<'mo
|
||||
Ok(*pos.func.dfg.inst_results(call_inst).first().unwrap())
|
||||
}
|
||||
|
||||
fn translate_current_memory(
|
||||
fn translate_memory_size(
|
||||
&mut self,
|
||||
mut pos: FuncCursor,
|
||||
index: MemoryIndex,
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
//! WebAssembly module.
|
||||
|
||||
use cretonne_codegen::ir;
|
||||
use cretonne_wasm::{FunctionIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex,
|
||||
Table, TableIndex};
|
||||
use cretonne_wasm::{
|
||||
FunctionIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex, Table, TableIndex,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Possible values for a WebAssembly table element.
|
||||
|
||||
14
src/main.rs
14
src/main.rs
@@ -1,4 +1,4 @@
|
||||
//! CLI tool to use the functions provided by the [wasmstandalone](../wasmstandalone/index.html)
|
||||
//! CLI tool to use the functions provided by the [wasmtime](../wasmtime/index.html)
|
||||
//! crate.
|
||||
//!
|
||||
//! Reads Wasm binary files (one Wasm module per file), translates the functions' code to Cretonne
|
||||
@@ -9,8 +9,8 @@ extern crate cretonne_codegen;
|
||||
extern crate cretonne_native;
|
||||
extern crate cretonne_wasm;
|
||||
extern crate docopt;
|
||||
extern crate wasmstandalone_execute;
|
||||
extern crate wasmstandalone_runtime;
|
||||
extern crate wasmtime_execute;
|
||||
extern crate wasmtime_runtime;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate tempdir;
|
||||
@@ -29,8 +29,8 @@ use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::process::{exit, Command};
|
||||
use tempdir::TempDir;
|
||||
use wasmstandalone_execute::{compile_module, execute};
|
||||
use wasmstandalone_runtime::{Instance, Module, ModuleEnvironment};
|
||||
use wasmtime_execute::{compile_module, execute};
|
||||
use wasmtime_runtime::{Instance, Module, ModuleEnvironment};
|
||||
|
||||
const USAGE: &str = "
|
||||
Wasm to Cretonne IL translation utility.
|
||||
@@ -38,8 +38,8 @@ Takes a binary WebAssembly module and returns its functions in Cretonne IL forma
|
||||
The translation is dependent on the environment chosen.
|
||||
|
||||
Usage:
|
||||
wasmstandalone [-mop] <file>...
|
||||
wasmstandalone --help | --version
|
||||
wasmtime [-mop] <file>...
|
||||
wasmtime --help | --version
|
||||
|
||||
Options:
|
||||
-o, --optimize runs optimization passes on the translated functions
|
||||
|
||||
@@ -8,8 +8,8 @@ extern crate cretonne_codegen;
|
||||
extern crate cretonne_native;
|
||||
extern crate cretonne_wasm;
|
||||
extern crate docopt;
|
||||
extern crate wasmstandalone_obj;
|
||||
extern crate wasmstandalone_runtime;
|
||||
extern crate wasmtime_obj;
|
||||
extern crate wasmtime_runtime;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate faerie;
|
||||
@@ -26,7 +26,7 @@ use std::io::prelude::*;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use wasmstandalone_obj::emit_module;
|
||||
use wasmtime_obj::emit_module;
|
||||
|
||||
const USAGE: &str = "
|
||||
Wasm to native object translation utility.
|
||||
@@ -90,8 +90,8 @@ fn handle_module(path: PathBuf, output: &str) -> Result<(), String> {
|
||||
});
|
||||
let isa = isa_builder.finish(settings::Flags::new(flag_builder));
|
||||
|
||||
let mut module = wasmstandalone_runtime::Module::new();
|
||||
let mut environ = wasmstandalone_runtime::ModuleEnvironment::new(&*isa, &mut module);
|
||||
let mut module = wasmtime_runtime::Module::new();
|
||||
let mut environ = wasmtime_runtime::ModuleEnvironment::new(&*isa, &mut module);
|
||||
translate_module(&data, &mut environ).map_err(|e| e.to_string())?;
|
||||
|
||||
let mut obj = Artifact::new(isa.triple().clone(), String::from(output));
|
||||
|
||||
Reference in New Issue
Block a user