[pypy-svn] r64631 - in pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp: . test

antocuni at codespeak.net antocuni at codespeak.net
Fri Apr 24 12:10:28 CEST 2009


Author: antocuni
Date: Fri Apr 24 12:10:28 2009
New Revision: 64631

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/support.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_vlist.py
Log:
recounstruct oopspec from the ootype.{Array,List} method names.  This is a bit
weird, as those oopspec are then deconstrcted again to have the same original
meaning, but at the moment it is the simpliest way to treat uniformly ootype
and lltype.  test_vlist.test_simple_array passes



Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py	Fri Apr 24 12:10:28 2009
@@ -1013,7 +1013,11 @@
         return True
 
     def prepare_list_getset(self, op, arraydescr, args):
-        func = get_funcobj(op.args[0].value)._callable      # xxx break of abstraction
+        if op.opname == 'oosend':
+            SELFTYPE, _, meth = support.lookup_oosend_method(op)
+            func = meth._callable
+        else:
+            func = get_funcobj(op.args[0].value)._callable      # xxx break of abstraction
         # XXX what if the type is called _nonneg or _fast???
         non_negative = '_nonneg' in func.__name__
         fast = '_fast' in func.__name__
@@ -1040,9 +1044,14 @@
         return v_posindex
 
     def handle_builtin_oosend(self, op):
-        SELFTYPE, methname, args_v = support.decompose_oosend(op)
+        oopspec_name, args = support.decode_builtin_call(op)
+        SELFTYPE, methname, meth = support.lookup_oosend_method(op)
         assert SELFTYPE.oopspec_name is not None
-        _, meth = SELFTYPE._lookup(methname)
+        # try to special-case list operations
+        if self.codewriter.metainterp_sd.options.listops:
+            if self.handle_list_call(op, oopspec_name, args, SELFTYPE):
+                return
+        # fallback to all the other builtin oosends
         if getattr(meth, '_pure_meth', False):
             kind = '_pure'
         elif getattr(meth, '_can_raise', True):

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/support.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/support.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/support.py	Fri Apr 24 12:10:28 2009
@@ -234,7 +234,25 @@
     else:
         args = op.args
     return '%s_%s_foldable' % (op.opname, T._name.lower()), args
-    
+
+
+RENAMED_ADT_NAME = {
+    'list': {
+        'll_getitem_fast': 'getitem',
+        'll_setitem_fast': 'setitem',
+        'll_length':       'len',
+        },
+    }
+
+def get_send_oopspec(SELFTYPE, name):
+    oopspec_name = SELFTYPE.oopspec_name
+    assert oopspec_name is not None
+    renamed = RENAMED_ADT_NAME.get(oopspec_name, {})
+    pubname = renamed.get(name, name)
+    oopspec = '%s.%s' % (oopspec_name, pubname)
+    return oopspec
+
+
 def decode_builtin_call(op):
     if op.opname == 'oosend':
         SELFTYPE, name, opargs = decompose_oosend(op)
@@ -281,3 +299,8 @@
     opargs = op.args[1:]
     SELFTYPE = opargs[0].concretetype
     return SELFTYPE, name, opargs
+
+def lookup_oosend_method(op):
+    SELFTYPE, methname, args_v = decompose_oosend(op)
+    _, meth = SELFTYPE._lookup(methname)
+    return SELFTYPE, methname, meth

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_vlist.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_vlist.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_vlist.py	Fri Apr 24 12:10:28 2009
@@ -356,8 +356,14 @@
         self.check_all_virtualized()
 
 
-## class TestOOtype(ListTests, OOJitMixin):
-##     pass
+class TestOOtype(ListTests, OOJitMixin):
+    def skip(self):
+        py.test.skip('in-progress')
+    
+    test_list_pass_around = skip
+    test_cannot_be_virtual = skip
+    test_ll_fixed_setitem_fast = skip
+
 
 class TestLLtype(ListTests, LLJitMixin):
     pass



More information about the Pypy-commit mailing list