@@ -3,7 +3,7 @@
|
|||||||
//! TODO: opportunities for better code generation:
|
//! TODO: opportunities for better code generation:
|
||||||
//!
|
//!
|
||||||
//! - Smarter use of addressing modes. Recognize a+SCALE*b patterns; recognize
|
//! - Smarter use of addressing modes. Recognize a+SCALE*b patterns; recognize
|
||||||
//! and incorporate sign/zero extension on indicies. Recognize pre/post-index
|
//! and incorporate sign/zero extension on indices. Recognize pre/post-index
|
||||||
//! opportunities.
|
//! opportunities.
|
||||||
//!
|
//!
|
||||||
//! - Floating-point immediates (FIMM instruction).
|
//! - Floating-point immediates (FIMM instruction).
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ struct Position {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Mapping of continuous range of source location to its generated
|
/// Mapping of continuous range of source location to its generated
|
||||||
/// code. The positions are always in accending order for search.
|
/// code. The positions are always in ascending order for search.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Range {
|
struct Range {
|
||||||
wasm_start: WasmAddress,
|
wasm_start: WasmAddress,
|
||||||
@@ -226,7 +226,7 @@ fn build_function_addr_map(
|
|||||||
// The iterator returns generated addresses sorted by RangeIndex.
|
// The iterator returns generated addresses sorted by RangeIndex.
|
||||||
struct TransformRangeStartIter<'a> {
|
struct TransformRangeStartIter<'a> {
|
||||||
addr: WasmAddress,
|
addr: WasmAddress,
|
||||||
indicies: &'a [RangeIndex],
|
indices: &'a [RangeIndex],
|
||||||
ranges: &'a [Range],
|
ranges: &'a [Range],
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ impl<'a> TransformRangeStartIter<'a> {
|
|||||||
if let Some(range_indices) = found {
|
if let Some(range_indices) = found {
|
||||||
TransformRangeStartIter {
|
TransformRangeStartIter {
|
||||||
addr,
|
addr,
|
||||||
indicies: range_indices,
|
indices: range_indices,
|
||||||
ranges: &func.lookup.ranges,
|
ranges: &func.lookup.ranges,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -261,10 +261,10 @@ impl<'a> TransformRangeStartIter<'a> {
|
|||||||
impl<'a> Iterator for TransformRangeStartIter<'a> {
|
impl<'a> Iterator for TransformRangeStartIter<'a> {
|
||||||
type Item = (GeneratedAddress, RangeIndex);
|
type Item = (GeneratedAddress, RangeIndex);
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
if let Some((first, tail)) = self.indicies.split_first() {
|
if let Some((first, tail)) = self.indices.split_first() {
|
||||||
let range_index = *first;
|
let range_index = *first;
|
||||||
let range = &self.ranges[range_index];
|
let range = &self.ranges[range_index];
|
||||||
self.indicies = tail;
|
self.indices = tail;
|
||||||
let address = match range
|
let address = match range
|
||||||
.positions
|
.positions
|
||||||
.binary_search_by(|a| a.wasm_pos.cmp(&self.addr))
|
.binary_search_by(|a| a.wasm_pos.cmp(&self.addr))
|
||||||
@@ -289,7 +289,7 @@ impl<'a> Iterator for TransformRangeStartIter<'a> {
|
|||||||
// The iterator returns generated addresses sorted by RangeIndex.
|
// The iterator returns generated addresses sorted by RangeIndex.
|
||||||
struct TransformRangeEndIter<'a> {
|
struct TransformRangeEndIter<'a> {
|
||||||
addr: WasmAddress,
|
addr: WasmAddress,
|
||||||
indicies: &'a [RangeIndex],
|
indices: &'a [RangeIndex],
|
||||||
ranges: &'a [Range],
|
ranges: &'a [Range],
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ impl<'a> TransformRangeEndIter<'a> {
|
|||||||
if let Some(range_indices) = found {
|
if let Some(range_indices) = found {
|
||||||
TransformRangeEndIter {
|
TransformRangeEndIter {
|
||||||
addr,
|
addr,
|
||||||
indicies: range_indices,
|
indices: range_indices,
|
||||||
ranges: &func.lookup.ranges,
|
ranges: &func.lookup.ranges,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -324,10 +324,10 @@ impl<'a> TransformRangeEndIter<'a> {
|
|||||||
impl<'a> Iterator for TransformRangeEndIter<'a> {
|
impl<'a> Iterator for TransformRangeEndIter<'a> {
|
||||||
type Item = (GeneratedAddress, RangeIndex);
|
type Item = (GeneratedAddress, RangeIndex);
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
while let Some((first, tail)) = self.indicies.split_first() {
|
while let Some((first, tail)) = self.indices.split_first() {
|
||||||
let range_index = *first;
|
let range_index = *first;
|
||||||
let range = &self.ranges[range_index];
|
let range = &self.ranges[range_index];
|
||||||
self.indicies = tail;
|
self.indices = tail;
|
||||||
if range.wasm_start >= self.addr {
|
if range.wasm_start >= self.addr {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ impl ExecutableModule {
|
|||||||
) -> Result<T, ExecutionError> {
|
) -> Result<T, ExecutionError> {
|
||||||
let module = &self.module;
|
let module = &self.module;
|
||||||
|
|
||||||
if func_idx as usize >= module.ctx.func_ty_indicies.len() {
|
if func_idx as usize >= module.ctx.func_ty_indices.len() {
|
||||||
return Err(ExecutionError::FuncIndexOutOfBounds);
|
return Err(ExecutionError::FuncIndexOutOfBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ impl VmCtx {
|
|||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct SimpleContext {
|
pub struct SimpleContext {
|
||||||
types: Vec<FuncType>,
|
types: Vec<FuncType>,
|
||||||
func_ty_indicies: Vec<u32>,
|
func_ty_indices: Vec<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const WASM_PAGE_SIZE: usize = 65_536;
|
pub const WASM_PAGE_SIZE: usize = 65_536;
|
||||||
@@ -393,7 +393,7 @@ impl ModuleContext for SimpleContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn func_type_index(&self, func_idx: u32) -> u32 {
|
fn func_type_index(&self, func_idx: u32) -> u32 {
|
||||||
self.func_ty_indicies[func_idx as usize]
|
self.func_ty_indices[func_idx as usize]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn defined_global_index(&self, _index: u32) -> Option<u32> {
|
fn defined_global_index(&self, _index: u32) -> Option<u32> {
|
||||||
@@ -539,7 +539,7 @@ pub fn translate_only(data: &[u8]) -> Result<TranslatedModule, Error> {
|
|||||||
|
|
||||||
if let SectionCode::Function = section.code {
|
if let SectionCode::Function = section.code {
|
||||||
let functions = section.get_function_section_reader()?;
|
let functions = section.get_function_section_reader()?;
|
||||||
output.ctx.func_ty_indicies = translate_sections::function(functions)?;
|
output.ctx.func_ty_indices = translate_sections::function(functions)?;
|
||||||
|
|
||||||
reader.skip_custom_sections()?;
|
reader.skip_custom_sections()?;
|
||||||
if reader.eof() {
|
if reader.eof() {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ pub fn layout_vmcontext(
|
|||||||
let out_len = ofs.size_of_vmctx() as usize;
|
let out_len = ofs.size_of_vmctx() as usize;
|
||||||
let mut out = vec![0; out_len];
|
let mut out = vec![0; out_len];
|
||||||
|
|
||||||
// Assign unique indicies to unique signatures.
|
// Assign unique indices to unique signatures.
|
||||||
let mut signature_registry = HashMap::new();
|
let mut signature_registry = HashMap::new();
|
||||||
let mut signature_registry_len = signature_registry.len();
|
let mut signature_registry_len = signature_registry.len();
|
||||||
for (index, sig) in module.local.signatures.iter() {
|
for (index, sig) in module.local.signatures.iter() {
|
||||||
|
|||||||
Reference in New Issue
Block a user