Ver código fonte

Rename 'user_root' to 'task_root'

jonathanvdc 8 anos atrás
pai
commit
ddf162c025

+ 30 - 30
kernel/modelverse_jit/bytecode_to_tree.py

@@ -33,13 +33,13 @@ def apply_intrinsic(intrinsic_function, named_args):
 
 class AnalysisState(object):
     """The state of a bytecode analysis call graph."""
-    def __init__(self, jit, body_id, user_root, local_mapping, max_instructions=None):
+    def __init__(self, jit, body_id, task_root, local_mapping, max_instructions=None):
         self.analyzed_instructions = set()
         self.function_vars = set()
         self.local_vars = set()
         self.body_id = body_id
         self.max_instructions = max_instructions
-        self.user_root = user_root
+        self.task_root = task_root
         self.jit = jit
         self.local_mapping = local_mapping
         self.function_name = jit.jitted_entry_points[body_id]
@@ -65,14 +65,14 @@ class AnalysisState(object):
                 "Local is used as target of function call.")
         self.function_vars.add(local_id)
 
-    def retrieve_user_root(self):
-        """Creates an instruction that stores the user_root variable
+    def retrieve_task_root(self):
+        """Creates an instruction that stores the task_root variable
            in a local."""
         return tree_ir.StoreLocalInstruction(
-            'user_root',
+            'task_root',
             tree_ir.LoadIndexInstruction(
                 tree_ir.LoadLocalInstruction(jit_runtime.KWARGS_PARAMETER_NAME),
-                tree_ir.LiteralInstruction('user_root')))
+                tree_ir.LiteralInstruction('task_root')))
 
     def load_kernel(self):
         """Creates an instruction that loads the Modelverse kernel."""
@@ -202,14 +202,14 @@ class AnalysisState(object):
         #
         # value = <some tree>
         # last_output, last_output_link, new_last_output = \
-        #                 yield [("RD", [user_root, "last_output"]),
-        #                        ("RDE", [user_root, "last_output"]),
+        #                 yield [("RD", [task_root, "last_output"]),
+        #                        ("RDE", [task_root, "last_output"]),
         #                        ("CN", []),
         #                       ]
         # _, _, _, _ = \
         #                 yield [("CD", [last_output, "value", value]),
         #                        ("CD", [last_output, "next", new_last_output]),
-        #                        ("CD", [user_root, "last_output", new_last_output]),
+        #                        ("CD", [task_root, "last_output", new_last_output]),
         #                        ("DE", [last_output_link])
         #                       ]
         # yield None
@@ -217,17 +217,17 @@ class AnalysisState(object):
         value_val, = yield [("CALL_ARGS", [self.analyze, (instruction.value,)])]
         value_local = tree_ir.StoreLocalInstruction('value', value_val)
 
-        store_user_root = self.retrieve_user_root()
+        store_task_root = self.retrieve_task_root()
         last_output = tree_ir.StoreLocalInstruction(
             'last_output',
             tree_ir.ReadDictionaryValueInstruction(
-                store_user_root.create_load(),
+                store_task_root.create_load(),
                 tree_ir.LiteralInstruction('last_output')))
 
         last_output_link = tree_ir.StoreLocalInstruction(
             'last_output_link',
             tree_ir.ReadDictionaryEdgeInstruction(
-                store_user_root.create_load(),
+                store_task_root.create_load(),
                 tree_ir.LiteralInstruction('last_output')))
 
         new_last_output = tree_ir.StoreLocalInstruction(
@@ -236,7 +236,7 @@ class AnalysisState(object):
 
         result = tree_ir.create_block(
             value_local,
-            store_user_root,
+            store_task_root,
             last_output,
             last_output_link,
             new_last_output,
@@ -249,7 +249,7 @@ class AnalysisState(object):
                 tree_ir.LiteralInstruction('next'),
                 new_last_output.create_load()),
             tree_ir.CreateDictionaryEdgeInstruction(
-                store_user_root.create_load(),
+                store_task_root.create_load(),
                 tree_ir.LiteralInstruction('last_output'),
                 new_last_output.create_load()),
             tree_ir.DeleteEdgeInstruction(last_output_link.create_load()),
@@ -272,7 +272,7 @@ class AnalysisState(object):
         #
         #     value = None
         #     while True:
-        #         _input = yield [("RD", [user_root, "input"])]
+        #         _input = yield [("RD", [task_root, "input"])]
         #         value = yield [("RD", [_input, "value"])]
         #
         #         if value is None:
@@ -282,15 +282,15 @@ class AnalysisState(object):
         #             break
         #
         #     _next = yield [("RD", [_input, "next"])]
-        #     yield [("CD", [user_root, "input", _next])]
+        #     yield [("CD", [task_root, "input", _next])]
         #     yield [("CE", [jit_locals, value])]
         #     yield [("DN", [_input])]
 
-        user_root = self.retrieve_user_root()
+        task_root = self.retrieve_task_root()
         _input = tree_ir.StoreLocalInstruction(
             None,
             tree_ir.ReadDictionaryValueInstruction(
-                user_root.create_load(),
+                task_root.create_load(),
                 tree_ir.LiteralInstruction('input')))
 
         value = tree_ir.StoreLocalInstruction(
@@ -302,7 +302,7 @@ class AnalysisState(object):
         raise primitive_functions.PrimitiveFinished(
             tree_ir.CompoundInstruction(
                 tree_ir.create_block(
-                    user_root,
+                    task_root,
                     value.create_store(tree_ir.LiteralInstruction(None)),
                     tree_ir.LoopInstruction(
                         tree_ir.create_block(
@@ -321,7 +321,7 @@ class AnalysisState(object):
                                     tree_ir.NopInstruction()),
                                 tree_ir.BreakInstruction()))),
                     tree_ir.CreateDictionaryEdgeInstruction(
-                        user_root.create_load(),
+                        task_root.create_load(),
                         tree_ir.LiteralInstruction('input'),
                         tree_ir.ReadDictionaryValueInstruction(
                             _input.create_load(),
@@ -340,7 +340,7 @@ class AnalysisState(object):
         #     if 'local_var' in locals():
         #         tmp = local_var
         #     else:
-        #         _globals, = yield [("RD", [user_root, "globals"])]
+        #         _globals, = yield [("RD", [task_root, "globals"])]
         #         global_var, = yield [("RD", [_globals, var_name])]
         #
         #         if global_var is None:
@@ -354,12 +354,12 @@ class AnalysisState(object):
             raise primitive_functions.PrimitiveFinished(
                 tree_ir.LoadLocalInstruction(name))
 
-        user_root = self.retrieve_user_root()
+        task_root = self.retrieve_task_root()
         global_var = tree_ir.StoreLocalInstruction(
             'global_var',
             tree_ir.ReadDictionaryValueInstruction(
                 tree_ir.ReadDictionaryValueInstruction(
-                    user_root.create_load(),
+                    task_root.create_load(),
                     tree_ir.LiteralInstruction('globals')),
                 tree_ir.LiteralInstruction(instruction.variable.name)))
 
@@ -382,7 +382,7 @@ class AnalysisState(object):
                 tree_ir.LoadLocalInstruction(name),
                 tree_ir.CompoundInstruction(
                     tree_ir.create_block(
-                        user_root,
+                        task_root,
                         global_var,
                         err_block),
                     global_var.create_load())))
@@ -412,7 +412,7 @@ class AnalysisState(object):
         # To resolve a variable, we'll do something along the
         # lines of:
         #
-        #     _globals, = yield [("RD", [user_root, "globals"])]
+        #     _globals, = yield [("RD", [task_root, "globals"])]
         #     global_var = yield [("RD", [_globals, var_name])]
         #
         #     if global_var is None:
@@ -421,11 +421,11 @@ class AnalysisState(object):
         #
         #     tmp = global_var
 
-        user_root = self.retrieve_user_root()
+        task_root = self.retrieve_task_root()
         _globals = tree_ir.StoreLocalInstruction(
             '_globals',
             tree_ir.ReadDictionaryValueInstruction(
-                user_root.create_load(),
+                task_root.create_load(),
                 tree_ir.LiteralInstruction('globals')))
 
         global_var = tree_ir.StoreLocalInstruction(
@@ -437,7 +437,7 @@ class AnalysisState(object):
         raise primitive_functions.PrimitiveFinished(
             tree_ir.CompoundInstruction(
                 tree_ir.create_block(
-                    user_root,
+                    task_root,
                     _globals,
                     global_var,
                     tree_ir.SelectInstruction(
@@ -523,7 +523,7 @@ class AnalysisState(object):
             if compiled_func is None:
                 # Compile the callee.
                 yield [
-                    ("CALL_ARGS", [self.jit.jit_compile, (self.user_root, body_id, callee_name)])]
+                    ("CALL_ARGS", [self.jit.jit_compile, (self.task_root, body_id, callee_name)])]
 
             # Get the callee's name.
             compiled_func_name = self.jit.get_compiled_name(body_id)
@@ -607,7 +607,7 @@ class AnalysisState(object):
                             tree_ir.LoadLocalInstruction(jit_runtime.KWARGS_PARAMETER_NAME)))
                 else:
                     # Try to look up the name as a global.
-                    _globals, = yield [("RD", [self.user_root, "globals"])]
+                    _globals, = yield [("RD", [self.task_root, "globals"])]
                     global_var, = yield [("RD", [_globals, resolved_var_name])]
                     global_val, = yield [("RD", [global_var, "value"])]
 

+ 1 - 1
kernel/modelverse_jit/intrinsics.py

@@ -248,7 +248,7 @@ MISC_INTRINSICS = {
         lambda:
         tree_ir.LoadIndexInstruction(
             tree_ir.LoadLocalInstruction(jit_runtime.KWARGS_PARAMETER_NAME),
-            tree_ir.LiteralInstruction('user_root')),
+            tree_ir.LiteralInstruction('task_root')),
 
     # Dictionary operations
     'dict_read' :

+ 8 - 8
kernel/modelverse_jit/jit.py

@@ -58,7 +58,7 @@ def create_function(
             jit_runtime.LOCALS_NODE_NAME,
             tree_ir.LoadIndexInstruction(
                 tree_ir.LoadLocalInstruction(jit_runtime.KWARGS_PARAMETER_NAME),
-                tree_ir.LiteralInstruction('user_root')),
+                tree_ir.LiteralInstruction('task_root')),
             jit_runtime.LOCALS_EDGE_NAME))
     for (key, val) in param_dict.items():
         arg_ptr = tree_ir.create_new_local_node(
@@ -391,7 +391,7 @@ class ModelverseJit(object):
                     '' if suggested_name is None else "'" + suggested_name + "'",
                     body_id))
 
-    def jit_recompile(self, user_root, body_id, function_name):
+    def jit_recompile(self, task_root, body_id, function_name):
         """Replaces the function with the given name by compiling the bytecode at the given
            body id."""
         self.check_jittable(body_id, function_name)
@@ -432,7 +432,7 @@ class ModelverseJit(object):
                 "Function was marked '%s'." % jit_runtime.MUTABLE_FUNCTION_KEY)
         body_bytecode, = yield [("CALL_ARGS", [self.jit_parse_bytecode, (body_id,)])]
         state = bytecode_to_tree.AnalysisState(
-            self, body_id, user_root, body_param_dict,
+            self, body_id, task_root, body_param_dict,
             self.max_instructions)
         constructed_body, = yield [("CALL_ARGS", [state.analyze, (body_bytecode,)])]
         yield [("END_TRY", [])]
@@ -473,12 +473,12 @@ class ModelverseJit(object):
         """Deletes the function with the given function name."""
         del self.jit_globals[function_name]
 
-    def jit_compile(self, user_root, body_id, suggested_name=None):
+    def jit_compile(self, task_root, body_id, suggested_name=None):
         """Tries to jit the function defined by the given entry point id and parameter list."""
         # Generate a name for the function we're about to analyze, and pretend that
         # it already exists. (we need to do this for recursive functions)
         function_name = self.generate_function_name(body_id, suggested_name)
-        yield [("TAIL_CALL_ARGS", [self.jit_recompile, (user_root, body_id, function_name)])]
+        yield [("TAIL_CALL_ARGS", [self.jit_recompile, (task_root, body_id, function_name)])]
 
     def jit_thunk(self, get_function_body, global_name=None):
         """Creates a thunk from the given IR tree that computes the function's body id.
