From 64ea964bc0b6f985de4064393f5652cee8fdb812 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 18 Dec 2018 14:13:46 -0800 Subject: [PATCH] Change the `elems` parameter of `declare_table_elements` to a boxed slice. Implementations that want a full `Vec` can use `into_vec` to convert it back. --- lib/wasm/src/environ/dummy.rs | 2 +- lib/wasm/src/environ/spec.rs | 4 ++-- lib/wasm/src/sections_translator.rs | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/wasm/src/environ/dummy.rs b/lib/wasm/src/environ/dummy.rs index 290aa38c0..5bf196168 100644 --- a/lib/wasm/src/environ/dummy.rs +++ b/lib/wasm/src/environ/dummy.rs @@ -402,7 +402,7 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment { _table_index: TableIndex, _base: Option, _offset: usize, - _elements: Vec, + _elements: Box<[FuncIndex]>, ) { // We do nothing } diff --git a/lib/wasm/src/environ/spec.rs b/lib/wasm/src/environ/spec.rs index 37d741a4f..92c7fa9e2 100644 --- a/lib/wasm/src/environ/spec.rs +++ b/lib/wasm/src/environ/spec.rs @@ -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. @@ -336,7 +336,7 @@ pub trait ModuleEnvironment<'data> { table_index: TableIndex, base: Option, offset: usize, - elements: Vec, + elements: Box<[FuncIndex]>, ); /// Provides the contents of a function body. diff --git a/lib/wasm/src/sections_translator.rs b/lib/wasm/src/sections_translator.rs index 89c1750c8..6192ec7b0 100644 --- a/lib/wasm/src/sections_translator.rs +++ b/lib/wasm/src/sections_translator.rs @@ -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(()) }