Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly disallow 64-bit/shared memories/tables in components #1970

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions crates/wasmparser/src/validator/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2970,7 +2970,6 @@ impl ComponentState {
match self.core_instance_export(instance_index, name, types, offset)? {
$expected(ty) => {
self.$collection.push(*ty);
Ok(())
}
_ => {
bail!(
Expand All @@ -2992,7 +2991,7 @@ impl ComponentState {
"functions",
offset,
)?;
push_module_export!(EntityType::Func, core_funcs, "function")
push_module_export!(EntityType::Func, core_funcs, "function");
}
ExternalKind::Table => {
check_max(
Expand All @@ -3002,7 +3001,21 @@ impl ComponentState {
"tables",
offset,
)?;
push_module_export!(EntityType::Table, core_tables, "table")
push_module_export!(EntityType::Table, core_tables, "table");

let ty = self.core_tables.last().unwrap();
if ty.table64 {
bail!(
offset,
"64-bit tables are not compatible with components yet"
);
}
if ty.shared {
bail!(
offset,
"shared tables are not compatible with components yet"
);
}
}
ExternalKind::Memory => {
check_max(
Expand All @@ -3012,7 +3025,21 @@ impl ComponentState {
"memories",
offset,
)?;
push_module_export!(EntityType::Memory, core_memories, "memory")
push_module_export!(EntityType::Memory, core_memories, "memory");

let ty = self.core_memories.last().unwrap();
if ty.memory64 {
bail!(
offset,
"64-bit linear memories are not compatible with components yet"
);
}
if ty.shared {
bail!(
offset,
"shared linear memories are not compatible with components yet"
);
}
}
ExternalKind::Global => {
check_max(
Expand All @@ -3022,7 +3049,7 @@ impl ComponentState {
"globals",
offset,
)?;
push_module_export!(EntityType::Global, core_globals, "global")
push_module_export!(EntityType::Global, core_globals, "global");
}
ExternalKind::Tag => {
check_max(
Expand All @@ -3032,9 +3059,11 @@ impl ComponentState {
"tags",
offset,
)?;
push_module_export!(EntityType::Tag, core_tags, "tag")
push_module_export!(EntityType::Tag, core_tags, "tag");
}
}

Ok(())
}

fn alias_instance_export(
Expand Down
18 changes: 18 additions & 0 deletions tests/local/component-model/memory64.wast
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,21 @@
(core instance $a (instantiate $A (with "" (instance $b))))
)
"mismatch in index type used for memories")

(assert_invalid
(component
(core module $A
(memory (export "m") i64 1))
(core instance $A (instantiate $A))
(alias core export $A "m" (core memory $m))
)
"64-bit linear memories are not compatible with components yet")

(assert_invalid
(component
(core module $A
(table (export "m") i64 1 funcref))
(core instance $A (instantiate $A))
(alias core export $A "m" (core table $m))
)
"64-bit tables are not compatible with components yet")
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(assert_invalid
(component
(core module $A
(memory (export "m") 1 2 shared))
(core instance $A (instantiate $A))
(alias core export $A "m" (core memory $m))
)
"shared linear memories are not compatible with components yet")

(assert_invalid
(component
(core module $A
(table (export "m") shared 1 2 (ref null (shared func)))
)
(core instance $A (instantiate $A))
(alias core export $A "m" (core table $m))
)
"shared tables are not compatible with components yet")
14 changes: 14 additions & 0 deletions tests/snapshots/local/component-model/memory64.wast.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
"filename": "memory64.1.wasm",
"module_type": "binary",
"text": "mismatch in index type used for memories"
},
{
"type": "assert_invalid",
"line": 24,
"filename": "memory64.2.wasm",
"module_type": "binary",
"text": "64-bit linear memories are not compatible with components yet"
},
{
"type": "assert_invalid",
"line": 33,
"filename": "memory64.3.wasm",
"module_type": "binary",
"text": "64-bit tables are not compatible with components yet"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"source_filename": "tests/local/component-model/shared-everything-threads/not-accepted.wast",
"commands": [
{
"type": "assert_invalid",
"line": 2,
"filename": "not-accepted.0.wasm",
"module_type": "binary",
"text": "shared linear memories are not compatible with components yet"
},
{
"type": "assert_invalid",
"line": 11,
"filename": "not-accepted.1.wasm",
"module_type": "binary",
"text": "shared tables are not compatible with components yet"
}
]
}
Loading