[pypy-svn] r65904 - pypy/branch/pyjitpl5/pypy/jit/metainterp

antocuni at codespeak.net antocuni at codespeak.net
Wed Jun 24 12:21:28 CEST 2009


Author: antocuni
Date: Wed Jun 24 12:21:27 2009
New Revision: 65904

Modified:
   pypy/branch/pyjitpl5/pypy/jit/metainterp/typesystem.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
Log:
try to make the ootype version of this code RPython


Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/typesystem.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/typesystem.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/typesystem.py	Wed Jun 24 12:21:27 2009
@@ -12,27 +12,6 @@
     assert isinstance(T, ootype.OOType)
     return T
 
-def getlength(array):
-    if isinstance(array, ootype._array):
-        return array.ll_length()
-    else:
-        return len(array)      # assume a Ptr(GcArray)
-getlength._annspecialcase_ = 'specialize:ll'
-
-def getarrayitem(array, i):
-    if isinstance(array, ootype._array):
-        return array.ll_getitem_fast(i)
-    else:
-        return array[i]        # assume a Ptr(GcArray)
-getarrayitem._annspecialcase_ = 'specialize:ll'
-
-def setarrayitem(array, i, newvalue):
-    if isinstance(array, ootype._array):
-        array.ll_setitem_fast(i, newvalue)
-    else:
-        array[i] = newvalue    # assume a Ptr(GcArray)
-setarrayitem._annspecialcase_ = 'specialize:ll'
-
 def fieldType(T, name):
     if isinstance(T, lltype.Struct):
         return getattr(T, name)
@@ -103,6 +82,15 @@
         if isinstance(box, history.BoxPtr):
             box.value = lltype.nullptr(llmemory.GCREF.TO)
 
+    def getlength(self, array):
+        return len(array)
+
+    def getarrayitem(self, array, i):
+        return array[i]
+
+    def setarrayitem(self, array, i, newvalue):
+        array[i] = newvalue
+
 
 class OOTypeHelper(TypeSystemHelper):
 
@@ -148,6 +136,15 @@
         if isinstance(box, history.BoxObj):
             box.value = ootype.NULL
 
+    def getlength(self, array):
+        return array.ll_length()
+
+    def getarrayitem(self, array, i):
+        return array.ll_getitem_fast(i)
+
+    def setarrayitem(self, array, i, newvalue):
+        array.ll_setitem_fast(i, newvalue)
+
 
 llhelper = LLTypeHelper()
 oohelper = OOTypeHelper()

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py	Wed Jun 24 12:21:27 2009
@@ -22,8 +22,8 @@
 from pypy.jit.metainterp.policy import JitPolicy
 from pypy.jit.metainterp.typesystem import LLTypeHelper, OOTypeHelper
 from pypy.jit.metainterp.jitprof import Profiler
-from pypy.jit.metainterp.typesystem import deref, getlength
-from pypy.jit.metainterp.typesystem import getarrayitem, setarrayitem
+from pypy.jit.metainterp.typesystem import deref#, getlength
+#from pypy.jit.metainterp.typesystem import getarrayitem, setarrayitem
 
 # ____________________________________________________________
 # Bootstrapping
@@ -533,6 +533,10 @@
         self.array_field_descrs = [cpu.fielddescrof(VTYPE, name)
                                    for name in array_fields]
         #
+        getlength = warmrunnerdesc.ts.getlength
+        getarrayitem = warmrunnerdesc.ts.getarrayitem
+        setarrayitem = warmrunnerdesc.ts.setarrayitem
+        #
         def read_boxes(cpu, virtualizable):
             boxes = []
             for _, fieldname in unroll_static_fields:
@@ -726,7 +730,11 @@
     else:
         MAX_HASH_TABLE_BITS = 1
     THRESHOLD_LIMIT = sys.maxint // 2
-
+    #
+    getlength = warmrunnerdesc.ts.getlength
+    getarrayitem = warmrunnerdesc.ts.getarrayitem
+    setarrayitem = warmrunnerdesc.ts.setarrayitem
+    #
     class MachineCodeEntryPoint(object):
         next = None    # linked list
         def __init__(self, bridge, *greenargs):
@@ -758,7 +766,7 @@
                     i = i + 1
                 for typecode, fieldname in vable_array_fields:
                     lst = getattr(virtualizable, fieldname)
-                    for j in range(len(lst)):
+                    for j in range(getlength(lst)):
                         x = getarrayitem(lst, j)
                         set_future_value(i, x, typecode)
                         i = i + 1



More information about the Pypy-commit mailing list