cranelift-frontend: Add the FunctionBuilder::insert_block_after method

This commit is contained in:
Nick Fitzgerald
2020-06-30 12:00:30 -07:00
parent 98e899f6b3
commit a2f4202800
2 changed files with 14 additions and 36 deletions

View File

@@ -228,6 +228,11 @@ impl<'a> FunctionBuilder<'a> {
block
}
/// Insert `block` in the layout *after* the existing block `after`.
pub fn insert_block_after(&mut self, block: Block, after: Block) {
self.func.layout.insert_block_after(block, after);
}
/// After the call to this function, new instructions will be inserted into the designated
/// block, in the order they are declared. You must declare the types of the Block arguments
/// you will use here.

View File

@@ -735,22 +735,10 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
let gc_block = builder.create_block();
let no_gc_block = builder.create_block();
let current_block = builder.current_block().unwrap();
builder
.func
.layout
.insert_block_after(non_null_elem_block, current_block);
builder
.func
.layout
.insert_block_after(no_gc_block, non_null_elem_block);
builder
.func
.layout
.insert_block_after(gc_block, no_gc_block);
builder
.func
.layout
.insert_block_after(continue_block, gc_block);
builder.insert_block_after(non_null_elem_block, current_block);
builder.insert_block_after(no_gc_block, non_null_elem_block);
builder.insert_block_after(gc_block, no_gc_block);
builder.insert_block_after(continue_block, gc_block);
// Load the table element.
let elem_addr = builder.ins().table_addr(pointer_type, table, index, 0);
@@ -893,30 +881,15 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
let current_block = builder.current_block().unwrap();
let inc_ref_count_block = builder.create_block();
builder
.func
.layout
.insert_block_after(inc_ref_count_block, current_block);
builder.insert_block_after(inc_ref_count_block, current_block);
let check_current_elem_block = builder.create_block();
builder
.func
.layout
.insert_block_after(check_current_elem_block, inc_ref_count_block);
builder.insert_block_after(check_current_elem_block, inc_ref_count_block);
let dec_ref_count_block = builder.create_block();
builder
.func
.layout
.insert_block_after(dec_ref_count_block, check_current_elem_block);
builder.insert_block_after(dec_ref_count_block, check_current_elem_block);
let drop_block = builder.create_block();
builder
.func
.layout
.insert_block_after(drop_block, dec_ref_count_block);
builder.insert_block_after(drop_block, dec_ref_count_block);
let continue_block = builder.create_block();
builder
.func
.layout
.insert_block_after(continue_block, drop_block);
builder.insert_block_after(continue_block, drop_block);
// Calculate the table address of the current element and do
// bounds checks. This is the first thing we do, because we