diff --git a/Cargo.toml b/Cargo.toml index ca777d6c69..6b6e395af2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ path = "src/wasm2obj.rs" [dependencies] cranelift-codegen = "0.18.1" cranelift-native = "0.18.1" -wasmtime-runtime = { path = "lib/runtime" } +wasmtime-environ = { path = "lib/environ" } wasmtime-execute = { path = "lib/execute" } wasmtime-obj = { path = "lib/obj" } docopt = "1.0.0" diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 24ac25240f..84e7623e19 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -8,7 +8,7 @@ publish = false cargo-fuzz = true [dependencies] -wasmtime-runtime = { path = "../lib/runtime" } +wasmtime-environ = { path = "../lib/environ" } wasmtime-execute = { path = "../lib/execute" } cranelift-codegen = "0.18.1" cranelift-wasm = "0.18.1" diff --git a/fuzz/fuzz_targets/compile.rs b/fuzz/fuzz_targets/compile.rs index 03e70a0e86..ad329fc215 100644 --- a/fuzz/fuzz_targets/compile.rs +++ b/fuzz/fuzz_targets/compile.rs @@ -5,13 +5,13 @@ extern crate libfuzzer_sys; extern crate cranelift_codegen; extern crate cranelift_wasm; extern crate cranelift_native; -extern crate wasmtime_runtime; +extern crate wasmtime_environ; extern crate wasmtime_execute; extern crate wasmparser; use cranelift_codegen::settings; use cranelift_wasm::translate_module; -use wasmtime_runtime::{ModuleEnvironment, Module}; +use wasmtime_environ::{ModuleEnvironment, Module}; use wasmparser::{validate}; fuzz_target!(|data: &[u8]| { @@ -23,8 +23,8 @@ fuzz_target!(|data: &[u8]| { }); let isa = isa_builder.finish(settings::Flags::new(flag_builder)); let mut module = Module::new(); - let mut runtime = ModuleEnvironment::new(&*isa, &mut module); - let translation = match translate_module(&data, &mut runtime) { + let mut environment = ModuleEnvironment::new(&*isa, &mut module); + let translation = match translate_module(&data, &mut environment) { Ok(()) => (), Err(_) => return, }; diff --git a/lib/runtime/.gitignore b/lib/environ/.gitignore similarity index 100% rename from lib/runtime/.gitignore rename to lib/environ/.gitignore diff --git a/lib/runtime/Cargo.toml b/lib/environ/Cargo.toml similarity index 72% rename from lib/runtime/Cargo.toml rename to lib/environ/Cargo.toml index c56d17b656..dd1b5ea966 100644 --- a/lib/runtime/Cargo.toml +++ b/lib/environ/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "wasmtime-runtime" +name = "wasmtime-environ" version = "0.0.0" authors = ["The Cranelift Project Developers"] publish = false -description = "Standalone runtime support for WebAsssembly code in Cranelift" +description = "Standalone environment support for WebAsssembly code in Cranelift" repository = "https://github.com/sunfishcode/wasmtime" license = "Apache-2.0 WITH LLVM-exception" diff --git a/lib/runtime/src/compilation.rs b/lib/environ/src/compilation.rs similarity index 98% rename from lib/runtime/src/compilation.rs rename to lib/environ/src/compilation.rs index d849eef0a0..bae21f753e 100644 --- a/lib/runtime/src/compilation.rs +++ b/lib/environ/src/compilation.rs @@ -17,7 +17,7 @@ pub struct Compilation { } impl Compilation { - /// Allocates the runtime data structures with the given flags. + /// Allocates the compilation result with the given function bodies. pub fn new(functions: Vec>) -> Self { Self { functions } } diff --git a/lib/runtime/src/environ.rs b/lib/environ/src/environ.rs similarity index 98% rename from lib/runtime/src/environ.rs rename to lib/environ/src/environ.rs index 07ae4e90a4..26afafd035 100644 --- a/lib/runtime/src/environ.rs +++ b/lib/environ/src/environ.rs @@ -21,8 +21,8 @@ pub fn get_func_name(func_index: FunctionIndex) -> ir::ExternalName { ir::ExternalName::user(0, func_index as u32) } -/// Object containing the standalone runtime information. To be passed after creation as argument -/// to `compile_module`. +/// Object containing the standalone environment information. To be passed after creation as +/// argument to `compile_module`. pub struct ModuleEnvironment<'data, 'module> { /// Compilation setting flags. pub isa: &'module isa::TargetIsa, @@ -35,7 +35,7 @@ pub struct ModuleEnvironment<'data, 'module> { } impl<'data, 'module> ModuleEnvironment<'data, 'module> { - /// Allocates the runtime data structures with the given isa. + /// Allocates the enironment data structures with the given isa. pub fn new(isa: &'module isa::TargetIsa, module: &'module mut Module) -> Self { Self { isa, @@ -119,7 +119,7 @@ impl<'module_environment> FuncEnvironment<'module_environment> { /// This trait is useful for /// `cranelift_wasm::translate_module` because it -/// tells how to translate runtime-dependent wasm instructions. These functions should not be +/// tells how to translate enironment-dependent wasm instructions. These functions should not be /// called by the user. impl<'data, 'module> cranelift_wasm::ModuleEnvironment<'data> for ModuleEnvironment<'data, 'module> diff --git a/lib/runtime/src/lib.rs b/lib/environ/src/lib.rs similarity index 91% rename from lib/runtime/src/lib.rs rename to lib/environ/src/lib.rs index 7907040462..482ac483d2 100644 --- a/lib/runtime/src/lib.rs +++ b/lib/environ/src/lib.rs @@ -1,4 +1,4 @@ -//! Standalone runtime for WebAssembly using Cranelift. Provides functions to translate +//! Standalone environment for WebAssembly using Cranelift. Provides functions to translate //! `get_global`, `set_global`, `current_memory`, `grow_memory`, `call_indirect` that hardcode in //! the translation the base addresses of regions of memory that will hold the globals, tables and //! linear memories. diff --git a/lib/runtime/src/module.rs b/lib/environ/src/module.rs similarity index 100% rename from lib/runtime/src/module.rs rename to lib/environ/src/module.rs diff --git a/lib/execute/Cargo.toml b/lib/execute/Cargo.toml index 471f047df0..38cd37b317 100644 --- a/lib/execute/Cargo.toml +++ b/lib/execute/Cargo.toml @@ -3,7 +3,7 @@ name = "wasmtime-execute" version = "0.0.0" authors = ["The Cranelift Project Developers"] publish = false -description = "JIT-style runtime support for WebAsssembly code in Cranelift" +description = "JIT-style execution for WebAsssembly code in Cranelift" repository = "https://github.com/sunfishcode/wasmtime" license = "Apache-2.0 WITH LLVM-exception" @@ -11,4 +11,4 @@ license = "Apache-2.0 WITH LLVM-exception" cranelift-codegen = "0.18.1" cranelift-wasm = "0.18.1" region = "0.3.0" -wasmtime-runtime = { path = "../runtime" } +wasmtime-environ = { path = "../environ" } diff --git a/lib/execute/src/execute.rs b/lib/execute/src/execute.rs index 3b5c94253b..434067ef08 100644 --- a/lib/execute/src/execute.rs +++ b/lib/execute/src/execute.rs @@ -5,9 +5,10 @@ use region::protect; use region::Protection; use std::mem::transmute; use std::ptr::write_unaligned; -use wasmtime_runtime::{compile_module, Compilation, Module, ModuleTranslation, Relocation}; +use wasmtime_environ::{compile_module, Compilation, Module, ModuleTranslation, Relocation}; -/// Executes a module that has been translated with the `standalone::Runtime` runtime implementation. +/// Executes a module that has been translated with the `wasmtime-environ` environment +/// implementation. pub fn compile_and_link_module<'data, 'module>( isa: &TargetIsa, translation: &ModuleTranslation<'data, 'module>, @@ -56,7 +57,7 @@ fn relocate(compilation: &mut Compilation, relocations: &[Vec]) { } /// Create the VmCtx data structure for the JIT'd code to use. This must -/// match the VmCtx layout in the runtime. +/// match the VmCtx layout in the environment. fn make_vmctx(instance: &mut Instance) -> Vec<*mut u8> { let mut memories = Vec::new(); let mut vmctx = Vec::new(); diff --git a/lib/execute/src/instance.rs b/lib/execute/src/instance.rs index 9ec7f1000b..6ae0909a12 100644 --- a/lib/execute/src/instance.rs +++ b/lib/execute/src/instance.rs @@ -3,7 +3,7 @@ use cranelift_codegen::ir; use cranelift_wasm::GlobalIndex; -use wasmtime_runtime::{DataInitializer, Module, TableElements}; +use wasmtime_environ::{DataInitializer, Module, TableElements}; const PAGE_SIZE: usize = 65536; diff --git a/lib/execute/src/lib.rs b/lib/execute/src/lib.rs index 6898f635ab..55a310cb54 100644 --- a/lib/execute/src/lib.rs +++ b/lib/execute/src/lib.rs @@ -15,7 +15,7 @@ extern crate cranelift_codegen; extern crate cranelift_wasm; extern crate region; -extern crate wasmtime_runtime; +extern crate wasmtime_environ; mod execute; mod instance; diff --git a/lib/obj/Cargo.toml b/lib/obj/Cargo.toml index 247430311b..11398a44a3 100644 --- a/lib/obj/Cargo.toml +++ b/lib/obj/Cargo.toml @@ -7,5 +7,5 @@ license = "Apache-2.0 WITH LLVM-exception" [dependencies] cranelift-codegen = "0.18.1" -wasmtime-runtime = { path = "../runtime" } +wasmtime-environ = { path = "../environ" } faerie = "0.4.4" diff --git a/lib/obj/src/emit_module.rs b/lib/obj/src/emit_module.rs index 2e1d6d0cdd..a66ac5aac2 100644 --- a/lib/obj/src/emit_module.rs +++ b/lib/obj/src/emit_module.rs @@ -1,15 +1,15 @@ use cranelift_codegen::settings; use cranelift_codegen::settings::Configurable; use faerie::Artifact; -use wasmtime_runtime; +use wasmtime_environ::{Module, Compilation, Relocations}; -/// Emits a module that has been emitted with the `WasmRuntime` runtime +/// Emits a module that has been emitted with the `wasmtime-environ` environment /// implementation to a native object file. pub fn emit_module( obj: &mut Artifact, - module: &wasmtime_runtime::Module, - compilation: &wasmtime_runtime::Compilation, - relocations: &wasmtime_runtime::Relocations, + module: &Module, + compilation: &Compilation, + relocations: &Relocations, ) -> Result<(), String> { debug_assert!( module.start_func.is_none() || module.start_func.unwrap() >= module.imported_funcs.len(), diff --git a/lib/obj/src/lib.rs b/lib/obj/src/lib.rs index e7597c5785..d10f409700 100644 --- a/lib/obj/src/lib.rs +++ b/lib/obj/src/lib.rs @@ -1,4 +1,4 @@ -//! Object-file writing library using the wasmtime runtime. +//! Object-file writing library using the wasmtime environment. #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates, unstable_features)] #![warn(unused_import_braces)] @@ -14,7 +14,7 @@ extern crate cranelift_codegen; extern crate faerie; -extern crate wasmtime_runtime; +extern crate wasmtime_environ; mod emit_module; diff --git a/src/main.rs b/src/main.rs index 40c96ee16b..92ed572930 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,7 @@ extern crate cranelift_codegen; extern crate cranelift_native; extern crate docopt; extern crate wasmtime_execute; -extern crate wasmtime_runtime; +extern crate wasmtime_environ; #[macro_use] extern crate serde_derive; extern crate tempdir; @@ -40,7 +40,7 @@ use std::path::PathBuf; use std::process::{exit, Command}; use tempdir::TempDir; use wasmtime_execute::{compile_and_link_module, execute, Instance}; -use wasmtime_runtime::{Module, ModuleEnvironment}; +use wasmtime_environ::{Module, ModuleEnvironment}; const USAGE: &str = " Wasm to Cranelift IL translation utility. diff --git a/src/wasm2obj.rs b/src/wasm2obj.rs index f0c6d5e146..3aada77a58 100644 --- a/src/wasm2obj.rs +++ b/src/wasm2obj.rs @@ -20,7 +20,7 @@ extern crate cranelift_codegen; extern crate cranelift_native; extern crate docopt; extern crate wasmtime_obj; -extern crate wasmtime_runtime; +extern crate wasmtime_environ; #[macro_use] extern crate serde_derive; extern crate faerie; @@ -37,13 +37,13 @@ use std::path::Path; use std::path::PathBuf; use std::process; use wasmtime_obj::emit_module; -use wasmtime_runtime::compile_module; +use wasmtime_environ::{compile_module, Module, ModuleEnvironment}; const USAGE: &str = " Wasm to native object translation utility. Takes a binary WebAssembly module into a native object file. -The translation is dependent on the runtime chosen. -The default is a dummy runtime that produces placeholder values. +The translation is dependent on the environment chosen. +The default is a dummy environment that produces placeholder values. Usage: wasm2obj -o @@ -103,8 +103,8 @@ fn handle_module(path: PathBuf, output: &str) -> Result<(), String> { let mut obj = Artifact::new(isa.triple().clone(), String::from(output)); - let mut module = wasmtime_runtime::Module::new(); - let environ = wasmtime_runtime::ModuleEnvironment::new(&*isa, &mut module); + let mut module = Module::new(); + let environ = ModuleEnvironment::new(&*isa, &mut module); let translation = environ.translate(&data).map_err(|e| e.to_string())?; // FIXME: We need to initialize memory in a way that supports alternate