Say "Global Variable" when referring to the WebAssembly concept.

This helps avoid confusion between wasm global variables and cretonne
global values.
This commit is contained in:
Dan Gohman
2018-06-26 14:03:22 -07:00
parent 8f3c49bc6c
commit 7a55a107ae
8 changed files with 26 additions and 24 deletions

View File

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

View File

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

View File

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