[pypy-svn] r64529 - in pypy/branch/pyjitpl5-simplify/pypy: jit/backend jit/backend/llgraph jit/metainterp jit/metainterp/test rpython/ootypesystem

antocuni at codespeak.net antocuni at codespeak.net
Tue Apr 21 17:47:16 CEST 2009


Author: antocuni
Date: Tue Apr 21 17:47:15 2009
New Revision: 64529

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/codewriter.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/support.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py
   pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/ootype.py
Log:
(arigo, antocuni) remove the ad-hoc oo{string,unicode}* ops and replace them
by calls to helper functions.



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 21 17:47:15 2009
@@ -8,6 +8,7 @@
 from pypy.rpython.ootypesystem import ootype
 from pypy.rpython.llinterp import LLInterpreter
 from pypy.jit.metainterp import history
+from pypy.jit.metainterp.warmspot import unwrap
 from pypy.jit.metainterp.resoperation import ResOperation, rop
 from pypy.jit.backend import model
 from pypy.jit.backend.llgraph import llimpl, symbolic
@@ -455,19 +456,7 @@
         x = descr.callmeth(selfbox, argboxes)
         # XXX: return None if METH.RESULT is Void
         return x
-
-    def do_oostring_char(self, args, descr=None):
-        char = chr(args[0].getint())
-        base = args[1].getint()
-        res = ootype.cast_to_object(ootype.oostring(char, base))
-        return history.ConstObj(res)
-
-    def do_oounicode_unichar(self, args, descr=None):
-        unichar = unichr(args[0].getint())
-        base = args[1].getint()
-        res = ootype.cast_to_object(ootype.oounicode(unichar, base))
-        return history.ConstObj(res)
-
+    
 
 def make_getargs(ARGS):
     argsiter = unrolling_iterable(ARGS)
@@ -479,17 +468,10 @@
         for ARG in argsiter:
             box = argboxes[i]
             i+=1
-            funcargs += (unbox(ARG, box),)
+            funcargs += (unwrap(ARG, box),)
         return funcargs
     return getargs
 
-def unbox(T, box):
-    if isinstance(T, ootype.OOType):
-        return ootype.cast_from_object(T, box.getobj())
-    else:
-        return box.getint()
-unbox._annspecialcase_ = 'specialize:arg(0)'
-
 def boxresult(RESULT, result):
     if isinstance(RESULT, ootype.OOType):
         return history.BoxObj(ootype.cast_to_object(result))
@@ -557,7 +539,7 @@
             return boxresult(T, value)
         def setfield(objbox, valuebox):
             obj = ootype.cast_from_object(TYPE, objbox.getobj())
-            value = unbox(T, valuebox)
+            value = unwrap(T, valuebox)
             setattr(obj, fieldname, value)
             
         self.getfield = getfield

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 21 17:47:15 2009
@@ -133,9 +133,3 @@
 
     def do_oosend(cpu, args, descr=None):
         raise NotImplementedError
-
-    def do_oostring_char(cpu, args, descr=None):
-        raise NotImplementedError
-
-    def do_oounicode_unichar(cpu, args, descr=None):
-        raise NotImplementedError

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	Tue Apr 21 17:47:15 2009
@@ -1050,10 +1050,8 @@
             self.emit(self.get_position(virtualizabledesc))
             self.emit(self.get_position(guard_field))
 
-    def serialize_op_oostring(self, op):
-        T = op.args[0].concretetype
-        opname = '%s_%s' % (op.opname, T._name.lower())
-        return self.default_serialize_op(op, opname)
+    def serialize_op_oostring(self, op):  
+        self.handle_builtin_call(op)
 
     serialize_op_oounicode = serialize_op_oostring
 

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py	Tue Apr 21 17:47:15 2009
@@ -159,8 +159,6 @@
     UNICODEGETITEM         = 84
     #
     # ootype operations
-    OOSTRING_CHAR          = 85
-    OOUNICODE_UNICHAR      = 86
     OOSEND_PURE            = 87
     #
     _ALWAYS_PURE_LAST = 87  # ----- end of always_pure operations -----

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	Tue Apr 21 17:47:15 2009
@@ -159,6 +159,22 @@
 _ll_1_str_str2unicode = rstr.LLHelpers.ll_str2unicode
 _ll_5_unicode_copy_contents = rstr.copy_unicode_contents
 
+# --------------- oostring and oounicode ----------------
+
+def _ll_2_oostring_signed_foldable(n, base):
+    return ootype.oostring(n, base)
+
+def _ll_1_oostring_char_foldable(ch):
+    return ootype.oostring(ch, -1)
+
+def _ll_2_oounicode_signed_foldable(n, base):
+    return ootype.oounicode(n, base)
+
+def _ll_1_oounicode_unichar_foldable(ch):
+    return ootype.oounicode(ch, -1)
+
+# -------------------------------------------------------
+
 def setup_extra_builtin(oopspec_name, nb_args):
     name = '_ll_%d_%s' % (nb_args, oopspec_name.replace('.', '_'))
 ##    try:
@@ -210,10 +226,20 @@
     normalized_opargs = normalize_opargs(argtuple, opargs)
     return oopspec, normalized_opargs
 
+def get_oostring_oopspec(op):
+    T = op.args[0].concretetype
+    if T is not ootype.Signed:
+        args = op.args[:-1]
+    else:
+        args = op.args
+    return '%s_%s_foldable' % (op.opname, T._name.lower()), args
+    
 def decode_builtin_call(op):
     if op.opname == 'oosend':
         SELFTYPE, name, opargs = decompose_oosend(op)
         return get_send_oopspec(SELFTYPE, name), opargs
+    elif op.opname in ('oostring', 'oounicode'):
+        return get_oostring_oopspec(op)
     elif op.opname == 'direct_call':
         fnobj = get_funcobj(op.args[0].value)
         opargs = op.args[1:]

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py	Tue Apr 21 17:47:15 2009
@@ -518,7 +518,6 @@
     def skip(self):
         py.test.skip('in-progress')
 
-    test_format = skip
     test_oops_on_nongc = skip
 
     test_print = skip

Modified: pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/ootype.py	Tue Apr 21 17:47:15 2009
@@ -472,6 +472,8 @@
 
 # WARNING: the name 'StringBuilder' is rebound at the end of file
 class StringBuilder(BuiltinADTType):
+    oopspec_name = 'stringbuilder'
+
     def __init__(self, STRINGTP, CHARTP):
         self._null = _null_string_builder(self)
         self._GENERIC_METHODS = frozendict({



More information about the Pypy-commit mailing list