[pypy-commit] pypy x86-dump-labels: actually print the offsets in the log
antocuni
noreply at buildbot.pypy.org
Thu May 12 13:53:28 CEST 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: x86-dump-labels
Changeset: r44097:bd0a0aaf7b2e
Date: 2011-05-12 13:26 +0200
http://bitbucket.org/pypy/pypy/changeset/bd0a0aaf7b2e/
Log: actually print the offsets in the log
diff --git a/pypy/jit/metainterp/logger.py b/pypy/jit/metainterp/logger.py
--- a/pypy/jit/metainterp/logger.py
+++ b/pypy/jit/metainterp/logger.py
@@ -17,30 +17,30 @@
def log_loop(self, inputargs, operations, number=0, type=None, labels=None):
if type is None:
debug_start("jit-log-noopt-loop")
- self._log_operations(inputargs, operations)
+ self._log_operations(inputargs, operations, labels)
debug_stop("jit-log-noopt-loop")
else:
debug_start("jit-log-opt-loop")
debug_print("# Loop", number, ":", type,
"with", len(operations), "ops")
- self._log_operations(inputargs, operations)
+ self._log_operations(inputargs, operations, labels)
debug_stop("jit-log-opt-loop")
def log_bridge(self, inputargs, operations, number=-1, labels=None):
if number == -1:
debug_start("jit-log-noopt-bridge")
- self._log_operations(inputargs, operations)
+ self._log_operations(inputargs, operations, labels)
debug_stop("jit-log-noopt-bridge")
else:
debug_start("jit-log-opt-bridge")
debug_print("# bridge out of Guard", number,
"with", len(operations), "ops")
- self._log_operations(inputargs, operations)
+ self._log_operations(inputargs, operations, labels)
debug_stop("jit-log-opt-bridge")
def log_short_preamble(self, inputargs, operations):
debug_start("jit-log-short-preamble")
- self._log_operations(inputargs, operations)
+ self._log_operations(inputargs, operations, labels=None)
debug_stop("jit-log-short-preamble")
def repr_of_descr(self, descr):
@@ -75,9 +75,11 @@
else:
return '?'
- def _log_operations(self, inputargs, operations):
+ def _log_operations(self, inputargs, operations, labels):
if not have_debug_prints():
return
+ if labels is None:
+ labels = {}
memo = {}
if inputargs is not None:
args = ", ".join([self.repr_of_arg(memo, arg) for arg in inputargs])
@@ -89,6 +91,11 @@
reclev = op.getarg(1).getint()
debug_print("debug_merge_point('%s', %s)" % (loc, reclev))
continue
+ offset = labels.get(op, -1)
+ if offset == -1:
+ s_offset = ""
+ else:
+ s_offset = "+%d: " % offset
args = ", ".join([self.repr_of_arg(memo, op.getarg(i)) for i in range(op.numargs())])
if op.result is not None:
res = self.repr_of_arg(memo, op.result) + " = "
@@ -108,8 +115,11 @@
for arg in op.getfailargs()]) + ']'
else:
fail_args = ''
- debug_print(res + op.getopname() +
+ debug_print(s_offset + res + op.getopname() +
'(' + args + ')' + fail_args)
+ if labels and None in labels:
+ offset = labels[None]
+ debug_print("+%d: # --end of the loop--" % offset)
def int_could_be_an_address(x):
diff --git a/pypy/jit/metainterp/test/test_logger.py b/pypy/jit/metainterp/test/test_logger.py
--- a/pypy/jit/metainterp/test/test_logger.py
+++ b/pypy/jit/metainterp/test/test_logger.py
@@ -31,10 +31,10 @@
return log_stream.getvalue()
class Logger(logger.Logger):
- def log_loop(self, loop, namespace={}):
+ def log_loop(self, loop, namespace={}, labels=None):
self.namespace = namespace
return capturing(logger.Logger.log_loop, self,
- loop.inputargs, loop.operations)
+ loop.inputargs, loop.operations, labels=labels)
def repr_of_descr(self, descr):
for k, v in self.namespace.items():
@@ -178,3 +178,27 @@
output = capturing(bare_logger.log_bridge, [], [], 3)
assert output.splitlines()[0] == "# bridge out of Guard 3 with 0 ops"
pure_parse(output)
+
+ def test_labels(self):
+ inp = '''
+ [i0]
+ i1 = int_add(i0, 1)
+ i2 = int_mul(i1, 2)
+ jump(i2)
+ '''
+ loop = pure_parse(inp)
+ ops = loop.operations
+ labels = {
+ ops[0]: 10,
+ ops[2]: 30,
+ None: 40
+ }
+ logger = Logger(self.make_metainterp_sd())
+ output = logger.log_loop(loop, labels=labels)
+ assert output.strip() == """
+[i0]
++10: i2 = int_add(i0, 1)
+i4 = int_mul(i2, 2)
++30: jump(i4)
++40: # --end of the loop--
+""".strip()
More information about the pypy-commit
mailing list