|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
import modelverse_jit.bytecode_ir as bytecode_ir
|
|
|
import modelverse_jit.runtime as jit_runtime
|
|
|
+import modelverse_jit.source_map as source_map
|
|
|
import modelverse_kernel.primitives as primitive_functions
|
|
|
|
|
|
class BreakException(Exception):
|
|
@@ -22,10 +23,11 @@ class ContinueException(Exception):
|
|
|
|
|
|
class InterpreterState(object):
|
|
|
"""The state of the bytecode interpreter."""
|
|
|
- def __init__(self, gc_root_node, keyword_arg_dict, nop_period=10):
|
|
|
+ def __init__(self, gc_root_node, keyword_arg_dict, src_map, nop_period=10):
|
|
|
self.gc_root_node = gc_root_node
|
|
|
self.nop_period = nop_period
|
|
|
self.keyword_arg_dict = keyword_arg_dict
|
|
|
+ self.src_map = src_map
|
|
|
self.current_result = None
|
|
|
self.nop_phase = 0
|
|
|
self.local_vars = {}
|
|
@@ -66,10 +68,17 @@ class InterpreterState(object):
|
|
|
"""Interprets the given instruction and returns the current result."""
|
|
|
instruction_type = type(instruction)
|
|
|
if instruction_type in InterpreterState.INTERPRETERS:
|
|
|
+ old_debug_info = self.src_map.debug_information
|
|
|
+ debug_info = instruction.debug_information
|
|
|
+ if debug_info is not None:
|
|
|
+ self.src_map.debug_information = debug_info
|
|
|
+
|
|
|
# Interpret the instruction.
|
|
|
yield [("CALL_ARGS",
|
|
|
[InterpreterState.INTERPRETERS[instruction_type], (self, instruction)])]
|
|
|
|
|
|
+ self.src_map.debug_information = old_debug_info
|
|
|
+
|
|
|
# Maybe perform a nop.
|
|
|
if self.schedule_nop():
|
|
|
yield None
|
|
@@ -279,11 +288,12 @@ class InterpreterState(object):
|
|
|
def interpret_bytecode_function(function_name, body_bytecode, local_arguments, keyword_arguments):
|
|
|
"""Interprets the bytecode function with the given name, body, named arguments and
|
|
|
keyword arguments."""
|
|
|
- yield [("DEBUG_INFO", [function_name, None, jit_runtime.BYTECODE_INTERPRETER_ORIGIN_NAME])]
|
|
|
+ src_map = source_map.ManualSourceMap()
|
|
|
+ yield [("DEBUG_INFO", [function_name, src_map, jit_runtime.BYTECODE_INTERPRETER_ORIGIN_NAME])]
|
|
|
task_root = keyword_arguments['task_root']
|
|
|
gc_root_node, = yield [("CN", [])]
|
|
|
gc_root_edge, = yield [("CE", [task_root, gc_root_node])]
|
|
|
- interpreter = InterpreterState(gc_root_node, keyword_arguments)
|
|
|
+ interpreter = InterpreterState(gc_root_node, keyword_arguments, src_map)
|
|
|
for param_id, arg_node in local_arguments.items():
|
|
|
yield [("CALL_ARGS", [interpreter.import_local, (param_id, arg_node)])]
|
|
|
|