diff --git a/lib/wasm/src/code_translator.rs b/lib/wasm/src/code_translator.rs index 7f9d390399..76290364f2 100644 --- a/lib/wasm/src/code_translator.rs +++ b/lib/wasm/src/code_translator.rs @@ -27,7 +27,7 @@ use cretonne_codegen::ir::types::*; use cretonne_codegen::ir::{self, InstBuilder, JumpTableData, MemFlags}; use cretonne_codegen::packed_option::ReservedValue; use cretonne_frontend::{FunctionBuilder, Variable}; -use environ::{FuncEnvironment, GlobalValue, WasmError, WasmResult}; +use environ::{FuncEnvironment, GlobalVariable, WasmError, WasmResult}; use state::{ControlStackFrame, TranslationState}; use std::collections::{hash_map, HashMap}; use std::vec::Vec; @@ -72,8 +72,8 @@ pub fn translate_operator( ***********************************************************************************/ Operator::GetGlobal { global_index } => { let val = match state.get_global(builder.func, global_index, environ) { - GlobalValue::Const(val) => val, - GlobalValue::Memory { gv, ty } => { + GlobalVariable::Const(val) => val, + GlobalVariable::Memory { gv, ty } => { let addr = builder.ins().global_value(environ.native_pointer(), gv); let mut flags = ir::MemFlags::new(); flags.set_notrap(); @@ -85,8 +85,8 @@ pub fn translate_operator( } Operator::SetGlobal { global_index } => { match state.get_global(builder.func, global_index, environ) { - GlobalValue::Const(_) => panic!("global #{} is a constant", global_index), - GlobalValue::Memory { gv, .. } => { + GlobalVariable::Const(_) => panic!("global #{} is a constant", global_index), + GlobalVariable::Memory { gv, .. } => { let addr = builder.ins().global_value(environ.native_pointer(), gv); let mut flags = ir::MemFlags::new(); flags.set_notrap(); diff --git a/lib/wasm/src/environ/dummy.rs b/lib/wasm/src/environ/dummy.rs index 6ccefe3213..912c39b107 100644 --- a/lib/wasm/src/environ/dummy.rs +++ b/lib/wasm/src/environ/dummy.rs @@ -4,7 +4,7 @@ use cretonne_codegen::cursor::FuncCursor; use cretonne_codegen::ir::types::*; use cretonne_codegen::ir::{self, InstBuilder}; use cretonne_codegen::settings; -use environ::{FuncEnvironment, GlobalValue, ModuleEnvironment, WasmResult}; +use environ::{FuncEnvironment, GlobalVariable, ModuleEnvironment, WasmResult}; use func_translator::FuncTranslator; use std::string::String; use std::vec::Vec; @@ -157,11 +157,11 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ &self.mod_info.flags } - fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalValue { + fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalVariable { // Just create a dummy `vmctx` global. let offset = ((index * 8) as i32 + 8).into(); let gv = func.create_global_value(ir::GlobalValueData::VMContext { offset }); - GlobalValue::Memory { + GlobalVariable::Memory { gv, ty: self.mod_info.globals[index].entity.ty, } diff --git a/lib/wasm/src/environ/mod.rs b/lib/wasm/src/environ/mod.rs index 923d65be11..0ca34575f7 100644 --- a/lib/wasm/src/environ/mod.rs +++ b/lib/wasm/src/environ/mod.rs @@ -4,4 +4,6 @@ mod dummy; mod spec; pub use environ::dummy::DummyEnvironment; -pub use environ::spec::{FuncEnvironment, GlobalValue, ModuleEnvironment, WasmError, WasmResult}; +pub use environ::spec::{ + FuncEnvironment, GlobalVariable, ModuleEnvironment, WasmError, WasmResult, +}; diff --git a/lib/wasm/src/environ/spec.rs b/lib/wasm/src/environ/spec.rs index 09a8dd5371..959a411899 100644 --- a/lib/wasm/src/environ/spec.rs +++ b/lib/wasm/src/environ/spec.rs @@ -10,17 +10,17 @@ use translation_utils::{ }; use wasmparser::BinaryReaderError; -/// The value of a WebAssembly global value. +/// The value of a WebAssembly global variable. #[derive(Clone, Copy)] -pub enum GlobalValue { +pub enum GlobalVariable { /// This is a constant global with a value known at compile time. Const(ir::Value), - /// This is a variable in memory that should be referenced as a `GlobalValue`. + /// This is a variable in memory that should be referenced through a `GlobalValue`. Memory { - /// Which global value should be referenced. + /// The address of the global variable storage. gv: ir::GlobalValue, - /// The global value's type. + /// The global variable's type. ty: ir::Type, }, } @@ -89,14 +89,14 @@ pub trait FuncEnvironment { ir::Type::int(u16::from(self.triple().pointer_width().unwrap().bits())).unwrap() } - /// Set up the necessary preamble definitions in `func` to access the global value + /// Set up the necessary preamble definitions in `func` to access the global variable /// identified by `index`. /// /// The index space covers both imported globals and globals defined by the module. /// /// Return the global variable reference that should be used to access the global and the /// WebAssembly type of the global. - fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalValue; + fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalVariable; /// Set up the necessary preamble definitions in `func` to access the linear memory identified /// by `index`. diff --git a/lib/wasm/src/lib.rs b/lib/wasm/src/lib.rs index 5d4fd24a37..70826f72fb 100644 --- a/lib/wasm/src/lib.rs +++ b/lib/wasm/src/lib.rs @@ -43,7 +43,7 @@ mod state; mod translation_utils; pub use environ::{ - DummyEnvironment, FuncEnvironment, GlobalValue, ModuleEnvironment, WasmError, WasmResult, + DummyEnvironment, FuncEnvironment, GlobalVariable, ModuleEnvironment, WasmError, WasmResult, }; pub use func_translator::FuncTranslator; pub use module_translator::translate_module; diff --git a/lib/wasm/src/sections_translator.rs b/lib/wasm/src/sections_translator.rs index 112bd3784e..0c47a3e940 100644 --- a/lib/wasm/src/sections_translator.rs +++ b/lib/wasm/src/sections_translator.rs @@ -4,7 +4,7 @@ //! The code of theses helper function is straightforward since it is only about reading metadata //! about linear memories, tables, globals, etc. and storing them for later use. //! -//! The special case of the initialize expressions for table elements offsets or global values +//! The special case of the initialize expressions for table elements offsets or global variables //! is handled, according to the semantics of WebAssembly, to only specific expressions that are //! interpreted on the fly. use cretonne_codegen::ir::{self, AbiParam, Signature}; diff --git a/lib/wasm/src/state.rs b/lib/wasm/src/state.rs index beba6e666f..d301d87348 100644 --- a/lib/wasm/src/state.rs +++ b/lib/wasm/src/state.rs @@ -4,7 +4,7 @@ //! value and control stacks during the translation of a single function. use cretonne_codegen::ir::{self, Ebb, Inst, Value}; -use environ::{FuncEnvironment, GlobalValue}; +use environ::{FuncEnvironment, GlobalVariable}; use std::collections::HashMap; use std::vec::Vec; use translation_utils::{FunctionIndex, GlobalIndex, MemoryIndex, SignatureIndex}; @@ -134,8 +134,8 @@ pub struct TranslationState { pub control_stack: Vec, pub reachable: bool, - // Map of global values that have already been created by `FuncEnvironment::make_global`. - globals: HashMap, + // Map of global variables that have already been created by `FuncEnvironment::make_global`. + globals: HashMap, // Map of heaps that have been created by `FuncEnvironment::make_heap`. heaps: HashMap, @@ -272,7 +272,7 @@ impl TranslationState { /// Methods for handling entity references. impl TranslationState { - /// Get the `GlobalValue` reference that should be used to access the global value `index`. + /// Get the `GlobalVariable` reference that should be used to access the global variable `index`. /// Create the reference if necessary. /// Also return the WebAssembly type of the global. pub fn get_global( @@ -280,7 +280,7 @@ impl TranslationState { func: &mut ir::Function, index: u32, environ: &mut FE, - ) -> GlobalValue { + ) -> GlobalVariable { let index = index as GlobalIndex; *self.globals .entry(index) diff --git a/lib/wasm/src/translation_utils.rs b/lib/wasm/src/translation_utils.rs index 3c16d0897e..3ed13899e6 100644 --- a/lib/wasm/src/translation_utils.rs +++ b/lib/wasm/src/translation_utils.rs @@ -7,7 +7,7 @@ use wasmparser; pub type FunctionIndex = usize; /// Index of a table (imported or defined) inside the WebAssembly module. pub type TableIndex = usize; -/// Index of a global value (imported or defined) inside the WebAssembly module. +/// Index of a global variable (imported or defined) inside the WebAssembly module. pub type GlobalIndex = usize; /// Index of a linear memory (imported or defined) inside the WebAssembly module. pub type MemoryIndex = usize;