Browse Source

Define interpret_function_body in the JIT runtime

jonathanvdc 8 years ago
parent
commit
09509dc250
1 changed files with 11 additions and 3 deletions
  1. 11 3
      kernel/modelverse_jit/runtime.py

+ 11 - 3
kernel/modelverse_jit/runtime.py

@@ -37,9 +37,9 @@ def call_function(function_id, named_arguments, **kwargs):
     # frame.
     def handle_jit_failed(_):
         """Interprets the function."""
-        interpreter_args = {'function_id' : function_id, 'named_arguments' : named_arguments}
+        interpreter_args = {'body_id' : body_id, 'named_arguments' : named_arguments}
         interpreter_args.update(kwargs)
-        yield [("TAIL_CALL_KWARGS", [interpret_function, interpreter_args])]
+        yield [("TAIL_CALL_KWARGS", [interpret_function_body, interpreter_args])]
 
     if is_mutable is not None:
         kernel.jit.mark_no_jit(body_id)
@@ -60,10 +60,18 @@ def call_function(function_id, named_arguments, **kwargs):
 def interpret_function(function_id, named_arguments, **kwargs):
     """Makes the interpreter run the function with the given id for the specified
        argument dictionary."""
+    body_id, = yield [("RD", [function_id, FUNCTION_BODY_KEY])]
+    args = {'body_id' : body_id, named_arguments : named_arguments}
+    args.update(kwargs)
+    yield [("TAIL_CALL_KWARGS", [interpret_function_body, args])]
+
+def interpret_function_body(body_id, named_arguments, **kwargs):
+    """Makes the interpreter run the function body with the given id for the specified
+       argument dictionary."""
     user_root = kwargs['user_root']
     kernel = kwargs['mvk']
     user_frame, = yield [("RD", [user_root, "frame"])]
-    inst, body_id = yield [("RD", [user_frame, "IP"]), ("RD", [function_id, FUNCTION_BODY_KEY])]
+    inst, = yield [("RD", [user_frame, "IP"])]
     kernel.jit.mark_entry_point(body_id)
 
     # Create a new stack frame.