[pypy-svn] r25251 - pypy/branch/jit-timeshifter-refactoring/timeshifter

arigo at codespeak.net arigo at codespeak.net
Mon Apr 3 14:39:36 CEST 2006


Author: arigo
Date: Mon Apr  3 14:39:30 2006
New Revision: 25251

Modified:
   pypy/branch/jit-timeshifter-refactoring/timeshifter/rcontainer.py
   pypy/branch/jit-timeshifter-refactoring/timeshifter/rvalue.py
Log:
(pedronis, arigo)

Fixes for exactmatch().



Modified: pypy/branch/jit-timeshifter-refactoring/timeshifter/rcontainer.py
==============================================================================
--- pypy/branch/jit-timeshifter-refactoring/timeshifter/rcontainer.py	(original)
+++ pypy/branch/jit-timeshifter-refactoring/timeshifter/rcontainer.py	Mon Apr  3 14:39:30 2006
@@ -91,8 +91,6 @@
         assert isinstance(PTRTYPE.TO, lltype.Array)
         FieldDesc.__init__(self, PTRTYPE, PTRTYPE.TO.OF)
 
-# ____________________________________________________________
-
 class StructFieldDesc(object):
     __metaclass__ = cachedtype
 
@@ -138,24 +136,35 @@
         rgenop.genop(jitstate.curblock, 'setfield', op_args,
                      rgenop.gv_Void)        
 
+# ____________________________________________________________
+
 class FrozenVirtualStruct(AbstractContainer):
 
-    def exactmatch(self, vstruct, outgoingvarboxes, memo):
+    def __init__(self, typedesc):
+        self.typedesc = typedesc
+        #self.fz_content initialized later
+
+    def exactmatch(self, box, outgoingvarboxes, memo):
+        vstruct = box.content
         contmemo = memo.containers
         if self in contmemo:
-            return vstruct is contmemo[self]
+            ok = vstruct is contmemo[self]
+            if not ok:
+                outgoingvarboxes.append(box)
+            return ok
         if vstruct in contmemo:
-            return contmemo[vstruct] is self 
+            assert contmemo[vstruct] is not self
+            outgoingvarboxes.append(box)
+            return False
         contmemo[self] = vstruct
         contmemo[vstruct] = self
-        self_length = len(self.fz_content_boxes)
-        vstruct_length = len(vstruct.content_boxes)
-        if self_length != vstruct_length:
+        if self.typedesc is not vstruct.typedesc:
+            outgoingvarboxes.append(box)
             return False
         self_boxes = self.fz_content_boxes
         vstruct_boxes = vstruct.content_boxes
         fullmatch = True
-        for i in range(self_length):
+        for i in range(len(self_boxes)):
             if not self_boxes[i].exactmatch(vstruct_boxes[i],
                                             outgoingvarboxes,
                                             memo):
@@ -180,12 +189,6 @@
             for box in self.content_boxes:
                 box.enter_block(newblock, incoming, memo)
 
-    def op_getfield(self, jitstate, fielddesc):
-        return self.content_boxes[fielddesc.fieldindex]
-
-    def op_setfield(self, jitstate, fielddesc, valuebox):
-        self.content_boxes[fielddesc.fieldindex] = valuebox
-
     def build_runtime_container(self, jitstate):
         if self.genvar:
             return self.genvar
@@ -211,7 +214,7 @@
         try:
             return contmemo[self]
         except KeyError:
-            result = contmemo[self] = FrozenVirtualStruct()
+            result = contmemo[self] = FrozenVirtualStruct(self.typedesc)
             frozens = [box.freeze(memo) for box in self.content_boxes]
             result.fz_content_boxes = frozens
             return result
@@ -228,6 +231,12 @@
             result.content_boxes = boxcopies
             return result
 
+    def op_getfield(self, jitstate, fielddesc):
+        return self.content_boxes[fielddesc.fieldindex]
+
+    def op_setfield(self, jitstate, fielddesc, valuebox):
+        self.content_boxes[fielddesc.fieldindex] = valuebox
+
     def op_getsubstruct(self, jitstate, fielddesc):
         #assert fielddesc.fieldindex == 0
         return rvalue.PtrRedBox(fielddesc.gv_resulttype, content=self)

Modified: pypy/branch/jit-timeshifter-refactoring/timeshifter/rvalue.py
==============================================================================
--- pypy/branch/jit-timeshifter-refactoring/timeshifter/rvalue.py	(original)
+++ pypy/branch/jit-timeshifter-refactoring/timeshifter/rvalue.py	Mon Apr  3 14:39:30 2006
@@ -334,8 +334,4 @@
             outgoingvarboxes.append(box)
             return False
         else:
-            result = self.fz_content.exactmatch(box.content, outgoingvarboxes,
-                                                memo)
-            if not result:
-                outgoingvarboxes.append(box)
-            return result
+            return self.fz_content.exactmatch(box, outgoingvarboxes, memo)



More information about the Pypy-commit mailing list