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

Fix a panic in table-ops translation #2350

Merged
merged 1 commit into from
Nov 2, 2020
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
2 changes: 2 additions & 0 deletions crates/cranelift/src/func_environ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m

let reference_type = self.reference_type(WasmType::ExternRef);

builder.ensure_inserted_block();
let continue_block = builder.create_block();
let non_null_elem_block = builder.create_block();
let gc_block = builder.create_block();
Expand Down Expand Up @@ -643,6 +644,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
// drop the old table element *after* we've replaced it with
// the new `value`!

builder.ensure_inserted_block();
let current_block = builder.current_block().unwrap();
let inc_ref_count_block = builder.create_block();
builder.insert_block_after(inc_ref_count_block, current_block);
Expand Down
26 changes: 26 additions & 0 deletions tests/misc_testsuite/reference-types/no-panic.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(module
(func $test (param i32) (result externref)
i32.const 0
if
else
end
local.get 0
table.get 0
)
(table 4 externref)
(export "test" (func $test))
)

(module
(func $test (param i32)
i32.const 0
if
else
end
local.get 0
ref.null extern
table.set 0
)
(table 4 externref)
(export "test" (func $test))
)