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

GC private tables #265

Merged
merged 2 commits into from
Jul 2, 2024
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
6 changes: 4 additions & 2 deletions crates/tests/tests/spec-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ fn run(wast: &Path) -> Result<(), anyhow::Error> {
// Tests which assert that they're not linkable tend to not work with
// the gc pass because it removes things which would cause a module to
// become unlinkable. This doesn't matter too much in the real world
// (hopefully), so just don't gc assert_unlinkable modules.
if cmd != "assert_unlinkable" {
// (hopefully), so just don't gc assert_unlinkable modules. The same
// applies to assert_uninstantiable modules due to removal of unused
// elements and tables.
if !matches!(cmd.as_str(), "assert_unlinkable" | "assert_uninstantiable") {
walrus::passes::gc::run(&mut module);
}

Expand Down
12 changes: 9 additions & 3 deletions src/passes/used.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,15 @@ impl Used {
for elem in module.elements.iter() {
match elem.kind {
// Active segments are rooted because they initialize imported
// or exported tables. Declared segments can probably get gc'd
// but for now we're conservative and we root them.
ElementKind::Active { .. } | ElementKind::Declared => {
// tables.
ElementKind::Active { table, .. } => {
if module.tables.get(table).import.is_some() {
stack.push_element(elem.id());
}
}
// Declared segments can probably get gc'd but for now we're
// conservative and we root them
ElementKind::Declared => {
stack.push_element(elem.id());
}
ElementKind::Passive => {}
Expand Down
Loading