[pypy-svn] r58066 - in pypy/branch/oo-jit/pypy: jit/codegen/cli/test translator/oosupport translator/oosupport/test_template

antocuni at codespeak.net antocuni at codespeak.net
Thu Sep 11 14:09:54 CEST 2008


Author: antocuni
Date: Thu Sep 11 14:09:49 2008
New Revision: 58066

Modified:
   pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_gencli_interpreter.py
   pypy/branch/oo-jit/pypy/translator/oosupport/constant.py
   pypy/branch/oo-jit/pypy/translator/oosupport/test_template/constant.py
Log:
make sure that constants of type Object are recorded only once by the
backends.  Some more jit tests pass.



Modified: pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_gencli_interpreter.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_gencli_interpreter.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_gencli_interpreter.py	Thu Sep 11 14:09:49 2008
@@ -100,8 +100,6 @@
     def test_indirect_gray_call(self):
         py.test.skip('mono 1.2 crashes, try again with a newer version')
         
-    test_constant_indirect_red_call = skip
-    test_constant_indirect_red_call_no_result = skip
     test_indirect_sometimes_residual_pure_red_call = skip
     test_red_int_add_ovf = skip
     test_nonzeroness_assert_while_compiling = skip

Modified: pypy/branch/oo-jit/pypy/translator/oosupport/constant.py
==============================================================================
--- pypy/branch/oo-jit/pypy/translator/oosupport/constant.py	(original)
+++ pypy/branch/oo-jit/pypy/translator/oosupport/constant.py	Thu Sep 11 14:09:49 2008
@@ -186,6 +186,9 @@
         should be an ootype constant value.  Not generally called
         directly, but it can be if desired. """
         assert not is_primitive(value)
+        if isinstance(value, ootype._object) and value: # leave ootype.NULL as is
+            value = value.obj
+            self.db.cts.lltype_to_cts(value._TYPE) # record const
         if value in self.cache:
             return self.cache[value]
         const = self._create_complex_const(value)
@@ -200,10 +203,6 @@
         """ A helper method which creates a Constant wrapper object for
         the given value.  Uses the types defined in the sub-class. """
 
-        if isinstance(value, ootype._object) and value: # leave ootype.NULL as is
-            value = value.obj
-            self.db.cts.lltype_to_cts(value._TYPE) # record const
-
         # Determine if the static type differs from the dynamic type.
         if isinstance(value, ootype._view):
             static_type = value._TYPE

Modified: pypy/branch/oo-jit/pypy/translator/oosupport/test_template/constant.py
==============================================================================
--- pypy/branch/oo-jit/pypy/translator/oosupport/test_template/constant.py	(original)
+++ pypy/branch/oo-jit/pypy/translator/oosupport/test_template/constant.py	Thu Sep 11 14:09:49 2008
@@ -154,3 +154,20 @@
             return s1
         res = self.interpret(fn, [], backendopt=False)
         assert res == 'hello world'
+
+    def test_unwrap_object(self):
+        A = ootype.Instance("A", ootype.ROOT, {})
+        a1 = ootype.new(A)
+        a2 = ootype.new(A)
+        obj1 = ootype.cast_to_object(a1)
+        obj2 = ootype.cast_to_object(a2)
+        def fn(flag):
+            if flag:
+                obj = obj1
+            else:
+                obj = obj2
+            a3 = ootype.cast_from_object(A, obj)
+            return a3 is a1
+        res = self.interpret(fn, [True], backendopt=False)
+        assert res is True
+    



More information about the Pypy-commit mailing list