@@ -528,7 +528,7 @@ class ModelverseJit(object):
                 yield [("CATCH", [JitCompilationFailedException, __handle_jit_exception])]
                 compiled_function, = yield [
                     ("CALL_ARGS",
-                     [self.jit_recompile, (kwargs['user_root'], body_id, thunk_name)])]
+                     [self.jit_recompile, (kwargs['task_root'], body_id, thunk_name)])]
                 yield [("END_TRY", [])]
 
             # Call the compiled function.
@@ -564,7 +564,7 @@ class ModelverseJit(object):
         # Looks like we'll just have to build that thunk after all.
         # We want to look up the global function like so
         #
-        #     _globals, = yield [("RD", [kwargs['user_root'], "globals"])]
+        #     _globals, = yield [("RD", [kwargs['task_root'], "globals"])]
         #     global_var, = yield [("RD", [_globals, global_name])]
         #     function_id, = yield [("RD", [global_var, "value"])]
         #     body_id, = yield [("RD", [function_id, jit_runtime.FUNCTION_BODY_KEY])]
@@ -576,7 +576,7 @@ class ModelverseJit(object):
                         tree_ir.ReadDictionaryValueInstruction(
                             tree_ir.LoadIndexInstruction(
                                 tree_ir.LoadLocalInstruction(jit_runtime.KWARGS_PARAMETER_NAME),
-                                tree_ir.LiteralInstruction('user_root')),
+                                tree_ir.LiteralInstruction('task_root')),
                             tree_ir.LiteralInstruction('globals')),
                         tree_ir.LiteralInstruction(global_name)),
                     tree_ir.LiteralInstruction('value')),

