Skip to content

Commit

Permalink
Rename to wasmtime. It's wasmtime!
Browse files Browse the repository at this point in the history
Also, update to Cretonne 0.13.0.
  • Loading branch information
sunfishcode committed Jul 2, 2018
1 parent 73639e4 commit c612d48
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 78 deletions.
26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
[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]]
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]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.*
Expand Down
6 changes: 3 additions & 3 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "wasmstandalone_fuzz"
name = "wasmtime_fuzz"
version = "0.0.1"
authors = ["The Cretonne Project Developers"]
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]
Expand Down
8 changes: 4 additions & 4 deletions fuzz/fuzz_targets/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
};
Expand Down
10 changes: 5 additions & 5 deletions lib/execute/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" }
16 changes: 8 additions & 8 deletions lib/execute/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
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;
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(),
Expand All @@ -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() {
Expand Down Expand Up @@ -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());
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions lib/obj/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 3 additions & 3 deletions lib/obj/src/emit_module.rs
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 1 addition & 1 deletion lib/obj/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
12 changes: 6 additions & 6 deletions lib/runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
38 changes: 23 additions & 15 deletions lib/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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);
Expand All @@ -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,
}
Expand All @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions lib/runtime/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit c612d48

Please sign in to comment.