rename PassiveElemIndex to ElemIndex and same for PassiveDataIndex (#1188)
* rename PassiveElemIndex to ElemIndex and same for PassiveDataIndex (#1411) * rename PassiveDataIndex to DataIndex * rename PassiveElemIndex to ElemIndex * Apply renamings to wasmtime as well * Run rustfmt Co-authored-by: csmoe <csmoe@msn.com>
This commit is contained in:
@@ -11,8 +11,8 @@ use crate::environ::{
|
|||||||
use crate::func_translator::FuncTranslator;
|
use crate::func_translator::FuncTranslator;
|
||||||
use crate::state::ModuleTranslationState;
|
use crate::state::ModuleTranslationState;
|
||||||
use crate::translation_utils::{
|
use crate::translation_utils::{
|
||||||
DefinedFuncIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, PassiveDataIndex,
|
DataIndex, DefinedFuncIndex, ElemIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex,
|
||||||
PassiveElemIndex, SignatureIndex, Table, TableIndex,
|
SignatureIndex, Table, TableIndex,
|
||||||
};
|
};
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
use cranelift_codegen::cursor::FuncCursor;
|
use cranelift_codegen::cursor::FuncCursor;
|
||||||
@@ -607,7 +607,7 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
|
|||||||
|
|
||||||
fn declare_passive_element(
|
fn declare_passive_element(
|
||||||
&mut self,
|
&mut self,
|
||||||
_elem_index: PassiveElemIndex,
|
_elem_index: ElemIndex,
|
||||||
_segments: Box<[FuncIndex]>,
|
_segments: Box<[FuncIndex]>,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -615,7 +615,7 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
|
|||||||
|
|
||||||
fn declare_passive_data(
|
fn declare_passive_data(
|
||||||
&mut self,
|
&mut self,
|
||||||
_elem_index: PassiveDataIndex,
|
_elem_index: DataIndex,
|
||||||
_segments: &'data [u8],
|
_segments: &'data [u8],
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
use crate::state::{FuncTranslationState, ModuleTranslationState};
|
use crate::state::{FuncTranslationState, ModuleTranslationState};
|
||||||
use crate::translation_utils::{
|
use crate::translation_utils::{
|
||||||
FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, PassiveDataIndex, PassiveElemIndex,
|
DataIndex, ElemIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex,
|
||||||
SignatureIndex, Table, TableIndex,
|
Table, TableIndex,
|
||||||
};
|
};
|
||||||
use core::convert::From;
|
use core::convert::From;
|
||||||
use cranelift_codegen::cursor::FuncCursor;
|
use cranelift_codegen::cursor::FuncCursor;
|
||||||
@@ -606,7 +606,7 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
|
|||||||
/// Declare a passive element segment.
|
/// Declare a passive element segment.
|
||||||
fn declare_passive_element(
|
fn declare_passive_element(
|
||||||
&mut self,
|
&mut self,
|
||||||
index: PassiveElemIndex,
|
index: ElemIndex,
|
||||||
elements: Box<[FuncIndex]>,
|
elements: Box<[FuncIndex]>,
|
||||||
) -> WasmResult<()>;
|
) -> WasmResult<()>;
|
||||||
|
|
||||||
@@ -620,11 +620,7 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Declare a passive data segment.
|
/// Declare a passive data segment.
|
||||||
fn declare_passive_data(
|
fn declare_passive_data(&mut self, data_index: DataIndex, data: &'data [u8]) -> WasmResult<()>;
|
||||||
&mut self,
|
|
||||||
data_index: PassiveDataIndex,
|
|
||||||
data: &'data [u8],
|
|
||||||
) -> WasmResult<()>;
|
|
||||||
|
|
||||||
/// Provides the contents of a function body.
|
/// Provides the contents of a function body.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ pub use crate::module_translator::translate_module;
|
|||||||
pub use crate::state::func_state::FuncTranslationState;
|
pub use crate::state::func_state::FuncTranslationState;
|
||||||
pub use crate::state::module_state::ModuleTranslationState;
|
pub use crate::state::module_state::ModuleTranslationState;
|
||||||
pub use crate::translation_utils::{
|
pub use crate::translation_utils::{
|
||||||
get_vmctx_value_label, DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex,
|
get_vmctx_value_label, DataIndex, DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex,
|
||||||
DefinedTableIndex, FuncIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex,
|
DefinedTableIndex, ElemIndex, FuncIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex,
|
||||||
PassiveDataIndex, PassiveElemIndex, SignatureIndex, Table, TableElementType, TableIndex,
|
SignatureIndex, Table, TableElementType, TableIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Version number of this crate.
|
/// Version number of this crate.
|
||||||
|
|||||||
@@ -10,9 +10,8 @@
|
|||||||
use crate::environ::{ModuleEnvironment, WasmError, WasmResult};
|
use crate::environ::{ModuleEnvironment, WasmError, WasmResult};
|
||||||
use crate::state::ModuleTranslationState;
|
use crate::state::ModuleTranslationState;
|
||||||
use crate::translation_utils::{
|
use crate::translation_utils::{
|
||||||
tabletype_to_type, type_to_type, FuncIndex, Global, GlobalIndex, GlobalInit, Memory,
|
tabletype_to_type, type_to_type, DataIndex, ElemIndex, FuncIndex, Global, GlobalIndex,
|
||||||
MemoryIndex, PassiveDataIndex, PassiveElemIndex, SignatureIndex, Table, TableElementType,
|
GlobalInit, Memory, MemoryIndex, SignatureIndex, Table, TableElementType, TableIndex,
|
||||||
TableIndex,
|
|
||||||
};
|
};
|
||||||
use crate::{wasm_unsupported, HashMap};
|
use crate::{wasm_unsupported, HashMap};
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
@@ -345,7 +344,7 @@ pub fn parse_element_section<'data>(
|
|||||||
)?
|
)?
|
||||||
}
|
}
|
||||||
ElementKind::Passive => {
|
ElementKind::Passive => {
|
||||||
let index = PassiveElemIndex::from_u32(index as u32);
|
let index = ElemIndex::from_u32(index as u32);
|
||||||
environ.declare_passive_element(index, segments)?;
|
environ.declare_passive_element(index, segments)?;
|
||||||
}
|
}
|
||||||
ElementKind::Declared => return Err(wasm_unsupported!("element kind declared")),
|
ElementKind::Declared => return Err(wasm_unsupported!("element kind declared")),
|
||||||
@@ -404,7 +403,7 @@ pub fn parse_data_section<'data>(
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
DataKind::Passive => {
|
DataKind::Passive => {
|
||||||
let index = PassiveDataIndex::from_u32(index as u32);
|
let index = DataIndex::from_u32(index as u32);
|
||||||
environ.declare_passive_data(index, data)?;
|
environ.declare_passive_data(index, data)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,13 +59,13 @@ entity_impl!(SignatureIndex);
|
|||||||
|
|
||||||
/// Index type of a passive data segment inside the WebAssembly module.
|
/// Index type of a passive data segment inside the WebAssembly module.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
|
||||||
pub struct PassiveDataIndex(u32);
|
pub struct DataIndex(u32);
|
||||||
entity_impl!(PassiveDataIndex);
|
entity_impl!(DataIndex);
|
||||||
|
|
||||||
/// Index type of a passive element segment inside the WebAssembly module.
|
/// Index type of a passive element segment inside the WebAssembly module.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
|
||||||
pub struct PassiveElemIndex(u32);
|
pub struct ElemIndex(u32);
|
||||||
entity_impl!(PassiveElemIndex);
|
entity_impl!(ElemIndex);
|
||||||
|
|
||||||
/// WebAssembly global.
|
/// WebAssembly global.
|
||||||
#[derive(Debug, Clone, Copy, Hash)]
|
#[derive(Debug, Clone, Copy, Hash)]
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ pub mod entity {
|
|||||||
pub mod wasm {
|
pub mod wasm {
|
||||||
pub use cranelift_wasm::{
|
pub use cranelift_wasm::{
|
||||||
get_vmctx_value_label, DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex,
|
get_vmctx_value_label, DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex,
|
||||||
DefinedTableIndex, FuncIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex,
|
DefinedTableIndex, ElemIndex, FuncIndex, Global, GlobalIndex, GlobalInit, Memory,
|
||||||
PassiveElemIndex, SignatureIndex, Table, TableElementType, TableIndex,
|
MemoryIndex, SignatureIndex, Table, TableElementType, TableIndex,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ use crate::WASM_MAX_PAGES;
|
|||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
use cranelift_entity::{EntityRef, PrimaryMap};
|
use cranelift_entity::{EntityRef, PrimaryMap};
|
||||||
use cranelift_wasm::{
|
use cranelift_wasm::{
|
||||||
DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex, Global,
|
DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, ElemIndex,
|
||||||
GlobalIndex, Memory, MemoryIndex, PassiveElemIndex, SignatureIndex, Table, TableIndex,
|
FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex, Table, TableIndex,
|
||||||
};
|
};
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use more_asserts::assert_ge;
|
use more_asserts::assert_ge;
|
||||||
@@ -166,7 +166,7 @@ pub struct Module {
|
|||||||
pub table_elements: Vec<TableElements>,
|
pub table_elements: Vec<TableElements>,
|
||||||
|
|
||||||
/// WebAssembly passive elements.
|
/// WebAssembly passive elements.
|
||||||
pub passive_elements: HashMap<PassiveElemIndex, Box<[FuncIndex]>>,
|
pub passive_elements: HashMap<ElemIndex, Box<[FuncIndex]>>,
|
||||||
|
|
||||||
/// WebAssembly table initializers.
|
/// WebAssembly table initializers.
|
||||||
pub func_names: HashMap<FuncIndex, String>,
|
pub func_names: HashMap<FuncIndex, String>,
|
||||||
@@ -239,7 +239,7 @@ impl Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the given passive element, if it exists.
|
/// Get the given passive element, if it exists.
|
||||||
pub fn get_passive_element(&self, index: PassiveElemIndex) -> Option<&[FuncIndex]> {
|
pub fn get_passive_element(&self, index: ElemIndex) -> Option<&[FuncIndex]> {
|
||||||
self.passive_elements.get(&index).map(|es| &**es)
|
self.passive_elements.get(&index).map(|es| &**es)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ use cranelift_codegen::ir::{AbiParam, ArgumentPurpose};
|
|||||||
use cranelift_codegen::isa::TargetFrontendConfig;
|
use cranelift_codegen::isa::TargetFrontendConfig;
|
||||||
use cranelift_entity::PrimaryMap;
|
use cranelift_entity::PrimaryMap;
|
||||||
use cranelift_wasm::{
|
use cranelift_wasm::{
|
||||||
self, translate_module, DefinedFuncIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex,
|
self, translate_module, DataIndex, DefinedFuncIndex, ElemIndex, FuncIndex, Global, GlobalIndex,
|
||||||
ModuleTranslationState, PassiveDataIndex, PassiveElemIndex, SignatureIndex, Table, TableIndex,
|
Memory, MemoryIndex, ModuleTranslationState, SignatureIndex, Table, TableIndex,
|
||||||
TargetEnvironment, WasmError, WasmResult,
|
TargetEnvironment, WasmError, WasmResult,
|
||||||
};
|
};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
@@ -336,7 +336,7 @@ impl<'data> cranelift_wasm::ModuleEnvironment<'data> for ModuleEnvironment<'data
|
|||||||
|
|
||||||
fn declare_passive_element(
|
fn declare_passive_element(
|
||||||
&mut self,
|
&mut self,
|
||||||
elem_index: PassiveElemIndex,
|
elem_index: ElemIndex,
|
||||||
segments: Box<[FuncIndex]>,
|
segments: Box<[FuncIndex]>,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
let old = self
|
let old = self
|
||||||
@@ -397,7 +397,7 @@ impl<'data> cranelift_wasm::ModuleEnvironment<'data> for ModuleEnvironment<'data
|
|||||||
|
|
||||||
fn declare_passive_data(
|
fn declare_passive_data(
|
||||||
&mut self,
|
&mut self,
|
||||||
_data_index: PassiveDataIndex,
|
_data_index: DataIndex,
|
||||||
_data: &'data [u8],
|
_data: &'data [u8],
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
Err(WasmError::Unsupported(
|
Err(WasmError::Unsupported(
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ use std::{mem, ptr, slice};
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use wasmtime_environ::entity::{packed_option::ReservedValue, BoxedSlice, EntityRef, PrimaryMap};
|
use wasmtime_environ::entity::{packed_option::ReservedValue, BoxedSlice, EntityRef, PrimaryMap};
|
||||||
use wasmtime_environ::wasm::{
|
use wasmtime_environ::wasm::{
|
||||||
DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex,
|
DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, ElemIndex,
|
||||||
GlobalIndex, GlobalInit, MemoryIndex, PassiveElemIndex, SignatureIndex, TableIndex,
|
FuncIndex, GlobalIndex, GlobalInit, MemoryIndex, SignatureIndex, TableIndex,
|
||||||
};
|
};
|
||||||
use wasmtime_environ::{ir, DataInitializer, Module, TableElements, VMOffsets};
|
use wasmtime_environ::{ir, DataInitializer, Module, TableElements, VMOffsets};
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ pub(crate) struct Instance {
|
|||||||
/// Passive elements in this instantiation. As `elem.drop`s happen, these
|
/// Passive elements in this instantiation. As `elem.drop`s happen, these
|
||||||
/// entries get removed. A missing entry is considered equivalent to an
|
/// entries get removed. A missing entry is considered equivalent to an
|
||||||
/// empty slice.
|
/// empty slice.
|
||||||
passive_elements: RefCell<HashMap<PassiveElemIndex, Box<[VMCallerCheckedAnyfunc]>>>,
|
passive_elements: RefCell<HashMap<ElemIndex, Box<[VMCallerCheckedAnyfunc]>>>,
|
||||||
|
|
||||||
/// Pointers to functions in executable memory.
|
/// Pointers to functions in executable memory.
|
||||||
finished_functions: BoxedSlice<DefinedFuncIndex, *mut [VMFunctionBody]>,
|
finished_functions: BoxedSlice<DefinedFuncIndex, *mut [VMFunctionBody]>,
|
||||||
@@ -587,7 +587,7 @@ impl Instance {
|
|||||||
pub(crate) fn table_init(
|
pub(crate) fn table_init(
|
||||||
&self,
|
&self,
|
||||||
table_index: TableIndex,
|
table_index: TableIndex,
|
||||||
elem_index: PassiveElemIndex,
|
elem_index: ElemIndex,
|
||||||
dst: u32,
|
dst: u32,
|
||||||
src: u32,
|
src: u32,
|
||||||
len: u32,
|
len: u32,
|
||||||
@@ -621,7 +621,7 @@ impl Instance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Drop an element.
|
/// Drop an element.
|
||||||
pub(crate) fn elem_drop(&self, elem_index: PassiveElemIndex) {
|
pub(crate) fn elem_drop(&self, elem_index: ElemIndex) {
|
||||||
// https://webassembly.github.io/reference-types/core/exec/instructions.html#exec-elem-drop
|
// https://webassembly.github.io/reference-types/core/exec/instructions.html#exec-elem-drop
|
||||||
|
|
||||||
let mut passive_elements = self.passive_elements.borrow_mut();
|
let mut passive_elements = self.passive_elements.borrow_mut();
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ use crate::table::Table;
|
|||||||
use crate::traphandlers::raise_lib_trap;
|
use crate::traphandlers::raise_lib_trap;
|
||||||
use crate::vmcontext::VMContext;
|
use crate::vmcontext::VMContext;
|
||||||
use wasmtime_environ::ir;
|
use wasmtime_environ::ir;
|
||||||
use wasmtime_environ::wasm::{DefinedMemoryIndex, MemoryIndex, PassiveElemIndex, TableIndex};
|
use wasmtime_environ::wasm::{DefinedMemoryIndex, ElemIndex, MemoryIndex, TableIndex};
|
||||||
|
|
||||||
/// Implementation of f32.ceil
|
/// Implementation of f32.ceil
|
||||||
pub extern "C" fn wasmtime_f32_ceil(x: f32) -> f32 {
|
pub extern "C" fn wasmtime_f32_ceil(x: f32) -> f32 {
|
||||||
@@ -204,7 +204,7 @@ pub unsafe extern "C" fn wasmtime_table_init(
|
|||||||
let result = {
|
let result = {
|
||||||
let table_index = TableIndex::from_u32(table_index);
|
let table_index = TableIndex::from_u32(table_index);
|
||||||
let source_loc = ir::SourceLoc::new(source_loc);
|
let source_loc = ir::SourceLoc::new(source_loc);
|
||||||
let elem_index = PassiveElemIndex::from_u32(elem_index);
|
let elem_index = ElemIndex::from_u32(elem_index);
|
||||||
let instance = (&mut *vmctx).instance();
|
let instance = (&mut *vmctx).instance();
|
||||||
instance.table_init(table_index, elem_index, dst, src, len, source_loc)
|
instance.table_init(table_index, elem_index, dst, src, len, source_loc)
|
||||||
};
|
};
|
||||||
@@ -215,7 +215,7 @@ pub unsafe extern "C" fn wasmtime_table_init(
|
|||||||
|
|
||||||
/// Implementation of `elem.drop`.
|
/// Implementation of `elem.drop`.
|
||||||
pub unsafe extern "C" fn wasmtime_elem_drop(vmctx: *mut VMContext, elem_index: u32) {
|
pub unsafe extern "C" fn wasmtime_elem_drop(vmctx: *mut VMContext, elem_index: u32) {
|
||||||
let elem_index = PassiveElemIndex::from_u32(elem_index);
|
let elem_index = ElemIndex::from_u32(elem_index);
|
||||||
let instance = (&mut *vmctx).instance();
|
let instance = (&mut *vmctx).instance();
|
||||||
instance.elem_drop(elem_index);
|
instance.elem_drop(elem_index);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user