+ 8 - 8
kernel/modelverse_jit/runtime.py

@@ -33,7 +33,7 @@ LOCALS_EDGE_NAME = "jit_locals_edge"
 
 def call_function(function_id, named_arguments, **kwargs):
     """Runs the function with the given id, passing it the specified argument dictionary."""
-    user_root = kwargs['user_root']
+    task_root = kwargs['task_root']
     kernel = kwargs['mvk']
     body_id, is_mutable = yield [
         ("RD", [function_id, FUNCTION_BODY_KEY]),
@@ -56,7 +56,7 @@ def call_function(function_id, named_arguments, **kwargs):
     yield [("TRY", [])]
     yield [("CATCH", [JitCompilationFailedException, handle_jit_failed])]
     # Try to compile.
-    compiled_func, = yield [("CALL_ARGS", [kernel.jit_compile, (user_root, body_id)])]
+    compiled_func, = yield [("CALL_ARGS", [kernel.jit_compile, (task_root, body_id)])]
     yield [("END_TRY", [])]
     # Add the keyword arguments to the argument dictionary.
     named_arguments.update(kwargs)
@@ -74,16 +74,16 @@ def interpret_function(function_id, named_arguments, **kwargs):
 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']
+    task_root = kwargs['task_root']
     kernel = kwargs['mvk']
-    user_frame, = yield [("RD", [user_root, "frame"])]
+    user_frame, = yield [("RD", [task_root, "frame"])]
     inst, = yield [("RD", [user_frame, "IP"])]
     kernel.jit.mark_entry_point(body_id)
 
     # Create a new stack frame.
     frame_link, new_phase, new_frame, new_evalstack, new_symbols, \
         new_returnvalue, intrinsic_return = \
-                    yield [("RDE", [user_root, "frame"]),
+                    yield [("RDE", [task_root, "frame"]),
                            ("CNV", ["init"]),
                            ("CN", []),
                            ("CN", []),
@@ -93,7 +93,7 @@ def interpret_function_body(body_id, named_arguments, **kwargs):
                           ]
 
     _, _, _, _, _, _, _, _, _, _ = \
-                    yield [("CD", [user_root, "frame", new_frame]),
+                    yield [("CD", [task_root, "frame", new_frame]),
                            ("CD", [new_frame, "evalstack", new_evalstack]),
                            ("CD", [new_frame, "symbols", new_symbols]),
                            ("CD", [new_frame, "returnvalue", new_returnvalue]),
@@ -136,9 +136,9 @@ def interpret_function_body(body_id, named_arguments, **kwargs):
 def get_input(**parameters):
     """Retrieves input."""
     mvk = parameters["mvk"]
-    user_root = parameters["user_root"]
+    task_root = parameters["task_root"]
     while 1:
-        yield [("CALL_ARGS", [mvk.input_init, (user_root,)])]
+        yield [("CALL_ARGS", [mvk.input_init, (task_root,)])]
         # Finished
         if mvk.success:
             # Got some input, so we can access it

+ 2 - 2
kernel/modelverse_kernel/compiled_legacy.py

@@ -471,10 +471,10 @@ def retype(a, b, c, **remainder):
 
 def __get_input(parameters):
     mvk = parameters["mvk"]
-    user_root = parameters["user_root"]
+    task_root = parameters["task_root"]
     while 1:
         try:
-            gen = mvk.input_init(user_root)
+            gen = mvk.input_init(task_root)
             inp = None
             while 1:
                 inp = yield gen.send(inp)