[pypy-svn] r52787 - in pypy/branch/jit-hotpath/pypy/jit: rainbow rainbow/test timeshifter

arigo at codespeak.net arigo at codespeak.net
Thu Mar 20 19:08:30 CET 2008


Author: arigo
Date: Thu Mar 20 19:08:29 2008
New Revision: 52787

Modified:
   pypy/branch/jit-hotpath/pypy/jit/rainbow/fallback.py
   pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hp_vdict.py
   pypy/branch/jit-hotpath/pypy/jit/timeshifter/rcontainer.py
   pypy/branch/jit-hotpath/pypy/jit/timeshifter/vdict.py
   pypy/branch/jit-hotpath/pypy/jit/timeshifter/vlist.py
Log:
Test and fix, plus whackings trying to make the code translatable.


Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/fallback.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/fallback.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/fallback.py	Thu Mar 20 19:08:29 2008
@@ -65,7 +65,8 @@
                 gv_result = self.fetch_from_frame(box, gv_result)
 
             self.containers_gv[content] = gv_result
-            content.populate_gv_container(gv_result, self.getinitialboxgv)
+            content.populate_gv_container(self.rgenop, gv_result,
+                                          self.getinitialboxgv)
             return gv_result
 
     def initialize_from_frame(self, frame):

Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hp_vdict.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hp_vdict.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hp_vdict.py	Thu Mar 20 19:08:29 2008
@@ -38,6 +38,7 @@
             while i > 0:
                 i >>= 1
                 dic = {}
+                dic[11] = 66
                 if flag:
                     dic[12] = 34
                 else:

Modified: pypy/branch/jit-hotpath/pypy/jit/timeshifter/rcontainer.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/timeshifter/rcontainer.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/timeshifter/rcontainer.py	Thu Mar 20 19:08:29 2008
@@ -908,9 +908,8 @@
     def allocate_gv_container(self, rgenop):
         return self.typedesc.allocate(rgenop)
 
-    def populate_gv_container(self, gv_structptr, box_gv_reader):
-        return self.typedesc.populate(self.content_boxes,
-                                      gv_structptr, box_gv_reader)
+    def populate_gv_container(self, rgenop, gv_structptr, box_gv_reader):
+        self.typedesc.populate(self.content_boxes, gv_structptr, box_gv_reader)
 
 class VirtualizableStruct(VirtualStruct):
     

Modified: pypy/branch/jit-hotpath/pypy/jit/timeshifter/vdict.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/timeshifter/vdict.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/timeshifter/vdict.py	Thu Mar 20 19:08:29 2008
@@ -32,6 +32,9 @@
             def getboxes(self):
                 return self.item_boxes.values()
 
+            def getlength(self):
+                return len(self.item_boxes)
+
             def getitems_and_makeempty(self, rgenop):
                 result = [(rgenop.genconst(key), box, llhash(key))
                           for key, box in self.item_boxes.iteritems()]
@@ -61,6 +64,12 @@
                 for key, newbox in changes:
                     self.item_boxes[key] = newbox
 
+            def populate_gv_container(self, rgenop, gv_dictptr, box_gv_reader):
+                for key, valuebox in self.item_boxes.iteritems():
+                    gv_value = box_gv_reader(valuebox)
+                    gv_key = rgenop.genconst(key)
+                    self.typedesc.perform_setitem(gv_dictptr, gv_key, gv_value)
+
 
         class FrozenVirtualDict(AbstractFrozenVirtualDict):
 
@@ -142,22 +151,19 @@
         from pypy.rpython.lltypesystem import rdict
         DICT = self.DICT
         DICTPTR = self.DICTPTR
-        KEY = DICT.KEY
 
         def allocate(rgenop, n):
             d = rdict.ll_newdict_size(DICT, n)
             return rgenop.genconst(d)
 
-        def populate(item_boxes, gv_lst, box_gv_reader):
-            d = gv_lst.revealconst(DICTPTR)
-            for key, valuebox in item_boxes.iteritems():
-                if valuebox is not None:
-                    gv_value = box_gv_reader(valuebox)
-                    v = gv_value.revealconst(KEY)
-                    rdict.ll_dict_setitem(key, v)
+        def perform_setitem(gv_dictptr, gv_key, gv_value):
+            d = gv_dictptr.revealconst(DICTPTR)
+            k = gv_key.revealconst(DICT.KEY)
+            v = gv_value.revealconst(DICT.VALUE)
+            rdict.ll_dict_setitem(d, k, v)
 
         self.allocate = allocate
-        self.populate = populate
+        self.perform_setitem = perform_setitem
 
 TypeDesc = DictTypeDesc
 
@@ -271,6 +277,9 @@
     def getboxes(self):
         raise NotImplementedError
 
+    def getlength(self):
+        raise NotImplementedError
+
     def getitems_and_makeempty(self, rgenop):
         raise NotImplementedError
 
@@ -287,11 +296,7 @@
         raise NotImplementedError
 
     def allocate_gv_container(self, rgenop):
-        return self.typedesc.allocate(rgenop, len(self.item_boxes))
-
-    def populate_gv_container(self, gv_dictptr, box_gv_reader):
-        return self.typedesc.populate(self.item_boxes,
-                                      gv_dictptr, box_gv_reader)
+        return self.typedesc.allocate(rgenop, self.getlength())
 
 def oop_newdict(jitstate, oopspecdesc, deepfrozen):
     return oopspecdesc.typedesc.factory()

Modified: pypy/branch/jit-hotpath/pypy/jit/timeshifter/vlist.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/timeshifter/vlist.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/timeshifter/vlist.py	Thu Mar 20 19:08:29 2008
@@ -291,9 +291,8 @@
     def allocate_gv_container(self, rgenop):
         return self.typedesc.allocate(rgenop, len(self.item_boxes))
 
-    def populate_gv_container(self, gv_listptr, box_gv_reader):
-        return self.typedesc.populate(self.item_boxes,
-                                      gv_listptr, box_gv_reader)
+    def populate_gv_container(self, rgenop, gv_listptr, box_gv_reader):
+        self.typedesc.populate(self.item_boxes, gv_listptr, box_gv_reader)
 
 
 def oop_newlist(jitstate, oopspecdesc, deepfrozen, lengthbox, itembox=None):



More information about the Pypy-commit mailing list