Просмотр исходного кода

Minor movement of code to improve performance slightly

Yentl Van Tendeloo 7 лет назад
Родитель
Сommit
db4a2db1a6
2 измененных файлов с 18 добавлено и 16 удалено
  1. 17 15
      kernel/modelverse_kernel/main.py
  2. 1 1
      wrappers/modelverse_SCCD.py

+ 17 - 15
kernel/modelverse_kernel/main.py

@@ -328,7 +328,6 @@ class ModelverseKernel(object):
         initial_instruction = inst
         initial_instruction = inst
 
 
         (params, _, is_mutable), = yield [("CALL_ARGS", [self.jit.jit_signature, (inst,)])]
         (params, _, is_mutable), = yield [("CALL_ARGS", [self.jit.jit_signature, (inst,)])]
-        #if suggested_name is None or is_mutable:
         if is_mutable:
         if is_mutable:
             print("Ignoring mutable or unreadable: %s" % suggested_name)
             print("Ignoring mutable or unreadable: %s" % suggested_name)
             raise jit.JitCompilationFailedException("FAIL")
             raise jit.JitCompilationFailedException("FAIL")
@@ -356,26 +355,29 @@ class ModelverseKernel(object):
 
 
     def jit_compile(self, task_root, inst):
     def jit_compile(self, task_root, inst):
         # Try to retrieve the suggested name.
         # Try to retrieve the suggested name.
-        suggested_name = self.jit.get_global_name(inst)
-        if suggested_name is None:
-            suggested_name = "func_%s" % str(inst)
-        #print("Exec function " + str(suggested_name))
-
         # Have the JIT compile the function.
         # Have the JIT compile the function.
         if inst is None:
         if inst is None:
+            suggested_name = self.jit.get_global_name(inst)
+            if suggested_name is None:
+                suggested_name = "func_%s" % str(inst)
             raise ValueError('body_id cannot be None: ' + str(suggested_name))
             raise ValueError('body_id cannot be None: ' + str(suggested_name))
+
         elif inst in self.jit.jitted_entry_points:
         elif inst in self.jit.jitted_entry_points:
             raise primitive_functions.PrimitiveFinished(
             raise primitive_functions.PrimitiveFinished(
                 self.jit.jit_globals[self.jit.jitted_entry_points[inst]])
                 self.jit.jit_globals[self.jit.jitted_entry_points[inst]])
-
-        compiled_func = self.jit.lookup_compiled_body(inst)
-        if compiled_func is None:
-            compiled_func, = yield [("CALL_ARGS", [self.read_function, (inst, suggested_name)])]
-            exec(str(compiled_func), self.jit.jit_globals)
-            compiled_func = self.jit.jit_globals[suggested_name]
-            self.jit.register_compiled(inst, compiled_func, suggested_name)
-
-        raise primitive_functions.PrimitiveFinished(compiled_func)
+        else:
+            compiled_func = self.jit.lookup_compiled_body(inst)
+
+            if compiled_func is None:
+                suggested_name = self.jit.get_global_name(inst)
+                if suggested_name is None:
+                    suggested_name = "func_%s" % str(inst)
+                compiled_func, = yield [("CALL_ARGS", [self.read_function, (inst, suggested_name)])]
+                exec(compiled_func, self.jit.jit_globals)
+                compiled_func = self.jit.jit_globals[suggested_name]
+                self.jit.register_compiled(inst, compiled_func, suggested_name)
+
+            raise primitive_functions.PrimitiveFinished(compiled_func)
 
 
     def execute_jit(self, task_root, inst, taskname, params = {}, store=False):
     def execute_jit(self, task_root, inst, taskname, params = {}, store=False):
         # execute_jit
         # execute_jit

+ 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 26 16:21:07 2018
+Date:   Thu Apr 26 16:40:53 2018
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server