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

pedronis at codespeak.net pedronis at codespeak.net
Sat Jan 28 19:49:10 CET 2006


Author: pedronis
Date: Sat Jan 28 19:49:08 2006
New Revision: 22807

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

hint annotate simple direct_call.



Modified: pypy/dist/pypy/jit/hintmodel.py
==============================================================================
--- pypy/dist/pypy/jit/hintmodel.py	(original)
+++ pypy/dist/pypy/jit/hintmodel.py	Sat Jan 28 19:49:08 2006
@@ -3,7 +3,7 @@
 from pypy.jit.hintbookkeeper import getbookkeeper
 from pypy.rpython.lltypesystem import lltype
 
-UNARY_OPERATIONS = "same_as hint getfield setfield".split()
+UNARY_OPERATIONS = "same_as hint getfield setfield direct_call".split()
 
 BINARY_OPERATIONS = "int_add int_sub int_mul int_gt int_eq".split()
 
@@ -38,12 +38,20 @@
         self.concretetype = T
         assert self.__class__ != SomeLLAbstractValue
 
+    def reorigin(self, bookkeeper):
+        return self
+
 class SomeLLAbstractConstant(SomeLLAbstractValue):
 
     def __init__(self, T, origins):
         SomeLLAbstractValue.__init__(self, T)
         self.origins = origins
 
+    def reorigin(self, bookkeeper):
+        origin = bookkeeper.myorigin()
+        origin.merge(self.origins)
+        return SomeLLAbstractConstant(self.concretetype, {origin: True})
+
 class SomeLLConcreteValue(SomeLLAbstractValue):
     pass
 
@@ -85,6 +93,15 @@
         else:
             return SomeLLAbstractVariable(FIELD_TYPE)
 
+    def direct_call(hs_f1, *args_hs):
+        bookkeeper = getbookkeeper()
+        graph = hs_f1.const._obj.graph
+        hs_res = bookkeeper.annotator.recursivecall(graph, bookkeeper.position_key, args_hs)
+        if isinstance(hs_res, SomeLLAbstractValue):
+            return hs_res.reorigin(bookkeeper)
+        else:
+            return hs_res # impossible value
+        
 class __extend__(SomeLLAbstractContainer):
 
     def setfield(hs_s1, hs_fieldname, hs_value):

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 19:49:08 2006
@@ -203,10 +203,21 @@
     assert len(hs.origins) == 1
     assert len(hs.origins.keys()[0].origins) == 2
 
+def test_simple_call():
+    def ll2(x, y):
+        return x + (y + 42)
+    def ll1(x, y, z):
+        return ll2(x, y - z)
+    hs = hannotate(ll1, [int, int, int])
+    assert isinstance(hs, SomeLLAbstractConstant)
+    assert hs.concretetype == lltype.Signed
+    assert len(hs.origins) == 1
 
 
+def CUR_GOAL_test_hannotate_tl():
+    from pypy.jit import tl
 
-    
+    hannotate(tl.interp, [str, int])
 
   
 



More information about the Pypy-commit mailing list