[pypy-svn] r22797 - in pypy/dist/pypy/jit: . test

pedronis at codespeak.net pedronis at codespeak.net
Sat Jan 28 16:51:50 CET 2006


Author: pedronis
Date: Sat Jan 28 16:51:47 2006
New Revision: 22797

Modified:
   pypy/dist/pypy/jit/hintannotator.py
   pypy/dist/pypy/jit/hintbookkeeper.py
   pypy/dist/pypy/jit/hintmodel.py
   pypy/dist/pypy/jit/test/test_hint_annotation.py
Log:
(arre, arigo, pedronis)

union of abstract containers, structures for now.



Modified: pypy/dist/pypy/jit/hintannotator.py
==============================================================================
--- pypy/dist/pypy/jit/hintannotator.py	(original)
+++ pypy/dist/pypy/jit/hintannotator.py	Sat Jan 28 16:51:47 2006
@@ -7,7 +7,7 @@
 
     def __init__(self):
         RPythonAnnotator.__init__(self)
-        self.bookkeeper = HintBookkeeper() # XXX
+        self.bookkeeper = HintBookkeeper(self) # XXX
 
     def consider_op_malloc(self, hs_TYPE):
         TYPE = hs_TYPE.const

Modified: pypy/dist/pypy/jit/hintbookkeeper.py
==============================================================================
--- pypy/dist/pypy/jit/hintbookkeeper.py	(original)
+++ pypy/dist/pypy/jit/hintbookkeeper.py	Sat Jan 28 16:51:47 2006
@@ -4,10 +4,11 @@
 
 class HintBookkeeper(object):
 
-    def __init__(self):
+    def __init__(self, hannotator):
         self.pending_specializations = []
         self.origins = {}
         self.virtual_containers = {}
+        self.annotator = hannotator
 
     def enter(self, position_key):
         """Start of an operation.

Modified: pypy/dist/pypy/jit/hintmodel.py
==============================================================================
--- pypy/dist/pypy/jit/hintmodel.py	(original)
+++ pypy/dist/pypy/jit/hintmodel.py	Sat Jan 28 16:51:47 2006
@@ -135,3 +135,8 @@
 
     def int_eq((hs_c1, hs_c2)):
         return SomeLLConcreteValue(lltype.Bool)
+
+class __extend__(pairtype(SomeLLAbstractContainer, SomeLLAbstractContainer)):
+
+    def union((hs_cont1, hs_cont2)):
+        return SomeLLAbstractContainer(hs_cont1.contentdef.union(hs_cont2.contentdef))

Modified: pypy/dist/pypy/jit/test/test_hint_annotation.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_hint_annotation.py	(original)
+++ pypy/dist/pypy/jit/test/test_hint_annotation.py	Sat Jan 28 16:51:47 2006
@@ -118,7 +118,7 @@
 
 def test_op_meet():
     def meet(hs1, hs2):
-        HintBookkeeper().enter(None)
+        HintBookkeeper(None).enter(None)
         return pair(hs1, hs2).int_add()
     av1, av2 = SomeLLAbstractVariable(lltype.Signed), SomeLLAbstractVariable(lltype.Signed)
     cv1, cv2 = SomeLLConcreteValue(lltype.Signed), SomeLLConcreteValue(lltype.Signed)
@@ -183,6 +183,29 @@
     assert len(hs.origins) == 1
     assert len(hs.origins.keys()[0].origins) == 1
 
+def test_container_union():
+    S = lltype.GcStruct('helloworld', ('hello', lltype.Signed),
+                                      ('world', lltype.Signed))               
+    def ll_function(cond, x, y):
+        if cond:
+            s = lltype.malloc(S)
+            s.hello = x
+        else:
+            s = lltype.malloc(S)
+            s.world = y
+        return s.hello + s.world
+
+    hs = hannotate(ll_function, [bool, int, int])
+    assert isinstance(hs, SomeLLAbstractConstant)
+    assert hs.concretetype == lltype.Signed
+    assert len(hs.origins) == 1
+    assert len(hs.origins.keys()[0].origins) == 2
+    
+
+    
+
+  
+
         
 
 



More information about the Pypy-commit mailing list