Browse Source

Fix most bugs with the JIT

Yentl Van Tendeloo 7 years ago
parent
commit
e3343aa8a5

+ 3 - 0
kernel/modelverse_jit/bytecode_ir.py

@@ -35,6 +35,9 @@ class VariableNode(object):
     """Represents a variable node, which has an identifier and an optional name."""
     """Represents a variable node, which has an identifier and an optional name."""
     def __init__(self, node_id, name):
     def __init__(self, node_id, name):
         self.node_id = node_id
         self.node_id = node_id
+        if node_id is None:
+            print(locals())
+            raise Exception("NONE")
         self.name = name
         self.name = name
 
 
     def __str__(self):
     def __str__(self):

+ 2 - 0
kernel/modelverse_jit/cfg_optimization.py

@@ -254,6 +254,8 @@ def try_redefine_as_direct_call(definition, jit, called_globals):
                 called_globals.add(loaded_ptr)
                 called_globals.add(loaded_ptr)
     elif isinstance(target, cfg_ir.Literal):
     elif isinstance(target, cfg_ir.Literal):
         node_id = target.literal
         node_id = target.literal
+        if target.literal is None:
+            raise Exception("NONE")
         thunk_name = jit.jit_thunk_constant_function(node_id)
         thunk_name = jit.jit_thunk_constant_function(node_id)
         definition.redefine(
         definition.redefine(
             cfg_ir.DirectFunctionCall(
             cfg_ir.DirectFunctionCall(

+ 7 - 5
kernel/modelverse_jit/jit.py

@@ -445,6 +445,8 @@ class ModelverseJit(object):
             else:
             else:
                 param_name_ids, = yield [("RDK", [param_set_id])]
                 param_name_ids, = yield [("RDK", [param_set_id])]
                 param_names = yield [("RV", [n]) for n in param_name_ids]
                 param_names = yield [("RV", [n]) for n in param_name_ids]
+                #NOTE Patch up strange links...
+                param_names = [i for i in param_names if i is not None]
                 param_vars = yield [("RD", [param_set_id, k]) for k in param_names]
                 param_vars = yield [("RD", [param_set_id, k]) for k in param_names]
                 self.jitted_parameters[body_id] = (param_vars, param_names, is_mutable)
                 self.jitted_parameters[body_id] = (param_vars, param_names, is_mutable)
 
 
@@ -785,6 +787,10 @@ def compile_function_body_fast(jit, function_name, body_id, _):
     (parameter_ids, parameter_list, _), = yield [
     (parameter_ids, parameter_list, _), = yield [
         ("CALL_ARGS", [jit.jit_signature, (body_id,)])]
         ("CALL_ARGS", [jit.jit_signature, (body_id,)])]
     param_dict = dict(list(zip(parameter_ids, parameter_list)))
     param_dict = dict(list(zip(parameter_ids, parameter_list)))
+    if None in param_dict:
+        del param_dict[None]
+        print("REMOVING NONE IN PARAMETERS for ")
+        print(locals())
     body_bytecode, = yield [("CALL_ARGS", [jit.jit_parse_bytecode, (body_id,)])]
     body_bytecode, = yield [("CALL_ARGS", [jit.jit_parse_bytecode, (body_id,)])]
     bytecode_analyzer = bytecode_to_cfg.AnalysisState(jit, function_name, param_dict)
     bytecode_analyzer = bytecode_to_cfg.AnalysisState(jit, function_name, param_dict)
     bytecode_analyzer.analyze(body_bytecode)
     bytecode_analyzer.analyze(body_bytecode)
@@ -797,11 +803,7 @@ def compile_function_body_fast(jit, function_name, body_id, _):
                 '\n'.join(map(str, cfg_ir.get_all_reachable_blocks(entry_point)))))
                 '\n'.join(map(str, cfg_ir.get_all_reachable_blocks(entry_point)))))
 
 
     # Lower the CFG to tree IR.
     # Lower the CFG to tree IR.
-    try:
-        constructed_body = cfg_to_tree.lower_flow_graph(entry_point, jit)
-    except Exception as e:
-        print("Exception in JIT: " + str(e))
-        raise JitCompilationFailedException("UNKNOWN...")
+    constructed_body = cfg_to_tree.lower_flow_graph(entry_point, jit)
 
 
     # Optimize the tree that was generated.
     # Optimize the tree that was generated.
     constructed_body, = yield [("CALL_ARGS", [optimize_tree_ir, (constructed_body,)])]
     constructed_body, = yield [("CALL_ARGS", [optimize_tree_ir, (constructed_body,)])]

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
 
-Date:   Thu Apr  5 07:27:30 2018
+Date:   Thu Apr  5 09:43:06 2018
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server