Browse Source

Fix some miscellaneous cfg_to_tree bugs

jonathanvdc 8 years ago
parent
commit
74042ce25a
1 changed files with 13 additions and 9 deletions
  1. 13 9
      kernel/modelverse_jit/cfg_to_tree.py

+ 13 - 9
kernel/modelverse_jit/cfg_to_tree.py

@@ -656,14 +656,13 @@ class LoweringState(object):
         #     _globals, = yield [("RD", [task_root, "globals"])]
         #     yield [("CD", [_globals, var_name, global_var])]
         #
-        task_root = bytecode_to_tree.retrieve_task_root()
         global_var = tree_ir.StoreLocalInstruction(None, tree_ir.CreateNodeInstruction())
         return tree_ir.create_block(
             global_var.create_store(
                 tree_ir.CreateNodeInstruction()),
             tree_ir.CreateDictionaryEdgeInstruction(
                 tree_ir.ReadDictionaryValueInstruction(
-                    task_root.create_load(),
+                    bytecode_to_tree.load_task_root(),
                     tree_ir.LiteralInstruction('globals')),
                 tree_ir.LiteralInstruction(
                     value.variable.name),
@@ -676,10 +675,9 @@ class LoweringState(object):
         #     _globals, = yield [("RD", [task_root, "globals"])]
         #     global_var, = yield [("RD", [_globals, var_name])]
         #
-        task_root = bytecode_to_tree.retrieve_task_root()
         return tree_ir.ReadDictionaryValueInstruction(
             tree_ir.ReadDictionaryValueInstruction(
-                task_root.create_load(),
+                bytecode_to_tree.load_task_root(),
                 tree_ir.LiteralInstruction('globals')),
             tree_ir.LiteralInstruction(value.variable.name))
 
@@ -808,13 +806,19 @@ class LoweringState(object):
 
     def lower_branch(self, branch):
         """Lowers the given (relooped) branch to a tree."""
+        instructions = []
         for param, arg in zip(branch.block.parameters, branch.arguments):
-            self.create_definition_load(param).create_store(self.use_definition(arg))
+            instructions.append(
+                tree_ir.IgnoreInstruction(
+                    self.create_definition_load(param).create_store(self.use_definition(arg))))
 
-        return tree_ir.IgnoreInstruction(
-            tree_ir.StoreLocalInstruction(
-                self.label_variable,
-                tree_ir.LiteralInstruction(branch.block.index)))
+        instructions.append(
+            tree_ir.IgnoreInstruction(
+                tree_ir.StoreLocalInstruction(
+                    self.label_variable,
+                    tree_ir.LiteralInstruction(branch.block.index))))
+
+        return tree_ir.create_block(*instructions)
 
     inline_value_types = (cfg_ir.Literal, cfg_ir.ResolveLocal, cfg_ir.FunctionParameter)