|
@@ -1,4 +1,5 @@
|
|
|
import modelverse_kernel.primitives as primitive_functions
|
|
|
+import modelverse_jit.source_map as source_map
|
|
|
|
|
|
class JitCompilationFailedException(Exception):
|
|
|
"""A type of exception that is raised when the jit fails to compile a function."""
|
|
@@ -43,6 +44,9 @@ LOCALS_EDGE_NAME = "jit_locals_edge"
|
|
|
GLOBAL_NOT_FOUND_MESSAGE_FORMAT = "Not found as global: %s"
|
|
|
"""The format of the 'not found as global' message. Takes a single argument."""
|
|
|
|
|
|
+REFERENCE_INTERPRETER_ORIGIN_NAME = "reference-interpreter"
|
|
|
+"""The origin name for functions that are interpreted by the reference interpreter."""
|
|
|
+
|
|
|
BYTECODE_INTERPRETER_ORIGIN_NAME = "bytecode-interpreter"
|
|
|
"""The origin name for functions that were produced by the bytecode interpreter."""
|
|
|
|
|
@@ -90,7 +94,7 @@ def call_function(function_id, named_arguments, **kwargs):
|
|
|
|
|
|
if is_mutable is not None:
|
|
|
kernel.jit.mark_no_jit(body_id)
|
|
|
- yield [("TAIL_CALL_ARGS", [handle_jit_failed, ()])]
|
|
|
+ yield [("TAIL_CALL_ARGS", [handle_jit_failed, (None,)])]
|
|
|
else:
|
|
|
kernel.jit.mark_entry_point(body_id)
|
|
|
|
|
@@ -162,6 +166,17 @@ def interpret_function_body(body_id, named_arguments, **kwargs):
|
|
|
yield [("CE", [symbol_edge, param_var])]
|
|
|
|
|
|
taskname = kwargs['taskname']
|
|
|
+
|
|
|
+ # Append a debug info record and set up a source map.
|
|
|
+ kernel.debug_info[taskname].append(UNKNOWN_LOCATION_REPR)
|
|
|
+ src_map = source_map.InterpreterSourceMap(
|
|
|
+ kernel, taskname, len(kernel.debug_info[taskname]) - 1)
|
|
|
+ function_name = kernel.jit.get_global_name(body_id)
|
|
|
+ if function_name is None:
|
|
|
+ function_name = UNKNOWN_FUNCTION_REPR
|
|
|
+
|
|
|
+ yield [("DEBUG_INFO", [function_name, src_map, REFERENCE_INTERPRETER_ORIGIN_NAME])]
|
|
|
+
|
|
|
def exception_handler(ex):
|
|
|
# print('Returning from interpreted function. Result: %s' % ex.result)
|
|
|
raise primitive_functions.PrimitiveFinished(ex.result)
|