Commit 8402546a authored by qinsoon's avatar qinsoon

during removing phi, if we generate intermediate blocks for an exception

block, mark the new block as exceptional block
parent 6279fb1c
......@@ -133,7 +133,7 @@ impl <'a> InstructionSelection {
// if any of these assumption breaks, we will need to re-emit the code
#[allow(unused_variables)]
fn instruction_select(&mut self, node: &'a TreeNode, f_content: &FunctionContent, f_context: &mut FunctionContext, vm: &VM) {
trace!("instsel on node {}", node);
trace!("instsel on node#{} {}", node.id(), node);
match node.v {
TreeNode_::Instruction(ref inst) => {
......@@ -3571,13 +3571,22 @@ impl CompilerPass for InstructionSelection {
func.name().unwrap()
};
let (mc, func_end) = self.backend.finish_code(func_name);
let (mc, func_end) = self.backend.finish_code(func_name.clone());
// insert exception branch info
let mut frame = self.current_frame.take().unwrap();
let mut frame = match self.current_frame.take() {
Some(frame) => frame,
None => panic!("no current_frame for function {} that is being compiled", func_name)
};
for block_id in self.current_exn_blocks.keys() {
let block_loc = self.current_exn_blocks.get(&block_id).unwrap();
let callsites = self.current_exn_callsites.get(&block_id).unwrap();
let block_loc = match self.current_exn_blocks.get(&block_id) {
Some(loc) => loc,
None => panic!("failed to find exception block {}", block_id)
};
let callsites = match self.current_exn_callsites.get(&block_id) {
Some(callsite) => callsite,
None => panic!("failed to find callsite for block {}", block_id)
};
for callsite in callsites {
frame.add_exception_callsite(callsite.clone(), block_loc.clone());
......
......@@ -185,15 +185,18 @@ impl CompilerPass for GenMovPhi {
vm.set_name(ret.as_entity(), name);
let target_block = f_content.get_block(target_id);
let mut target_block = f_content.get_block_mut(target_id);
assert!(target_block.content.is_some());
// if target_block is an exception block,
// set its exn argument to None, and set this new block as an exception block
let exn_arg = target_block.content.as_mut().unwrap().exn_arg.take();
let ref target_args = target_block.content.as_ref().unwrap().args;
ret.content = Some(BlockContent{
args: vec![],
exn_arg: None,
exn_arg: exn_arg,
body: {
let mut vec = vec![];
......
......@@ -1016,7 +1016,6 @@ def test_make_boot_image_simple():
assert res.returncode == 0, res.err
assert res.out == '%s\nabc\n123\n' % exe
@pytest.mark.xfail(reason='unimplemented')
@may_spawn_proc
def test_rpytarget_print_argv():
from rpython.translator.interactive import Translation
......@@ -1039,7 +1038,7 @@ def test_rpytarget_print_argv():
assert res.returncode == 0, res.err
assert res.out == '[%s, abc, 123]\n' % exe
@pytest.mark.skipif("True")
@may_spawn_proc
def test_rpytarget_sha1sum():
john1 = \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment