浏览代码

Include the function origin in DEBUG_INFO requests

jonathanvdc 8 年之前
父节点
当前提交
9da9327045

+ 2 - 1
kernel/modelverse_jit/bytecode_to_cfg.py

@@ -11,7 +11,8 @@ def emit_debug_info_trace(block, debug_info, function_name):
         block.append_definition(
             cfg_ir.create_print(
                 block.append_definition(
-                    cfg_ir.Literal(jit_runtime.format_trace_message(debug_info, function_name)))))
+                    cfg_ir.Literal(jit_runtime.format_trace_message(
+                        debug_info, function_name, jit_runtime.FAST_JIT_ORIGIN_NAME)))))
 
 class AnalysisState(object):
     """State that is common to the bytecode->CFG transformation of a function."""

+ 3 - 1
kernel/modelverse_jit/bytecode_to_tree.py

@@ -242,7 +242,9 @@ def with_debug_info_trace(instruction, debug_info, function_name):
         return tree_ir.create_block(
             tree_ir.PrintInstruction(
                 tree_ir.LiteralInstruction(
-                    jit_runtime.format_trace_message(debug_info, function_name))),
+                    jit_runtime.format_trace_message(
+                        debug_info, function_name,
+                        jit_runtime.BASELINE_JIT_ORIGIN_NAME))),
             instruction)
 
 class LocalNameMap(object):

+ 2 - 1
kernel/modelverse_jit/jit.py

@@ -70,7 +70,8 @@ def create_function(
         prolog_statements.append(
             tree_ir.RegisterDebugInfoInstruction(
                 tree_ir.LiteralInstruction(function_name),
-                tree_ir.LoadGlobalInstruction(source_map_name)))
+                tree_ir.LoadGlobalInstruction(source_map_name),
+                tree_ir.LiteralInstruction(jit_runtime.BASELINE_JIT_ORIGIN_NAME)))
 
     # Create a LOCALS_NODE_NAME node, and connect it to the user root.
     prolog_statements.append(

+ 8 - 2
kernel/modelverse_jit/runtime.py

@@ -37,14 +37,20 @@ 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."""
 
-def format_trace_message(debug_info, function_name, source='JIT'):
+BASELINE_JIT_ORIGIN_NAME = "baseline-jit"
+"""The origin name for functions that were produced by the baseline JIT."""
+
+FAST_JIT_ORIGIN_NAME = "fast-jit"
+"""The origin name for functions that were produced by the fast JIT."""
+
+def format_trace_message(debug_info, function_name, origin='unknown'):
     """Creates a formatted trace message."""
     if debug_info is None:
         debug_info = 'unknown location '
     if function_name is None:
         function_name = 'unknown function'
 
-    return 'TRACE: %s(%s, %s)' % (debug_info, function_name, source)
+    return 'TRACE: %s(%s, %s)' % (debug_info, function_name, origin)
 
 def call_function(function_id, named_arguments, **kwargs):
     """Runs the function with the given id, passing it the specified argument dictionary."""

+ 3 - 2
kernel/modelverse_jit/tree_ir.py

@@ -1000,10 +1000,11 @@ class RunTailGeneratorFunctionInstruction(StateInstruction):
 
 class RegisterDebugInfoInstruction(StateInstruction):
     """An instruction that sends a DEBUG_INFO request to the request handler."""
-    def __init__(self, function_name, function_source_map):
+    def __init__(self, function_name, function_source_map, function_origin):
         StateInstruction.__init__(self)
         self.function_name = function_name
         self.function_source_map = function_source_map
+        self.function_origin = function_origin
 
     def get_result_type_impl(self):
         """Gets the type of value produced by this instruction."""
@@ -1015,7 +1016,7 @@ class RegisterDebugInfoInstruction(StateInstruction):
 
     def get_arguments(self):
         """Gets this state instruction's argument list."""
-        return [self.function_name, self.function_source_map]
+        return [self.function_name, self.function_source_map, self.function_origin]
 
 class VariableName(object):
     """A data structure that unifies names across instructions that access the

+ 2 - 1
kernel/modelverse_kernel/request_handler.py

@@ -10,6 +10,7 @@ class GeneratorStackEntry(object):
         self.generator = generator
         self.function_name = None
         self.source_map = None
+        self.function_source = None
         self.pending_requests = None
         self.finished_requests = True
         self.replies = []
@@ -352,6 +353,6 @@ class RequestHandler(object):
         # encountered.
         # Format: ("DEBUG_INFO", [function_name, source_map])
         top_entry = self.generator_stack[-1]
-        top_entry.function_name, top_entry.source_map = request_args
+        top_entry.function_name, top_entry.source_map, top_entry.function_source = request_args
         top_entry.append_reply(None)