Author: Hakan Ardo <[email protected]>
Branch: jit-short_from_state
Changeset: r44571:7fee08d52f42
Date: 2011-05-27 19:47 +0200
http://bitbucket.org/pypy/pypy/changeset/7fee08d52f42/
Log: log the virtual states for debugging
diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py
b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -339,6 +339,10 @@
debug_print("Bad virtual state at end of loop")
raise InvalidLoop
+ debug_start('jit-log-virtualstate')
+ virtual_state.debug_print('Closed loop with ')
+ debug_stop('jit-log-virtualstate')
+
return inputargs, short_inputargs, short
def add_op_to_short(self, op, short, short_seen):
@@ -640,13 +644,17 @@
args = op.getarglist()
modifier = VirtualStateAdder(self.optimizer)
virtual_state = modifier.get_virtual_state(args)
+ debug_start('jit-log-virtualstate')
+ virtual_state.debug_print("Looking for ")
for sh in short:
ok = False
extra_guards = []
-
+
+ debugmsg = 'Did not match '
if sh.virtual_state.generalization_of(virtual_state):
ok = True
+ debugmsg = 'Matched '
else:
try:
cpu = self.optimizer.cpu
@@ -655,9 +663,13 @@
extra_guards)
ok = True
+ debugmsg = 'Guarded to match '
except InvalidLoop:
pass
+ sh.virtual_state.debug_print(debugmsg)
+
if ok:
+ debug_stop('jit-log-virtualstate')
# FIXME: Do we still need the dry run
#if self.inline(sh.operations, sh.inputargs,
# op.getarglist(), dryrun=True):
@@ -683,6 +695,7 @@
self.emit_operation(guard)
self.optimizer.newoperations.append(jumpop)
return
+ debug_stop('jit-log-virtualstate')
retraced_count = loop_token.retraced_count
loop_token.retraced_count += 1
limit =
self.optimizer.metainterp_sd.warmrunnerdesc.memory_manager.retrace_limit
diff --git a/pypy/jit/metainterp/optimizeopt/virtualstate.py
b/pypy/jit/metainterp/optimizeopt/virtualstate.py
--- a/pypy/jit/metainterp/optimizeopt/virtualstate.py
+++ b/pypy/jit/metainterp/optimizeopt/virtualstate.py
@@ -10,6 +10,7 @@
from pypy.jit.metainterp.optimizeopt.intutils import IntBound
from pypy.jit.metainterp.resoperation import rop, ResOperation
from pypy.rlib.objectmodel import we_are_translated
+from pypy.rlib.debug import debug_start, debug_stop, debug_print
class AbstractVirtualStateInfo(resume.AbstractVirtualInfo):
position = -1
@@ -39,6 +40,20 @@
def _enum(self, virtual_state):
raise NotImplementedError
+
+ def debug_print(self, indent, seen):
+ self.debug_header(indent)
+ if self not in seen:
+ seen[self] = True
+ for s in self.fieldstate:
+ s.debug_print(indent + " ", seen)
+ else:
+ debug_print(indent + " ...")
+
+
+ def debug_header(self, indent):
+ raise NotImplementedError
+
class AbstractVirtualStructStateInfo(AbstractVirtualStateInfo):
def __init__(self, fielddescrs):
@@ -80,6 +95,7 @@
for s in self.fieldstate:
s.enum(virtual_state)
+
class VirtualStateInfo(AbstractVirtualStructStateInfo):
def __init__(self, known_class, fielddescrs):
AbstractVirtualStructStateInfo.__init__(self, fielddescrs)
@@ -91,6 +107,9 @@
if not self.known_class.same_constant(other.known_class):
return False
return True
+
+ def debug_header(self, indent):
+ debug_print(indent + 'VirtualStateInfo(%d):' % self.position)
class VStructStateInfo(AbstractVirtualStructStateInfo):
def __init__(self, typedescr, fielddescrs):
@@ -103,6 +122,9 @@
if self.typedescr is not other.typedescr:
return False
return True
+
+ def debug_header(self, indent):
+ debug_print(indent + 'VStructStateInfo(%d):' % self.position)
class VArrayStateInfo(AbstractVirtualStateInfo):
def __init__(self, arraydescr):
@@ -134,6 +156,10 @@
def _enum(self, virtual_state):
for s in self.fieldstate:
s.enum(virtual_state)
+
+ def debug_header(self, indent):
+ debug_print(indent + 'VArrayStateInfo(%d):' % self.position)
+
class NotVirtualStateInfo(AbstractVirtualStateInfo):
def __init__(self, value):
@@ -236,6 +262,15 @@
self.position_in_notvirtuals = len(virtual_state.notvirtuals)
virtual_state.notvirtuals.append(self)
+ def debug_print(self, indent, seen):
+ l = {LEVEL_UNKNOWN: 'Unknown',
+ LEVEL_NONNULL: 'NonNull',
+ LEVEL_KNOWNCLASS: 'KnownClass',
+ LEVEL_CONSTANT: 'Constant',
+ None: 'None'}[self.level]
+ debug_print(indent + 'NotVirtualInfo(%d' % self.position + ', ' +
+ l + ', ' + str(self.intbound) + ')')
+
class VirtualState(object):
def __init__(self, state):
self.state = state
@@ -276,6 +311,11 @@
return inputargs
+ def debug_print(self, hdr=''):
+ debug_print(hdr + "VirtualState():")
+ seen = {}
+ for s in self.state:
+ s.debug_print(" ", seen)
class VirtualStateAdder(resume.ResumeDataVirtualAdder):
def __init__(self, optimizer):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit