|
@@ -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"])]
|
|
|
|