Browse Source

Protect against non-tree graphs in JIT

jonathanvdc 8 years ago
parent
commit
1f8353c85b
1 changed files with 5 additions and 2 deletions
  1. 5 2
      kernel/modelverse_jit/jit.py

+ 5 - 2
kernel/modelverse_jit/jit.py

@@ -61,7 +61,7 @@ class ModelverseJit(object):
 
         print(constructed_ir)
         self.mark_no_jit(body_id)
-        raise JitCompilationFailedException("Can't JIT function body at " + str(body_id))
+        raise JitCompilationFailedException("Can't jit function body at " + str(body_id))
 
 class AnalysisState(object):
     """The state of a bytecode analysis call graph."""
@@ -72,8 +72,11 @@ class AnalysisState(object):
     def analyze(self, instruction_id):
         """Tries to build an intermediate representation from the instruction with the
         given id."""
-        # Add the instruction id to the analyzed_instructions set to avoid
+        # Check the analyzed_instructions set for instruction_id to avoid
         # infinite loops.
+        if instruction_id in self.analyzed_instructions:
+            raise JitCompilationFailedException('Cannon jit non-tree instruction graph.')
+
         self.analyzed_instructions.add(instruction_id)
         instruction_val, = yield [("RV", [instruction_id])]
         instruction_val = instruction_val["value"]