Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Change the elems parameter of declare_table_elements to a boxed s…
Browse files Browse the repository at this point in the history
…lice.

Implementations that want a full `Vec` can use `into_vec` to convert it
back.
  • Loading branch information
sunfishcode committed Jan 7, 2019
1 parent 464fa4e commit 64ea964
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/wasm/src/environ/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
_table_index: TableIndex,
_base: Option<GlobalIndex>,
_offset: usize,
_elements: Vec<FuncIndex>,
_elements: Box<[FuncIndex]>,
) {
// We do nothing
}
Expand Down
4 changes: 2 additions & 2 deletions lib/wasm/src/environ/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use cranelift_codegen::ir::immediates::Offset32;
use cranelift_codegen::ir::{self, InstBuilder};
use cranelift_codegen::isa::TargetFrontendConfig;
use failure_derive::Fail;
use std::boxed::Box;
use std::convert::From;
use std::vec::Vec;
use wasmparser::BinaryReaderError;

/// The value of a WebAssembly global variable.
Expand Down Expand Up @@ -336,7 +336,7 @@ pub trait ModuleEnvironment<'data> {
table_index: TableIndex,
base: Option<GlobalIndex>,
offset: usize,
elements: Vec<FuncIndex>,
elements: Box<[FuncIndex]>,
);

/// Provides the contents of a function body.
Expand Down
7 changes: 6 additions & 1 deletion lib/wasm/src/sections_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ pub fn parse_element_section<'data>(
let x = item?;
elems.push(FuncIndex::from_u32(x));
}
environ.declare_table_elements(TableIndex::from_u32(table_index), base, offset, elems)
environ.declare_table_elements(
TableIndex::from_u32(table_index),
base,
offset,
elems.into_boxed_slice(),
)
}
Ok(())
}
Expand Down

0 comments on commit 64ea964

Please sign in to comment.