Update the spec reference testsuite submodule (#3450)

* Update the spec reference testsuite submodule

This commit brings in recent updates to the spec test suite. Most of the
changes here were already fixed in `wasmparser` with some tweaks to
esoteric modules, but Wasmtime also gets a bug fix where where import
matching for the size of tables/memories is based on the current runtime
size of the table/memory rather than the original type of the
table/memory. This means that during type matching the actual value is
consulted for its size rather than using the minimum size listed in its
type.

* Fix now-missing directories in build script
This commit is contained in:
Alex Crichton
2021-10-13 16:14:12 -05:00
committed by GitHub
parent 14cde24377
commit 9c6884e28d
36 changed files with 101 additions and 68 deletions

View File

@@ -20,7 +20,7 @@ wasmtime-cache = { path = "../cache", version = "0.30.0", optional = true }
wasmtime-fiber = { path = "../fiber", version = "0.30.0", optional = true }
wasmtime-cranelift = { path = "../cranelift", version = "0.30.0", optional = true }
target-lexicon = { version = "0.12.0", default-features = false }
wasmparser = "0.80"
wasmparser = "0.81"
anyhow = "1.0.19"
region = "2.2.0"
libc = "0.2"

View File

@@ -523,7 +523,10 @@ impl Table {
///
/// Panics if `store` does not own this table.
pub fn size(&self, store: impl AsContext) -> u32 {
let store = store.as_context();
self.internal_size(store.as_context().0)
}
pub(crate) fn internal_size(&self, store: &StoreOpaque) -> u32 {
unsafe { (*store[self.0].definition).current_elements }
}

View File

@@ -396,7 +396,11 @@ impl Memory {
///
/// Panics if this memory doesn't belong to `store`.
pub fn data_size(&self, store: impl AsContext) -> usize {
unsafe { (*store.as_context()[self.0].definition).current_length }
self.internal_data_size(store.as_context().0)
}
pub(crate) fn internal_data_size(&self, store: &StoreOpaque) -> usize {
unsafe { (*store[self.0].definition).current_length }
}
/// Returns the size, in WebAssembly pages, of this wasm memory.
@@ -405,7 +409,11 @@ impl Memory {
///
/// Panics if this memory doesn't belong to `store`.
pub fn size(&self, store: impl AsContext) -> u64 {
(self.data_size(store) / wasmtime_environ::WASM_PAGE_SIZE as usize) as u64
self.internal_size(store.as_context().0)
}
pub(crate) fn internal_size(&self, store: &StoreOpaque) -> u64 {
(self.internal_data_size(store) / wasmtime_environ::WASM_PAGE_SIZE as usize) as u64
}
/// Grows this WebAssembly memory by `delta` pages.

View File

@@ -35,15 +35,24 @@ impl MatchCx<'_> {
}
pub fn table(&self, expected: &Table, actual: &crate::Table) -> Result<()> {
self.table_ty(expected, actual.wasmtime_ty(self.store.store_data()))
self.table_ty(
expected,
actual.wasmtime_ty(self.store.store_data()),
Some(actual.internal_size(self.store)),
)
}
fn table_ty(&self, expected: &Table, actual: &Table) -> Result<()> {
fn table_ty(
&self,
expected: &Table,
actual: &Table,
actual_runtime_size: Option<u32>,
) -> Result<()> {
match_ty(expected.wasm_ty, actual.wasm_ty, "table")?;
match_limits(
expected.minimum.into(),
expected.maximum.map(|i| i.into()),
actual.minimum.into(),
actual_runtime_size.unwrap_or(actual.minimum).into(),
actual.maximum.map(|i| i.into()),
"table",
)?;
@@ -51,10 +60,19 @@ impl MatchCx<'_> {
}
pub fn memory(&self, expected: &Memory, actual: &crate::Memory) -> Result<()> {
self.memory_ty(expected, actual.wasmtime_ty(self.store.store_data()))
self.memory_ty(
expected,
actual.wasmtime_ty(self.store.store_data()),
Some(actual.internal_size(self.store)),
)
}
fn memory_ty(&self, expected: &Memory, actual: &Memory) -> Result<()> {
fn memory_ty(
&self,
expected: &Memory,
actual: &Memory,
actual_runtime_size: Option<u64>,
) -> Result<()> {
match_bool(
expected.shared,
actual.shared,
@@ -72,7 +90,7 @@ impl MatchCx<'_> {
match_limits(
expected.minimum,
expected.maximum,
actual.minimum,
actual_runtime_size.unwrap_or(actual.minimum),
actual.maximum,
"memory",
)?;
@@ -280,11 +298,11 @@ impl MatchCx<'_> {
_ => bail!("expected global, but found {}", actual_desc),
},
EntityType::Table(expected) => match actual_ty {
EntityType::Table(actual) => self.table_ty(expected, actual),
EntityType::Table(actual) => self.table_ty(expected, actual, None),
_ => bail!("expected table, but found {}", actual_desc),
},
EntityType::Memory(expected) => match actual_ty {
EntityType::Memory(actual) => self.memory_ty(expected, actual),
EntityType::Memory(actual) => self.memory_ty(expected, actual, None),
_ => bail!("expected memory, but found {}", actual_desc),
},
EntityType::Function(expected) => match *actual_ty {