Move default blocks into jump tables (#5756)
Move the default block off of the br_table instrution, and into the JumpTable that it references.
This commit is contained in:
@@ -515,7 +515,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
}
|
||||
};
|
||||
let val = state.pop1();
|
||||
let mut data = JumpTableData::with_capacity(targets.len() as usize);
|
||||
let mut data = Vec::with_capacity(targets.len() as usize);
|
||||
if jump_args_count == 0 {
|
||||
// No jump arguments
|
||||
for depth in targets.targets() {
|
||||
@@ -526,16 +526,16 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
frame.set_branched_to_exit();
|
||||
frame.br_destination()
|
||||
};
|
||||
data.push_entry(block);
|
||||
data.push(block);
|
||||
}
|
||||
let jt = builder.create_jump_table(data);
|
||||
let block = {
|
||||
let i = state.control_stack.len() - 1 - (default as usize);
|
||||
let frame = &mut state.control_stack[i];
|
||||
frame.set_branched_to_exit();
|
||||
frame.br_destination()
|
||||
};
|
||||
builder.ins().br_table(val, block, jt);
|
||||
let jt = builder.create_jump_table(JumpTableData::new(block, data));
|
||||
builder.ins().br_table(val, jt);
|
||||
} else {
|
||||
// Here we have jump arguments, but Cranelift's br_table doesn't support them
|
||||
// We then proceed to split the edges going out of the br_table
|
||||
@@ -552,7 +552,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
*entry.insert(block)
|
||||
}
|
||||
};
|
||||
data.push_entry(branch_block);
|
||||
data.push(branch_block);
|
||||
}
|
||||
let default_branch_block = match dest_block_map.entry(default as usize) {
|
||||
hash_map::Entry::Occupied(entry) => *entry.get(),
|
||||
@@ -562,8 +562,8 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
*entry.insert(block)
|
||||
}
|
||||
};
|
||||
let jt = builder.create_jump_table(data);
|
||||
builder.ins().br_table(val, default_branch_block, jt);
|
||||
let jt = builder.create_jump_table(JumpTableData::new(default_branch_block, data));
|
||||
builder.ins().br_table(val, jt);
|
||||
for (depth, dest_block) in dest_block_sequence {
|
||||
builder.switch_to_block(dest_block);
|
||||
builder.seal_block(dest_block);
|
||||
|
||||
Reference in New Issue
Block a user