|
@@ -333,6 +333,7 @@ class ModelverseKernel(object):
|
|
|
print("Total printed function: ")
|
|
|
func = "def " + suggested_name + "(" + ", ".join(["var_%s" % param for param in params]) + "):\n" + printed
|
|
|
print(func)
|
|
|
+ raise primitive_functions.PrimitiveFinished(func)
|
|
|
|
|
|
def jit_compile(self, task_root, inst):
|
|
|
# Try to retrieve the suggested name.
|
|
@@ -347,20 +348,21 @@ class ModelverseKernel(object):
|
|
|
self.jit.jit_globals[self.jit.jitted_entry_points[inst]])
|
|
|
|
|
|
compiled_func = self.jit.lookup_compiled_body(inst)
|
|
|
- if compiled_func is not None:
|
|
|
- raise primitive_functions.PrimitiveFinished(compiled_func)
|
|
|
-
|
|
|
- """
|
|
|
- def func(**kwargs):
|
|
|
- print("KWARGS: " + str(kwargs))
|
|
|
- #raise primitive_functions.PrimitiveFinished(None)
|
|
|
- """
|
|
|
+ if compiled_func is None:
|
|
|
+ name = self.jit.get_global_name(inst)
|
|
|
+ compiled_func, = yield [("CALL_ARGS", [self.read_function, (inst,)])]
|
|
|
+ exec(str(compiled_func), self.jit.jit_globals)
|
|
|
+ print(self.jit.jit_globals)
|
|
|
+ compiled_func = self.jit.jit_globals[name]
|
|
|
+ self.jit.register_compiled(inst, compiled_func, name)
|
|
|
|
|
|
- yield [("CALL_ARGS", [self.read_function, (inst,)])]
|
|
|
+ #raise jit.JitCompilationFailedException("FAIL")
|
|
|
|
|
|
- raise jit.JitCompilationFailedException("FAIL")
|
|
|
-
|
|
|
- raise primitive_functions.PrimitiveFinished(func)
|
|
|
+ try:
|
|
|
+ raise primitive_functions.PrimitiveFinished(compiled_func)
|
|
|
+ except Exception as e:
|
|
|
+ print("Exception: " + str(e))
|
|
|
+ raise jit.JitCompilationFailedException("FAIL")
|
|
|
|
|
|
def execute_jit(self, task_root, inst, taskname):
|
|
|
# execute_jit
|