[pypy-svn] r74672 - in pypy/branch/blackhole-improvement/pypy/jit/metainterp: . test

arigo at codespeak.net arigo at codespeak.net
Sat May 22 13:01:03 CEST 2010


Author: arigo
Date: Sat May 22 13:01:01 2010
New Revision: 74672

Modified:
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_slist.py
Log:
Make test_slist pass.


Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py	Sat May 22 13:01:01 2010
@@ -783,33 +783,52 @@
     # ----------
     # list operations
 
-    @arguments("r", "d", "i", returns="i")
-    def bhimpl_check_neg_index(array, arraydescr, index):
-        xxx
-
-    @arguments("r", "d", "i", returns="i")
-    def bhimpl_check_resizable_neg_index(list, lengthdescr, index):
-        xxx
-
-    @arguments()
-    def bhimpl_getlistitem_gc_i(yyy):
-        xxx
-    @arguments()
-    def bhimpl_getlistitem_gc_r(yyy):
-        xxx
-    @arguments()
-    def bhimpl_getlistitem_gc_f(yyy):
-        xxx
+    @arguments("cpu", "r", "d", "i", returns="i")
+    def bhimpl_check_neg_index(cpu, array, arraydescr, index):
+        if index < 0:
+            index += cpu.bh_arraylen_gc(arraydescr, array)
+        return index
 
-    @arguments()
-    def bhimpl_setlistitem_gc_i(yyy):
-        xxx
-    @arguments()
-    def bhimpl_setlistitem_gc_r(yyy):
-        xxx
-    @arguments()
-    def bhimpl_setlistitem_gc_f(yyy):
-        xxx
+    @arguments("cpu", "r", "d", "i", returns="i")
+    def bhimpl_check_resizable_neg_index(cpu, lst, lengthdescr, index):
+        if index < 0:
+            index += cpu.bh_getfield_gc_i(lst, lengthdescr)
+        return index
+
+    @arguments("cpu", "d", "d", "d", "d", "i", returns="r")
+    def bhimpl_newlist(cpu, structdescr, lengthdescr, itemsdescr,
+                       arraydescr, length):
+        result = cpu.bh_new(structdescr)
+        cpu.bh_setfield_gc_i(result, lengthdescr, length)
+        items = cpu.bh_new_array(arraydescr, length)
+        cpu.bh_setfield_gc_r(result, itemsdescr, items)
+        return result
+
+    @arguments("cpu", "r", "d", "d", "i", returns="i")
+    def bhimpl_getlistitem_gc_i(cpu, lst, itemsdescr, arraydescr, index):
+        items = cpu.bh_getfield_gc_r(lst, itemsdescr)
+        return cpu.bh_getarrayitem_gc_i(arraydescr, items, index)
+    @arguments("cpu", "r", "d", "d", "i", returns="r")
+    def bhimpl_getlistitem_gc_r(cpu, lst, itemsdescr, arraydescr, index):
+        items = cpu.bh_getfield_gc_r(lst, itemsdescr)
+        return cpu.bh_getarrayitem_gc_r(arraydescr, items, index)
+    @arguments("cpu", "r", "d", "d", "i", returns="f")
+    def bhimpl_getlistitem_gc_f(cpu, lst, itemsdescr, arraydescr, index):
+        items = cpu.bh_getfield_gc_r(lst, itemsdescr)
+        return cpu.bh_getarrayitem_gc_f(arraydescr, items, index)
+
+    @arguments("cpu", "r", "d", "d", "i", "i")
+    def bhimpl_setlistitem_gc_i(cpu, lst, itemsdescr, arraydescr, index, nval):
+        items = cpu.bh_getfield_gc_r(lst, itemsdescr)
+        cpu.bh_setarrayitem_gc_i(arraydescr, items, index, nval)
+    @arguments("cpu", "r", "d", "d", "i", "r")
+    def bhimpl_setlistitem_gc_r(cpu, lst, itemsdescr, arraydescr, index, nval):
+        items = cpu.bh_getfield_gc_r(lst, itemsdescr)
+        cpu.bh_setarrayitem_gc_r(arraydescr, items, index, nval)
+    @arguments("cpu", "r", "d", "d", "i", "f")
+    def bhimpl_setlistitem_gc_f(cpu, lst, itemsdescr, arraydescr, index, nval):
+        items = cpu.bh_getfield_gc_r(lst, itemsdescr)
+        cpu.bh_setarrayitem_gc_f(arraydescr, items, index, nval)
 
     # ----------
     # the following operations are directly implemented by the backend

Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py	Sat May 22 13:01:01 2010
@@ -437,7 +437,7 @@
     @arguments("orgpc", "box", "descr", "box")
     def opimpl_check_neg_index(self, orgpc, arraybox, arraydescr, indexbox):
         negbox = self.metainterp.execute_and_record(
-            rop.INT_LT, None, indexbox, ConstInt(0))
+            rop.INT_LT, None, indexbox, history.CONST_FALSE)
         negbox = self.implement_guard_value(orgpc, negbox)
         if negbox.getint():
             # the index is < 0; add the array length to it
@@ -447,7 +447,7 @@
                 rop.INT_ADD, None, indexbox, lenbox)
         return indexbox
 
-    @FixME  #arguments("descr", "descr", "descr", "descr", "box")
+    @arguments("descr", "descr", "descr", "descr", "box")
     def opimpl_newlist(self, structdescr, lengthdescr, itemsdescr, arraydescr,
                        sizebox):
         sbox = self.metainterp.execute_and_record(rop.NEW, structdescr)
@@ -457,13 +457,19 @@
                                                   sizebox)
         self.metainterp.execute_and_record(rop.SETFIELD_GC, itemsdescr,
                                            sbox, abox)
-        self.make_result_box(sbox)
+        return sbox
 
-    @FixME  #arguments("box", "descr", "descr", "box")
-    def opimpl_getlistitem_gc(self, listbox, itemsdescr, arraydescr, indexbox):
+    @arguments("box", "descr", "descr", "box")
+    def _opimpl_getlistitem_gc_any(self, listbox, itemsdescr, arraydescr,
+                                   indexbox):
         arraybox = self.metainterp.execute_and_record(rop.GETFIELD_GC,
                                                       itemsdescr, listbox)
-        self.execute_with_descr(rop.GETARRAYITEM_GC, arraydescr, arraybox, indexbox)
+        return self.execute_with_descr(rop.GETARRAYITEM_GC,
+                                       arraydescr, arraybox, indexbox)
+
+    opimpl_getlistitem_gc_i = _opimpl_getlistitem_gc_any
+    opimpl_getlistitem_gc_r = _opimpl_getlistitem_gc_any
+    opimpl_getlistitem_gc_f = _opimpl_getlistitem_gc_any
 
     @arguments("box", "descr", "descr", "box", "box")
     def _opimpl_setlistitem_gc_any(self, listbox, itemsdescr, arraydescr,

Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_slist.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_slist.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_slist.py	Sat May 22 13:01:01 2010
@@ -1,5 +1,4 @@
 import py
-from pypy.jit.metainterp.policy import StopAtXPolicy
 from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
 from pypy.rlib.jit import JitDriver, OPTIMIZER_SIMPLE
 



More information about the Pypy-commit mailing list