[pypy-svn] r79074 - in pypy/trunk/pypy/jit/metainterp: . test

fijal at codespeak.net fijal at codespeak.net
Sun Nov 14 11:58:54 CET 2010


Author: fijal
Date: Sun Nov 14 11:58:53 2010
New Revision: 79074

Modified:
   pypy/trunk/pypy/jit/metainterp/resoperation.py
   pypy/trunk/pypy/jit/metainterp/test/test_resoperation.py
Log:
can_malloc hook. Also have is_call which is right now the same as can_raise,
but let's be on the safe side


Modified: pypy/trunk/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/resoperation.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/resoperation.py	Sun Nov 14 11:58:53 2010
@@ -143,6 +143,13 @@
     def can_raise(self):
         return rop._CANRAISE_FIRST <= self.getopnum() <= rop._CANRAISE_LAST
 
+    def can_malloc(self):
+        return (self.is_call() or
+                rop._MALLOC_FIRST <= self.getopnum() <= rop._MALLOC_LAST)
+
+    def is_call(self):
+        return rop._CALL_FIRST <= self.getopnum() <= rop._CALL_LAST
+
     def is_ovf(self):
         return rop._OVF_FIRST <= self.getopnum() <= rop._OVF_LAST
 
@@ -441,11 +448,13 @@
     'GETARRAYITEM_RAW/2d',
     'GETFIELD_GC/1d',
     'GETFIELD_RAW/1d',
+    '_MALLOC_FIRST',
     'NEW/0d',
     'NEW_WITH_VTABLE/1',
     'NEW_ARRAY/1d',
     'NEWSTR/1',
     'NEWUNICODE/1',
+    '_MALLOC_LAST',
     'FORCE_TOKEN/0',
     'VIRTUAL_REF/2',         # removed before it's passed to the backend
     '_NOSIDEEFFECT_LAST', # ----- end of no_side_effect operations -----
@@ -465,6 +474,7 @@
     'COPYUNICODECONTENT/5',
 
     '_CANRAISE_FIRST', # ----- start of can_raise operations -----
+    '_CALL_FIRST',
     'CALL/*d',
     'CALL_ASSEMBLER/*d',  # call already compiled assembler
     'CALL_MAY_FORCE/*d',
@@ -473,6 +483,7 @@
     #'OOSEND_PURE',                # ootype operation
     'CALL_PURE/*d',             # removed before it's passed to the backend
                              # CALL_PURE(result, func, arg_1,..,arg_n)
+    '_CALL_LAST',
     '_CANRAISE_LAST', # ----- end of can_raise operations -----
 
     '_OVF_FIRST', # ----- start of is_ovf operations -----

Modified: pypy/trunk/pypy/jit/metainterp/test/test_resoperation.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_resoperation.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_resoperation.py	Sun Nov 14 11:58:53 2010
@@ -61,3 +61,10 @@
     assert op.getarglist() == ['a', 'b']
     assert op.result == 'c'
     assert op.getdescr() is mydescr
+
+def test_can_malloc():
+    mydescr = AbstractDescr()
+    assert rop.ResOperation(rop.rop.NEW, [], 'b').can_malloc()
+    call = rop.ResOperation(rop.rop.CALL, ['a', 'b'], 'c', descr=mydescr)
+    assert call.can_malloc()
+    assert not rop.ResOperation(rop.rop.INT_ADD, ['a', 'b'], 'c').can_malloc()



More information about the Pypy-commit mailing list