浏览代码

Don't assign id to all returnvalues if potentially not needed

Yentl Van Tendeloo 7 年之前
父节点
当前提交
3ba5aed5ab
共有 3 个文件被更改,包括 6 次插入6 次删除
  1. 2 0
      kernel/modelverse_kernel/compiled.py
  2. 3 5
      kernel/modelverse_kernel/main.py
  3. 1 1
      wrappers/modelverse_SCCD.py

+ 2 - 0
kernel/modelverse_kernel/compiled.py

@@ -87,6 +87,8 @@ def reverseKeyLookup(a, b, **remainder):
         raise PrimitiveFinished({'value': ""})
 
 def instantiated_name(a, b, **remainder):
+    if "id" not in a:
+        a['id'], = yield [("CNV", [a['value']])]
     if "value" not in b:
         b['value'], = yield [("RV", [b["id"]])]
 

+ 3 - 5
kernel/modelverse_kernel/main.py

@@ -224,7 +224,6 @@ class ModelverseKernel(object):
                 prev = \
                        "  " * nested_indent + "%s = _mvk.jit.cache[_taskname].get('%s', None)\n" % (str_value, str_value) + \
                        "  " * nested_indent + "if %s is None:\n" % str_value + \
-                       "  " * (nested_indent + 1) + "print('cache miss for %s')\n" % str_value + \
                        "  " * (nested_indent + 1) + "%s, = yield [('RD', [_globs, '%s'])]\n" % (str_value, str_value) + \
                        "  " * (nested_indent + 1) + "%s, = yield [('RD', [%s, 'value'])]\n" % (str_value, str_value) + \
                        "  " * (nested_indent + 1) + "%s = {'id': %s}\n" % (str_value, str_value) + \
@@ -431,10 +430,6 @@ class ModelverseKernel(object):
         if result is None:
             result = {'id': None, 'value': None}
 
-        # TODO this can move inside "store" branch?
-        if "id" not in result:
-            result['id'], = yield [("CNV", [result['value']])]
-
         if store:
             # Clean up the current stack, as if a return happened
             old_frame, exception_return = yield [
@@ -444,6 +439,9 @@ class ModelverseKernel(object):
             #if self.debug_info[self.taskname]:
             #    self.debug_info[self.taskname].pop()
 
+            if "id" not in result:
+                result['id'], = yield [("CNV", [result['value']])]
+
             if exception_return is not None:
                 # The caller has requested that we throw an exception instead of injecting
                 # the return value into the caller's frame. Read the comment at

+ 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)
 
-Date:   Fri Apr 27 08:54:20 2018
+Date:   Fri Apr 27 09:25:20 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server