[pypy-commit] pypy default: allow the applevel creation of DMP objects and hopefully fix translation this

fijal noreply at buildbot.pypy.org
Sun Jun 19 20:22:59 CEST 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r45023:a3292e57297b
Date: 2011-06-19 20:26 +0200
http://bitbucket.org/pypy/pypy/changeset/a3292e57297b/

Log:	allow the applevel creation of DMP objects and hopefully fix
	translation this way

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
@@ -18,7 +18,7 @@
 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
+from pypy.module.pypyjit.interp_resop import debug_merge_point_from_boxes
 
 PyFrame._virtualizable2_ = ['last_instr', 'pycode',
                             'valuestackdepth', 'valuestack_w[*]',
@@ -53,7 +53,8 @@
     list_w = []
     for op in operations:
         if op.getopnum() == rop.DEBUG_MERGE_POINT:
-            list_w.append(space.wrap(W_DebugMergePoint(op.getarglist())))
+            list_w.append(space.wrap(debug_merge_point_from_boxes(
+                op.getarglist())))
         else:
             list_w.append(space.wrap(logops.repr_of_resop(op)))
     return list_w
diff --git a/pypy/module/pypyjit/interp_resop.py b/pypy/module/pypyjit/interp_resop.py
--- a/pypy/module/pypyjit/interp_resop.py
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -1,6 +1,6 @@
 
 from pypy.interpreter.typedef import TypeDef, interp_attrproperty
-from pypy.interpreter.baseobjspace import Wrappable, ObjSpace
+from pypy.interpreter.baseobjspace import Wrappable, ObjSpace, W_Root
 from pypy.interpreter.gateway import unwrap_spec, interp2app
 from pypy.interpreter.pycode import PyCode
 from pypy.rpython.lltypesystem import lltype, llmemory
@@ -11,19 +11,30 @@
     """ 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)
+    def __init__(self, mp_no, offset, pycode):
+        self.mp_no = mp_no
+        self.offset = offset
+        self.pycode = pycode
 
     @unwrap_spec('self', ObjSpace)
     def descr_repr(self, space):
         return space.wrap('DebugMergePoint()')
 
+ at unwrap_spec(ObjSpace, W_Root, int, int, PyCode)
+def new_debug_merge_point(space, w_tp, mp_no, offset, pycode):
+    return W_DebugMergePoint(mp_no, offset, pycode)
+
+def debug_merge_point_from_boxes(boxes):
+    mp_no = boxes[0].getint()
+    offset = boxes[2].getint()
+    llcode = lltype.cast_opaque_ptr(lltype.Ptr(OBJECT),
+                                    boxes[4].getref_base())
+    pycode = cast_base_ptr_to_instance(PyCode, llcode)
+    return W_DebugMergePoint(mp_no, offset, pycode)
+
 W_DebugMergePoint.typedef = TypeDef(
     'DebugMergePoint',
+    __new__ = interp2app(new_debug_merge_point),
     __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
@@ -119,3 +119,8 @@
         dmp = l[0][3][1]
         assert isinstance(dmp, pypyjit.DebugMergePoint)
         assert dmp.code is self.f.func_code
+
+    def test_creation(self):
+        import pypyjit
+        dmp = pypyjit.DebugMergePoint(0, 0, self.f.func_code)
+        assert dmp.code is self.f.func_code 


More information about the pypy-commit mailing list