diff --git a/.gitignore b/.gitignore index a481ff48e8..ad34d8c47b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,6 @@ tags target Cargo.lock .*.rustfmt -cretonne.dbg* +cranelift.dbg* .mypy_cache rusty-tags.* diff --git a/Cargo.toml b/Cargo.toml index 33a4dc5668..2f34c7f692 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "wasmtime_tools" -authors = ["The Cretonne Project Developers"] +authors = ["The Cranelift Project Developers"] version = "0.0.0" description = "Command-line interface for the wasmtime crate" license = "Apache-2.0 WITH LLVM-exception" -documentation = "https://cretonne.readthedocs.io/" +documentation = "https://cranelift.readthedocs.io/" repository = "https://github.com/sunfishcode/wasmtime" publish = false @@ -17,11 +17,11 @@ name = "wasm2obj" path = "src/wasm2obj.rs" [dependencies] -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" +cranelift-codegen = "0.16.1" +cranelift-frontend = "0.16.1" +cranelift-reader = "0.16.1" +cranelift-wasm = "0.16.1" +cranelift-native = "0.16.1" wasmtime_runtime = { path = "lib/runtime" } wasmtime_execute = { path = "lib/execute" } wasmtime_obj = { path = "lib/obj" } @@ -29,6 +29,6 @@ docopt = "1.0.0" serde = "1.0.55" serde_derive = "1.0.55" tempdir = "*" -faerie = "0.4.2" +faerie = "0.4.4" [workspace] diff --git a/README.md b/README.md index f9c1972232..062ed61fa3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # wasmtime -Standalone JIT-style runtime support for WebAsssembly code in Cretonne +Standalone JIT-style runtime support for WebAsssembly code in Cranelift *This is a work in progress that is not currently functional.* diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 58274f28dc..f1d38346c7 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wasmtime_fuzz" version = "0.0.1" -authors = ["The Cretonne Project Developers"] +authors = ["The Cranelift Project Developers"] publish = false [package.metadata] @@ -13,13 +13,13 @@ path = "../lib/runtime" [dependencies.wasmtime_execute] path = "../lib/execute" -[dependencies.cretonne-codegen] +[dependencies.cranelift-codegen] version = "0.8.0" -[dependencies.cretonne-wasm] +[dependencies.cranelift-wasm] version = "0.8.0" -[dependencies.cretonne-native] +[dependencies.cranelift-native] version = "0.8.0" [dependencies.libfuzzer-sys] diff --git a/fuzz/fuzz_targets/compile.rs b/fuzz/fuzz_targets/compile.rs index 149f64de79..20c80f40b8 100644 --- a/fuzz/fuzz_targets/compile.rs +++ b/fuzz/fuzz_targets/compile.rs @@ -2,17 +2,17 @@ #[macro_use] extern crate libfuzzer_sys; -extern crate cretonne; -extern crate cton_wasm; -extern crate cton_native; +extern crate cranelift; +extern crate cranelift_wasm; +extern crate cranelift_native; extern crate wasmtime_runtime; extern crate wasmtime_execute; -use cretonne::settings; -use cton_wasm::translate_module; +use cranelift::settings; +use cranelift_wasm::translate_module; fuzz_target!(|data: &[u8]| { - let (flag_builder, isa_builder) = cton_native::builders().unwrap_or_else(|_| { + let (flag_builder, isa_builder) = cranelift_native::builders().unwrap_or_else(|_| { panic!("host machine is not a supported target"); }); let isa = isa_builder.finish(settings::Flags::new(&flag_builder)); diff --git a/lib/execute/Cargo.toml b/lib/execute/Cargo.toml index 448980dcdf..cd9c319289 100644 --- a/lib/execute/Cargo.toml +++ b/lib/execute/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "wasmtime_execute" version = "0.0.0" -authors = ["The Cretonne Project Developers"] +authors = ["The Cranelift Project Developers"] publish = false -description = "JIT-style runtime support for WebAsssembly code in Cretonne" +description = "JIT-style runtime support for WebAsssembly code in Cranelift" repository = "https://github.com/sunfishcode/wasmtime" license = "Apache-2.0 WITH LLVM-exception" [dependencies] -cretonne-codegen = "0.13.0" -cretonne-wasm = "0.13.0" +cranelift-codegen = "0.16.1" +cranelift-wasm = "0.16.1" region = "0.3.0" wasmtime_runtime = { path = "../runtime" } diff --git a/lib/execute/src/lib.rs b/lib/execute/src/lib.rs index 7f550c4c85..d1e62803e7 100644 --- a/lib/execute/src/lib.rs +++ b/lib/execute/src/lib.rs @@ -1,14 +1,14 @@ -//! JIT-style runtime for WebAssembly using Cretonne. +//! JIT-style runtime for WebAssembly using Cranelift. #![deny(missing_docs)] -extern crate cretonne_codegen; -extern crate cretonne_wasm; +extern crate cranelift_codegen; +extern crate cranelift_wasm; extern crate region; extern crate wasmtime_runtime; -use cretonne_codegen::binemit::Reloc; -use cretonne_codegen::isa::TargetIsa; +use cranelift_codegen::binemit::Reloc; +use cranelift_codegen::isa::TargetIsa; use region::protect; use region::Protection; use std::mem::transmute; diff --git a/lib/obj/Cargo.toml b/lib/obj/Cargo.toml index d32da2bad9..7ffe459b17 100644 --- a/lib/obj/Cargo.toml +++ b/lib/obj/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "wasmtime_obj" version = "0.0.0" -authors = ["The Cretonne Project Developers"] +authors = ["The Cranelift Project Developers"] publish = false license = "Apache-2.0 WITH LLVM-exception" [dependencies] -cretonne-codegen = "0.13.0" -cretonne-wasm = "0.13.0" +cranelift-codegen = "0.16.1" +cranelift-wasm = "0.16.1" wasmtime_runtime = { path = "../runtime" } -faerie = "0.4.2" +faerie = "0.4.4" diff --git a/lib/obj/src/emit_module.rs b/lib/obj/src/emit_module.rs index b0af0b4da1..c54a151151 100644 --- a/lib/obj/src/emit_module.rs +++ b/lib/obj/src/emit_module.rs @@ -1,5 +1,5 @@ -use cretonne_codegen::settings; -use cretonne_codegen::settings::Configurable; +use cranelift_codegen::settings; +use cranelift_codegen::settings::Configurable; use faerie::Artifact; use wasmtime_runtime; diff --git a/lib/obj/src/lib.rs b/lib/obj/src/lib.rs index 726a84b7b4..dcaa6462fa 100644 --- a/lib/obj/src/lib.rs +++ b/lib/obj/src/lib.rs @@ -1,5 +1,5 @@ -extern crate cretonne_codegen; -extern crate cretonne_wasm; +extern crate cranelift_codegen; +extern crate cranelift_wasm; extern crate faerie; extern crate wasmtime_runtime; diff --git a/lib/runtime/Cargo.toml b/lib/runtime/Cargo.toml index 2aad8e6f9f..9bf0109ef6 100644 --- a/lib/runtime/Cargo.toml +++ b/lib/runtime/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "wasmtime_runtime" version = "0.0.0" -authors = ["The Cretonne Project Developers"] +authors = ["The Cranelift Project Developers"] publish = false -description = "Standalone runtime support for WebAsssembly code in Cretonne" +description = "Standalone runtime support for WebAsssembly code in Cranelift" repository = "https://github.com/sunfishcode/wasmtime" license = "Apache-2.0 WITH LLVM-exception" [dependencies] -cretonne-codegen = "0.13.0" -cretonne-wasm = "0.13.0" -wasmparser = "0.17.0" -target-lexicon = "0.0.2" +cranelift-codegen = "0.16.1" +cranelift-wasm = "0.16.1" +wasmparser = "0.17.2" +target-lexicon = "0.0.3" diff --git a/lib/runtime/src/instance.rs b/lib/runtime/src/instance.rs index fdc4e5993f..a6dde2a666 100644 --- a/lib/runtime/src/instance.rs +++ b/lib/runtime/src/instance.rs @@ -1,8 +1,8 @@ //! An `Instance` contains all the runtime state used by execution of a wasm //! module. -use cretonne_codegen::ir; -use cretonne_wasm::GlobalIndex; +use cranelift_codegen::ir; +use cranelift_wasm::GlobalIndex; use module::{Module, TableElements}; use DataInitializer; diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs index 84d09442a2..4bb1be1c6c 100644 --- a/lib/runtime/src/lib.rs +++ b/lib/runtime/src/lib.rs @@ -1,12 +1,12 @@ -//! Standalone runtime for WebAssembly using Cretonne. Provides functions to translate +//! Standalone runtime 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. #![deny(missing_docs)] -extern crate cretonne_codegen; -extern crate cretonne_wasm; +extern crate cranelift_codegen; +extern crate cranelift_wasm; extern crate target_lexicon; extern crate wasmparser; @@ -18,25 +18,25 @@ pub use compilation::Compilation; pub use instance::Instance; pub use module::Module; -use cretonne_codegen::binemit; -use cretonne_codegen::cursor::FuncCursor; -use cretonne_codegen::ir; -use cretonne_codegen::ir::immediates::Offset32; -use cretonne_codegen::ir::types::*; -use cretonne_codegen::ir::{ +use cranelift_codegen::binemit; +use cranelift_codegen::cursor::FuncCursor; +use cranelift_codegen::ir; +use cranelift_codegen::ir::immediates::Offset32; +use cranelift_codegen::ir::types::*; +use cranelift_codegen::ir::{ AbiParam, ArgumentExtension, ArgumentLoc, ArgumentPurpose, ExtFuncData, ExternalName, FuncRef, Function, InstBuilder, Signature, }; -use cretonne_codegen::isa; -use cretonne_codegen::settings; -use cretonne_wasm::{ +use cranelift_codegen::isa; +use cranelift_codegen::settings; +use cranelift_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. -pub fn get_func_name(func_index: FunctionIndex) -> cretonne_codegen::ir::ExternalName { +pub fn get_func_name(func_index: FunctionIndex) -> cranelift_codegen::ir::ExternalName { debug_assert!(func_index as u32 as FunctionIndex == func_index); ir::ExternalName::user(0, func_index as u32) } @@ -140,7 +140,7 @@ impl<'data> LazyContents<'data> { } /// Object containing the standalone runtime information. To be passed after creation as argument -/// to `cretonne_wasm::translatemodule`. +/// to `cranelift_wasm::translatemodule`. pub struct ModuleEnvironment<'data, 'module> { /// Compilation setting flags. pub isa: &'module isa::TargetIsa, @@ -167,7 +167,7 @@ impl<'data, 'module> ModuleEnvironment<'data, 'module> { } fn native_pointer(&self) -> ir::Type { - use cretonne_wasm::FuncEnvironment; + use cranelift_wasm::FuncEnvironment; self.func_env().native_pointer() } @@ -192,10 +192,10 @@ pub struct FuncEnvironment<'module_environment> { /// The module-level environment which this function-level environment belongs to. pub module: &'module_environment Module, - /// The Cretonne global holding the base address of the memories vector. + /// The Cranelift global holding the base address of the memories vector. pub memories_base: Option, - /// The Cretonne global holding the base address of the globals vector. + /// The Cranelift global holding the base address of the globals vector. pub globals_base: Option, /// The external function declaration for implementing wasm's `current_memory`. @@ -230,7 +230,7 @@ impl<'module_environment> FuncEnvironment<'module_environment> { } } -impl<'module_environment> cretonne_wasm::FuncEnvironment for FuncEnvironment<'module_environment> { +impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'module_environment> { fn flags(&self) -> &settings::Flags { &self.isa.flags() } @@ -322,7 +322,7 @@ impl<'module_environment> cretonne_wasm::FuncEnvironment for FuncEnvironment<'mo callee: ir::Value, call_args: &[ir::Value], ) -> WasmResult { - // TODO: Cretonne's call_indirect doesn't implement bounds checking + // TODO: Cranelift's call_indirect doesn't implement bounds checking // or signature checking, so we need to implement it ourselves. debug_assert_eq!(table_index, 0, "non-default tables not supported yet"); let real_call_args = FuncEnvironment::get_real_call_args(pos.func, call_args); @@ -401,11 +401,13 @@ impl<'module_environment> cretonne_wasm::FuncEnvironment for FuncEnvironment<'mo } /// This trait is useful for -/// `cretonne_wasm::translatemodule` because it +/// `cranelift_wasm::translatemodule` because it /// tells how to translate runtime-dependent wasm instructions. These functions should not be /// called by the user. -impl<'data, 'module> cretonne_wasm::ModuleEnvironment<'data> for ModuleEnvironment<'data, 'module> { - fn get_func_name(&self, func_index: FunctionIndex) -> cretonne_codegen::ir::ExternalName { +impl<'data, 'module> cranelift_wasm::ModuleEnvironment<'data> + for ModuleEnvironment<'data, 'module> +{ + fn get_func_name(&self, func_index: FunctionIndex) -> cranelift_codegen::ir::ExternalName { get_func_name(func_index) } @@ -458,7 +460,7 @@ impl<'data, 'module> cretonne_wasm::ModuleEnvironment<'data> for ModuleEnvironme self.module.globals.push(global); } - fn get_global(&self, global_index: GlobalIndex) -> &cretonne_wasm::Global { + fn get_global(&self, global_index: GlobalIndex) -> &cranelift_wasm::Global { &self.module.globals[global_index] } @@ -581,7 +583,7 @@ impl<'data, 'module> ModuleTranslation<'data, 'module> { let mut relocations = Vec::new(); for (i, input) in self.lazy.function_body_inputs.iter().enumerate() { let func_index = i + self.module.imported_funcs.len(); - let mut context = cretonne_codegen::Context::new(); + let mut context = cranelift_codegen::Context::new(); context.func.name = get_func_name(func_index); context.func.signature = self.module.signatures[self.module.functions[func_index]].clone(); diff --git a/lib/runtime/src/module.rs b/lib/runtime/src/module.rs index 374209676d..e705910279 100644 --- a/lib/runtime/src/module.rs +++ b/lib/runtime/src/module.rs @@ -1,8 +1,8 @@ //! A `Module` contains all the relevant information translated from a //! WebAssembly module. -use cretonne_codegen::ir; -use cretonne_wasm::{ +use cranelift_codegen::ir; +use cranelift_wasm::{ FunctionIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex, Table, TableIndex, }; use std::collections::HashMap; diff --git a/src/main.rs b/src/main.rs index 64fa9db8a7..faca992fff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,13 +1,13 @@ //! 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 +//! Reads Wasm binary files (one Wasm module per file), translates the functions' code to Cranelift //! IL. Can also executes the `start` function of the module by laying out the memories, globals //! and tables, then emitting the translated code with hardcoded addresses to memory. -extern crate cretonne_codegen; -extern crate cretonne_native; -extern crate cretonne_wasm; +extern crate cranelift_codegen; +extern crate cranelift_native; +extern crate cranelift_wasm; extern crate docopt; extern crate wasmtime_execute; extern crate wasmtime_runtime; @@ -15,10 +15,10 @@ extern crate wasmtime_runtime; extern crate serde_derive; extern crate tempdir; -use cretonne_codegen::isa::TargetIsa; -use cretonne_codegen::settings; -use cretonne_codegen::settings::Configurable; -use cretonne_wasm::translate_module; +use cranelift_codegen::isa::TargetIsa; +use cranelift_codegen::settings; +use cranelift_codegen::settings::Configurable; +use cranelift_wasm::translate_module; use docopt::Docopt; use std::error::Error; use std::fs::File; @@ -33,8 +33,8 @@ use wasmtime_execute::{compile_module, execute}; use wasmtime_runtime::{Instance, Module, ModuleEnvironment}; const USAGE: &str = " -Wasm to Cretonne IL translation utility. -Takes a binary WebAssembly module and returns its functions in Cretonne IL format. +Wasm to Cranelift IL translation utility. +Takes a binary WebAssembly module and returns its functions in Cranelift IL format. The translation is dependent on the environment chosen. Usage: @@ -45,7 +45,7 @@ Options: -o, --optimize runs optimization passes on the translated functions -m, --memory interactive memory inspector after execution -h, --help print this help message - --version print the Cretonne version + --version print the Cranelift version "; #[derive(Deserialize, Debug, Clone)] @@ -70,7 +70,7 @@ fn main() { .deserialize() }) .unwrap_or_else(|e| e.exit()); - let (mut flag_builder, isa_builder) = cretonne_native::builders().unwrap_or_else(|_| { + let (mut flag_builder, isa_builder) = cranelift_native::builders().unwrap_or_else(|_| { panic!("host machine is not a supported target"); }); @@ -101,7 +101,7 @@ fn main() { fn handle_module(args: &Args, path: PathBuf, isa: &TargetIsa) -> Result<(), String> { let mut data = read_to_end(path.clone()).map_err(|err| String::from(err.description()))?; if !data.starts_with(&[b'\0', b'a', b's', b'm']) { - let tmp_dir = TempDir::new("cretonne-wasm").unwrap(); + let tmp_dir = TempDir::new("cranelift-wasm").unwrap(); let file_path = tmp_dir.path().join("module.wasm"); File::create(file_path.clone()).unwrap(); Command::new("wat2wasm") diff --git a/src/wasm2obj.rs b/src/wasm2obj.rs index 7bb3f411a5..2cda07662c 100644 --- a/src/wasm2obj.rs +++ b/src/wasm2obj.rs @@ -1,12 +1,12 @@ //! Translation from wasm to native object files. //! -//! Reads a Wasm binary file, translates the functions' code to Cretonne +//! Reads a Wasm binary file, translates the functions' code to Cranelift //! IL, then translates it to native code, and writes it out to a native //! object file with relocations. -extern crate cretonne_codegen; -extern crate cretonne_native; -extern crate cretonne_wasm; +extern crate cranelift_codegen; +extern crate cranelift_native; +extern crate cranelift_wasm; extern crate docopt; extern crate wasmtime_obj; extern crate wasmtime_runtime; @@ -14,8 +14,8 @@ extern crate wasmtime_runtime; extern crate serde_derive; extern crate faerie; -use cretonne_codegen::settings; -use cretonne_wasm::translate_module; +use cranelift_codegen::settings; +use cranelift_wasm::translate_module; use docopt::Docopt; use faerie::Artifact; use std::error::Error; @@ -41,7 +41,7 @@ Usage: Options: -v, --verbose displays the module and translated functions -h, --help print this help message - --version print the Cretonne version + --version print the Cranelift version "; #[derive(Deserialize, Debug, Clone)] @@ -85,7 +85,7 @@ fn handle_module(path: PathBuf, output: &str) -> Result<(), String> { }; // FIXME: Make the target a parameter. - let (flag_builder, isa_builder) = cretonne_native::builders().unwrap_or_else(|_| { + let (flag_builder, isa_builder) = cranelift_native::builders().unwrap_or_else(|_| { panic!("host machine is not a supported target"); }); let isa = isa_builder.finish(settings::Flags::new(flag_builder));