[pypy-svn] r67553 - in pypy/trunk/pypy/jit: backend/llgraph metainterp/test

antocuni at codespeak.net antocuni at codespeak.net
Mon Sep 7 14:24:58 CEST 2009


Author: antocuni
Date: Mon Sep  7 14:24:55 2009
New Revision: 67553

Modified:
   pypy/trunk/pypy/jit/backend/llgraph/llimpl.py
   pypy/trunk/pypy/jit/metainterp/test/test_basic.py
Log:
a test that was failing for ootype and the corresponding fix (a cast was missing)


Modified: pypy/trunk/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/trunk/pypy/jit/backend/llgraph/llimpl.py	Mon Sep  7 14:24:55 2009
@@ -775,6 +775,8 @@
         obj = ootype.cast_from_object(TYPE, obj)
         if isinstance(ootype.typeOf(newvalue), ootype.OOType):
             newvalue = ootype.cast_from_object(T, newvalue)
+        elif isinstance(T, lltype.Primitive):
+            newvalue = lltype.cast_primitive(T, newvalue)
         setattr(obj, fieldname, newvalue)
 
     def op_getarrayitem_gc(self, typedescr, obj, index):

Modified: pypy/trunk/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_basic.py	Mon Sep  7 14:24:55 2009
@@ -403,6 +403,24 @@
         assert res == 210
         self.check_history_(getfield_gc=0)
 
+    def test_setfield_bool(self):
+        class A:
+            def __init__(self):
+                self.flag = True
+        myjitdriver = JitDriver(greens = [], reds = ['n', 'obj'])
+        def f(n):
+            obj = A()
+            res = False
+            while n > 0:
+                myjitdriver.can_enter_jit(n=n, obj=obj)
+                myjitdriver.jit_merge_point(n=n, obj=obj)
+                obj.flag = False
+                n -= 1
+            return res
+        res = self.meta_interp(f, [7])
+        assert type(res) == bool
+        assert not res
+
     def test_switch_dict(self):
         def f(x):
             if   x == 1: return 61



More information about the Pypy-commit mailing list