[pypy-svn] r64059 - in pypy/branch/pyjitpl5-simplify/pypy/jit: backend backend/llgraph metainterp

antocuni at codespeak.net antocuni at codespeak.net
Tue Apr 14 14:15:03 CEST 2009


Author: antocuni
Date: Tue Apr 14 14:15:02 2009
New Revision: 64059

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/model.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/executor.py
Log:
move ootype operations in the backend


Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py	Tue Apr 14 14:15:02 2009
@@ -386,7 +386,39 @@
                                                         self.memo_cast))
 
 class OOtypeCPU(BaseCPU):
-    pass
+
+    def do_str_stritem_nonneg(cpu, args, descr=None):
+        assert cpu.has_ootype
+        obj = args[0].getobj()
+        str = ootype.cast_from_object(ootype.String, obj)
+        index = args[1].getint()
+        res = str.ll_stritem_nonneg(index)
+        return history.ConstInt(ord(res))
+
+    def do_str_strconcat(cpu, args, descr=None):
+        assert cpu.has_ootype
+        obj1 = args[0].getobj()
+        obj2 = args[1].getobj()
+        str1 = ootype.cast_from_object(ootype.String, obj1)
+        str2 = ootype.cast_from_object(ootype.String, obj2)
+        res = str1.ll_strconcat(str2)
+        objres = ootype.cast_to_object(res)
+        return history.ConstObj(objres)
+
+    def do_str_strlen(cpu, args, descr=None):
+        assert cpu.has_ootype
+        obj = args[0].getobj()
+        str = ootype.cast_from_object(ootype.String, obj)
+        res = str.ll_strlen()
+        return history.ConstInt(res)
+
+    def do_oostring(cpu, args, descr=None):
+        assert cpu.has_ootype
+        obj = args[0].getint() # XXX what about other types?
+        base = args[1].getint()
+        res = ootype.cast_to_object(ootype.oostring(obj, base))
+        return history.ConstObj(res) # XXX ???
+
 
 # ____________________________________________________________
 

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/model.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/model.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/model.py	Tue Apr 14 14:15:02 2009
@@ -115,3 +115,18 @@
 
     def do_cast_ptr_to_int(self, args, descr=None):
         raise NotImplementedError
+
+    # ootype specific operations
+    # --------------------------
+
+    def do_str_stritem_nonneg(cpu, args, descr=None):
+        raise NotImplementedError
+    
+    def do_str_strconcat(cpu, args, descr=None):
+        raise NotImplementedError
+
+    def do_str_strlen(cpu, args, descr=None):
+        raise NotImplementedError
+
+    def do_oostring(cpu, args, descr=None):
+        raise NotImplementedError

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/executor.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/executor.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/executor.py	Tue Apr 14 14:15:02 2009
@@ -7,7 +7,6 @@
 from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.rlib.rarithmetic import ovfcheck, r_uint, intmask
 from pypy.jit.metainterp.history import BoxInt, ConstInt, check_descr, INT, PTR
-from pypy.jit.metainterp.history import ConstObj
 from pypy.jit.metainterp.resoperation import rop
 
 
@@ -251,43 +250,11 @@
         z = llop.int_floordiv(lltype.Signed, x, y)
     return BoxInt(z)
 
-# XXX: these ops should probably be delegated to the backend
-def do_str_stritem_nonneg(cpu, args, descr=None):
-    assert cpu.has_ootype
-    obj = args[0].getobj()
-    str = ootype.cast_from_object(ootype.String, obj)
-    index = args[1].getint()
-    res = str.ll_stritem_nonneg(index)
-    return ConstInt(ord(res))
-
-def do_str_strconcat(cpu, args, descr=None):
-    assert cpu.has_ootype
-    obj1 = args[0].getobj()
-    obj2 = args[1].getobj()
-    str1 = ootype.cast_from_object(ootype.String, obj1)
-    str2 = ootype.cast_from_object(ootype.String, obj2)
-    res = str1.ll_strconcat(str2)
-    objres = ootype.cast_to_object(res)
-    return ConstObj(objres)
-
-def do_str_strlen(cpu, args, descr=None):
-    assert cpu.has_ootype
-    obj = args[0].getobj()
-    str = ootype.cast_from_object(ootype.String, obj)
-    res = str.ll_strlen()
-    return ConstInt(res)
-
-def do_oostring(cpu, args, descr=None):
-    assert cpu.has_ootype
-    obj = args[0].getint() # XXX what about other types?
-    base = args[1].getint()
-    res = ootype.cast_to_object(ootype.oostring(obj, base))
-    return ConstObj(res) # XXX ???
-
 # ____________________________________________________________
 
 
 def make_execute_list(cpuclass):
+    from pypy.jit.backend.model import AbstractCPU
     execute = [None] * (rop._LAST+1)
     for key, value in rop.__dict__.items():
         if not key.startswith('_'):
@@ -299,10 +266,12 @@
             if key.endswith('_PURE'):
                 key = key[:-5]
             name = 'do_' + key.lower()
-            try:
+            if hasattr(cpuclass, name):
                 execute[value] = getattr(cpuclass, name)
-            except AttributeError:
+            elif name in globals():
                 execute[value] = globals()[name]
+            else:
+                assert hasattr(AbstractCPU, name)
     cpuclass._execute_list = execute
 
 def get_execute_function(cpu, opnum):



More information about the Pypy-commit mailing list