Rename to wasmtime. It's wasmtime!

Also, update to Cretonne 0.13.0.
This commit is contained in:
Dan Gohman
2018-07-02 16:20:22 -07:00
parent 73639e4557
commit c612d48b33
14 changed files with 87 additions and 78 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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