[pypy-svn] pypy out-of-line-guards: Improve the test not to rely on builtins.

fijal commits-noreply at bitbucket.org
Sun Jan 2 10:56:26 CET 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: out-of-line-guards
Changeset: r40316:60a950aa40ab
Date: 2011-01-02 11:56 +0200
http://bitbucket.org/pypy/pypy/changeset/60a950aa40ab/

Log:	Improve the test not to rely on builtins. A hack to make sure we
	keep a reference to opaque ptr itself (should not matter after
	translating, since opaque ptr is not an actual object)

diff --git a/pypy/jit/metainterp/test/test_outofline.py b/pypy/jit/metainterp/test/test_outofline.py
--- a/pypy/jit/metainterp/test/test_outofline.py
+++ b/pypy/jit/metainterp/test/test_outofline.py
@@ -26,23 +26,23 @@
         class A(object):
             _jit_invariant_fields_ = ['x']
 
-        myjitdriver = JitDriver(greens = [], reds = ['i', 'total'])
+        myjitdriver = JitDriver(greens = [], reds = ['i', 'total',  'a'])
         
-        a = A()
-
         @dont_look_inside
-        def g(i):
+        def g(a, i):
             if i == 5:
                 a.x = 2
 
         def f():
+            a = A() 
             a.x = 1
             i = 0
             total = 0
             while i < 20:
-                myjitdriver.can_enter_jit(i=i, total=total)
-                myjitdriver.jit_merge_point(i=i, total=total)
-                g(i)
+                myjitdriver.can_enter_jit(i=i, total=total, a=a)
+                myjitdriver.jit_merge_point(i=i, total=total, a=a)
+                a = hint(a, promote=True)
+                g(a, i)
                 i += a.x
                 total += i
             return total

diff --git a/pypy/rlib/ropaque.py b/pypy/rlib/ropaque.py
--- a/pypy/rlib/ropaque.py
+++ b/pypy/rlib/ropaque.py
@@ -14,7 +14,9 @@
 
 def cast_obj_to_ropaque(obj):
     if not we_are_translated():
-        return lltype.opaqueptr(ROPAQUE.TO, 'ropaque', _obj=obj)
+        res = lltype.opaqueptr(ROPAQUE.TO, 'ropaque', _obj=obj)
+        obj._ropaqu_ptr = res # XXX ugly hack for weakrefs
+        return res
     else:
         ptr = cast_instance_to_base_ptr(obj)
         return lltype.cast_opaque_ptr(ROPAQUE, ptr)


More information about the Pypy-commit mailing list