Author: Maciej Fijalkowski <[email protected]>
Branch:
Changeset: r44998:0277ce1445df
Date: 2011-06-19 12:32 +0200
http://bitbucket.org/pypy/pypy/changeset/0277ce1445df/
Log: Expose debug_merge_points as actual code points (for the main
jitdriver)
diff --git a/pypy/module/pypyjit/__init__.py b/pypy/module/pypyjit/__init__.py
--- a/pypy/module/pypyjit/__init__.py
+++ b/pypy/module/pypyjit/__init__.py
@@ -8,6 +8,7 @@
'set_param': 'interp_jit.set_param',
'residual_call': 'interp_jit.residual_call',
'set_compile_hook': 'interp_jit.set_compile_hook',
+ 'DebugMergePoint': 'interp_resop.W_DebugMergePoint',
}
def setup_after_space_initialization(self):
diff --git a/pypy/module/pypyjit/interp_jit.py
b/pypy/module/pypyjit/interp_jit.py
--- a/pypy/module/pypyjit/interp_jit.py
+++ b/pypy/module/pypyjit/interp_jit.py
@@ -17,6 +17,8 @@
from opcode import opmap
from pypy.rlib.objectmodel import we_are_translated
from pypy.rlib.nonconst import NonConstant
+from pypy.jit.metainterp.resoperation import rop
+from pypy.module.pypyjit.interp_resop import W_DebugMergePoint
PyFrame._virtualizable2_ = ['last_instr', 'pycode',
'valuestackdepth', 'valuestack_w[*]',
@@ -50,7 +52,10 @@
def wrap_oplist(space, logops, operations):
list_w = []
for op in operations:
- list_w.append(space.wrap(logops.repr_of_resop(op)))
+ if op.getopnum() == rop.DEBUG_MERGE_POINT:
+ list_w.append(space.wrap(W_DebugMergePoint(op.getarglist())))
+ else:
+ list_w.append(space.wrap(logops.repr_of_resop(op)))
return list_w
class PyPyJitDriver(JitDriver):
diff --git a/pypy/module/pypyjit/interp_resop.py
b/pypy/module/pypyjit/interp_resop.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -0,0 +1,31 @@
+
+from pypy.interpreter.typedef import TypeDef, interp_attrproperty
+from pypy.interpreter.baseobjspace import Wrappable, ObjSpace
+from pypy.interpreter.gateway import unwrap_spec, interp2app
+from pypy.interpreter.pycode import PyCode
+from pypy.rpython.lltypesystem import lltype, llmemory
+from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
+from pypy.rpython.lltypesystem.rclass import OBJECT
+
+class W_DebugMergePoint(Wrappable):
+ """ A class representing debug_merge_point JIT operation
+ """
+
+ def __init__(self, boxes):
+ self.mp_no = boxes[0].getint()
+ self.offset = boxes[2].getint()
+ llcode = lltype.cast_opaque_ptr(lltype.Ptr(OBJECT),
+ boxes[4].getref_base())
+ self.pycode = cast_base_ptr_to_instance(PyCode, llcode)
+
+ @unwrap_spec('self', ObjSpace)
+ def descr_repr(self, space):
+ return space.wrap('DebugMergePoint()')
+
+W_DebugMergePoint.typedef = TypeDef(
+ 'DebugMergePoint',
+ __doc__ = W_DebugMergePoint.__doc__,
+ __repr__ = interp2app(W_DebugMergePoint.descr_repr),
+ code = interp_attrproperty('pycode', W_DebugMergePoint),
+)
+
diff --git a/pypy/module/pypyjit/test/test_jit_hook.py
b/pypy/module/pypyjit/test/test_jit_hook.py
--- a/pypy/module/pypyjit/test/test_jit_hook.py
+++ b/pypy/module/pypyjit/test/test_jit_hook.py
@@ -8,6 +8,7 @@
from pypy.jit.metainterp.logger import Logger
from pypy.rpython.annlowlevel import (cast_instance_to_base_ptr,
cast_base_ptr_to_instance)
+from pypy.rpython.lltypesystem import lltype, llmemory
from pypy.module.pypyjit.interp_jit import pypyjitdriver
from pypy.jit.tool.oparser import parse
from pypy.jit.metainterp.typesystem import llhelper
@@ -27,14 +28,17 @@
pass
return f
""")
+ cls.w_f = w_f
ll_code = cast_instance_to_base_ptr(w_f.code)
+ code_gcref = lltype.cast_opaque_ptr(llmemory.GCREF, ll_code)
logger = Logger(MockSD())
oplist = parse("""
[i1, i2]
i3 = int_add(i1, i2)
+ debug_merge_point(0, 0, 0, 0, ConstPtr(ptr0))
guard_true(i3) []
- """, namespace={'ptr0': 3}).operations
+ """, namespace={'ptr0': code_gcref}).operations
def interp_on_compile():
pypyjitdriver.on_compile(logger, LoopToken(), oplist, 'loop',
@@ -63,7 +67,7 @@
assert all[0][0][0].co_name == 'f'
assert all[0][0][1] == 0
assert all[0][0][2] == False
- assert len(all[0][1]) == 2
+ assert len(all[0][1]) == 3
assert 'int_add' in all[0][1][0]
self.on_compile_bridge()
assert len(all) == 2
@@ -103,3 +107,15 @@
self.on_compile_bridge()
assert len(l) == 2 # and did not crash
+ def test_on_compile_types(self):
+ import pypyjit
+ l = []
+
+ def hook(*args):
+ l.append(args)
+
+ pypyjit.set_compile_hook(hook)
+ self.on_compile()
+ dmp = l[0][3][1]
+ assert isinstance(dmp, pypyjit.DebugMergePoint)
+ assert dmp.code is self.f.func_code
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit