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

arigo at codespeak.net arigo at codespeak.net
Sun May 3 17:39:55 CEST 2009


Author: arigo
Date: Sun May  3 17:39:54 2009
New Revision: 65004

Modified:
   pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_loop.py
Log:
Implement oohash, as a call to a small helper function
(good enough for now).


Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py	Sun May  3 17:39:54 2009
@@ -1142,10 +1142,9 @@
             self.emit(self.get_position(virtualizabledesc))
             self.emit(self.get_position(guard_field))
 
-    def serialize_op_oostring(self, op):  
-        self.handle_builtin_call(op)
-
-    serialize_op_oounicode = serialize_op_oostring
+    serialize_op_oostring  = handle_builtin_call
+    serialize_op_oounicode = handle_builtin_call
+    serialize_op_oohash    = handle_builtin_call
 
     # ----------
 

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py	Sun May  3 17:39:54 2009
@@ -194,6 +194,12 @@
 def _ll_1_oounicode_unichar_foldable(ch):
     return ootype.oounicode(ch, -1)
 
+def _ll_1_oohash_string_foldable(s):
+    return ootype.oohash(s)
+
+def _ll_1_oohash_unicode_foldable(u):
+    return ootype.oohash(u)
+
 # -------------------------------------------------------
 
 def setup_extra_builtin(oopspec_name, nb_args):
@@ -255,6 +261,15 @@
         args = op.args
     return '%s_%s_foldable' % (op.opname, T._name.lower()), args
 
+def get_oohash_oopspec(op):
+    T = op.args[0].concretetype
+    if T is ootype.String:
+        return 'oohash_string_foldable', op.args
+    elif T is ootype.Unicode:
+        return 'oohash_unicode_foldable', op.args
+    else:
+        raise Exception("oohash() of type %r" % (T,))
+
 
 RENAMED_ADT_NAME = {
     'list': {
@@ -279,6 +294,8 @@
         return get_send_oopspec(SELFTYPE, name), opargs
     elif op.opname in ('oostring', 'oounicode'):
         return get_oostring_oopspec(op)
+    elif op.opname == 'oohash':
+        return get_oohash_oopspec(op)
     elif op.opname == 'direct_call':
         fnobj = get_funcobj(op.args[0].value)
         opargs = op.args[1:]

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py	Sun May  3 17:39:54 2009
@@ -559,7 +559,15 @@
 
 
 class TestOOtype(BasicTests, OOJitMixin):
-    pass
+
+    def test_oohash(self):
+        def f():
+            s = ootype.oostring(5, -1)
+            return ootype.oohash(s)
+        res = self.interp_operations(f, [])
+        # xxx can we rely on oohash() returning the same value in and out of
+        # translation?
+        assert res == ootype.oohash(ootype.oostring(5, -1))
 
 
 class TestLLtype(BasicTests, LLJitMixin):

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_loop.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_loop.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_loop.py	Sun May  3 17:39:54 2009
@@ -575,8 +575,7 @@
         res = self.meta_interp(f, [200])
 
 class TestOOtype(LoopTest, OOJitMixin):
-    def test_loop_unicode(self):
-        py.test.skip("oohash")
+    pass
 
 class TestLLtype(LoopTest, LLJitMixin):
     pass



More information about the Pypy-commit mailing list