[pypy-svn] r64731 - pypy/branch/pyjitpl5/pypy/jit/metainterp
arigo at codespeak.net
arigo at codespeak.net
Mon Apr 27 15:27:41 CEST 2009
Author: arigo
Date: Mon Apr 27 15:27:39 2009
New Revision: 64731
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/TODO
pypy/branch/pyjitpl5/pypy/jit/metainterp/dump.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
Log:
Checking in some debugging output.
Controlled by DEBUG={0,1,2} in pyjitpl.py.
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/TODO
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/TODO (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/TODO Mon Apr 27 15:27:39 2009
@@ -8,3 +8,5 @@
* support floats
* fix bugs in virtualizables, but think first
+
+* kill empty pairs setup_exception_block/teardown_exception_block
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/dump.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/dump.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/dump.py Mon Apr 27 15:27:39 2009
@@ -106,7 +106,7 @@
args = []
def wrapper_callback(src, *newargs):
args.extend(newargs)
- opimpl.argspec(wrapper_callback)(src, 'pc')
+ opimpl.argspec(wrapper_callback, 0)(src, 'pc')
args = map(str, args)
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py Mon Apr 27 15:27:39 2009
@@ -63,6 +63,15 @@
except AttributeError:
return box.value
+class ReprRPython:
+ def __init__(self):
+ self.seen = {}
+ def repr_rpython(self, box, typechars):
+ n = self.seen.setdefault(box, len(self.seen))
+ return '%s/%s%d' % (box.get_(), typechars, n)
+
+repr_rpython = ReprRPython().repr_rpython
+
class AbstractValue(object):
__slots__ = ()
@@ -101,6 +110,9 @@
def sort_key(self):
raise NotImplementedError
+ def repr_rpython(self):
+ return '%s' % self
+
class AbstractDescr(AbstractValue):
def handle_fail_op(self, metainterp, fail_op):
raise NotImplementedError
@@ -213,6 +225,9 @@
sort_key = getint
+ def repr_rpython(self):
+ return repr_rpython(self, 'ci')
+
CONST_FALSE = ConstInt(0)
CONST_TRUE = ConstInt(1)
@@ -253,6 +268,9 @@
def _getrepr_(self):
return self.value
+ def repr_rpython(self):
+ return repr_rpython(self, 'ca')
+
class ConstPtr(Const):
type = PTR
value = lltype.nullptr(llmemory.GCREF.TO)
@@ -284,6 +302,9 @@
_getrepr_ = repr_pointer
+ def repr_rpython(self):
+ return repr_rpython(self, 'cp')
+
class ConstObj(Const):
type = OBJ
value = ootype.NULL
@@ -318,6 +339,9 @@
_getrepr_ = repr_object
+ def repr_rpython(self):
+ return repr_rpython(self, 'co')
+
class Box(AbstractValue):
__slots__ = ()
_extended_display = True
@@ -394,6 +418,9 @@
def _getrepr_(self):
return self.value
+ def repr_rpython(self):
+ return repr_rpython(self, 'bi')
+
changevalue_int = __init__
class BoxPtr(Box):
@@ -422,6 +449,9 @@
def set_future_value(self, cpu, j):
cpu.set_future_value_ptr(j, self.value)
+ def repr_rpython(self):
+ return repr_rpython(self, 'bp')
+
_getrepr_ = repr_pointer
changevalue_ptr = __init__
@@ -451,6 +481,9 @@
def set_future_value(self, cpu, j):
cpu.set_future_value_obj(j, self.value)
+ def repr_rpython(self):
+ return repr_rpython(self, 'bo')
+
_getrepr_ = repr_object
changevalue_obj = __init__
@@ -463,7 +496,7 @@
# The TreeLoop class contains a loop or a generalized loop, i.e. a tree
# of operations. Each branch ends in a jump which can go either to
-# the top of the same loop, or to another TreeLoop.
+# the top of the same loop, or to another TreeLoop; or it ends in a FAIL.
class Base(object):
"""Common base class for TreeLoop and History."""
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py Mon Apr 27 15:27:39 2009
@@ -36,29 +36,33 @@
debug_print(msg)
class arguments(object):
- def __init__(self, *argtypes, **kwargs):
- self.result = kwargs.pop("returns", None)
- assert not kwargs
+ def __init__(self, *argtypes):
self.argtypes = argtypes
def __eq__(self, other):
if not isinstance(other, arguments):
return NotImplemented
- return self.argtypes == other.argtypes and self.result == other.result
+ return self.argtypes == other.argtypes
def __ne__(self, other):
if not isinstance(other, arguments):
return NotImplemented
- return self.argtypes != other.argtypes or self.result != other.result
+ return self.argtypes != other.argtypes
- def __call__(self, func):
- result = self.result
+ def __call__(self, func, DEBUG=DEBUG):
argtypes = unrolling_iterable(self.argtypes)
def wrapped(self, orgpc):
args = (self, )
+ if DEBUG >= 2:
+ s = '%s:%d\t%s' % (self.jitcode.name, orgpc, name)
+ else:
+ s = ''
for argspec in argtypes:
if argspec == "box":
- args += (self.load_arg(), )
+ box = self.load_arg()
+ args += (box, )
+ if DEBUG >= 2:
+ s += '\t' + box.repr_rpython()
elif argspec == "constbox":
args += (self.load_const_arg(), )
elif argspec == "int":
@@ -103,17 +107,17 @@
args += (virtualizabledesc, )
else:
assert 0, "unknown argtype declaration: %r" % (argspec,)
+ if DEBUG >= 2:
+ debug_print(s)
val = func(*args)
- if result is not None:
- if result == "box":
- self.make_result_box(val)
- else:
- assert 0, "unknown result declaration: %r" % (result,)
- return False
+ if DEBUG >= 2:
+ reprboxes = ' '.join([box.repr_rpython() for box in self.env])
+ debug_print(' env=[%s]' % (reprboxes,))
if val is None:
val = False
return val
- wrapped.func_name = "wrap_" + func.func_name
+ name = func.func_name
+ wrapped.func_name = "wrap_" + name
wrapped.argspec = self
return wrapped
@@ -601,16 +605,17 @@
def opimpl_oounicode_unichar(self, obj, base):
self.execute(rop.OOUNICODE_UNICHAR, [obj, base])
- @arguments("orgpc", "box", returns="box")
+ @arguments("orgpc", "box")
def opimpl_guard_value(self, pc, box):
- return self.implement_guard_value(pc, box)
+ constbox = self.implement_guard_value(pc, box)
+ self.make_result_box(constbox)
- @arguments("orgpc", "box", returns="box")
+ @arguments("orgpc", "box")
def opimpl_guard_class(self, pc, box):
clsbox = self.cls_of_box(box)
if isinstance(box, Box):
self.generate_guard(pc, rop.GUARD_CLASS, box, [clsbox])
- return clsbox
+ self.make_result_box(clsbox)
## @arguments("orgpc", "box", "builtin")
## def opimpl_guard_builtin(self, pc, box, builtin):
@@ -714,11 +719,11 @@
else:
box = consts[~num]
self.env.append(box)
- if DEBUG:
- values = [box.get_() for box in self.env]
- log('setup_resume_at_op %s:%d %s %d' % (self.jitcode.name,
- self.pc, values,
- self.exception_target))
+ if DEBUG >= 2:
+ values = ' '.join([box.repr_rpython() for box in self.env])
+ log('setup_resume_at_op %s:%d [%s] %d' % (self.jitcode.name,
+ self.pc, values,
+ self.exception_target))
def run_one_step(self):
# Execute the frame forward. This method contains a loop that leaves
More information about the Pypy-commit
mailing list