[pypy-svn] r65057 - pypy/branch/pyjitpl5/pypy/jit/backend/test

arigo at codespeak.net arigo at codespeak.net
Tue May 5 14:17:54 CEST 2009


Author: arigo
Date: Tue May  5 14:17:51 2009
New Revision: 65057

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/test/test_ll_random.py
   pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py
Log:
rop.SETARRAYITEM_GC.


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/test/test_ll_random.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/test/test_ll_random.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/test/test_ll_random.py	Tue May  5 14:17:51 2009
@@ -108,7 +108,8 @@
 
     def get_random_array(self, r):
         A = self.get_random_array_type(r)
-        length = r.random_integer() % 300      # length: between 0 and 299
+        length = (r.random_integer() // 15) % 300  # length: between 0 and 299
+                                                   # likely to be small
         p = lltype.malloc(A, length)
         for i in range(length):
             p[i] = rffi.cast(A.OF, r.random_integer())
@@ -240,6 +241,18 @@
                 continue
             break
 
+class SetArrayItemOperation(GetArrayItemOperation):
+    def produce_into(self, builder, r):
+        v, A, v_index, descr = self.field_descr(builder, r)
+        while True:
+            if r.random() < 0.3:
+                w = ConstInt(r.random_integer())
+            else:
+                w = r.choice(builder.intvars)
+            if rffi.cast(lltype.Signed, rffi.cast(A.OF, w.value)) == w.value:
+                break
+        builder.do(self.opnum, [v, v_index, w], descr)
+
 #class NewArrayOperation(test_random.AbstractOperation):
 #    ...
 
@@ -404,6 +417,7 @@
     OPERATIONS.append(NewOperation(rop.NEW_WITH_VTABLE))
 
     OPERATIONS.append(GetArrayItemOperation(rop.GETARRAYITEM_GC))
+    OPERATIONS.append(SetArrayItemOperation(rop.SETARRAYITEM_GC))
 
     OPERATIONS.append(GuardClassOperation(rop.GUARD_CLASS))
     OPERATIONS.append(CallOperation(rop.CALL))

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py	Tue May  5 14:17:51 2009
@@ -99,7 +99,8 @@
             for op in ops:
                 for arg in op.args:
                     if isinstance(arg, ConstPtr):
-                        writevar(arg, 'const_ptr')
+                        if arg not in names:
+                            writevar(arg, 'const_ptr')
                 if getattr(op, 'suboperations', None) is not None:
                     print_loop_prebuilt(op.suboperations)
 



More information about the Pypy-commit mailing list