[pypy-commit] pypy default: Fixes, trying to use siphash24 on pypy

arigo pypy.commits at gmail.com
Wed Jan 25 15:37:21 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r89772:db5482cc94a2
Date: 2017-01-25 20:36 +0000
http://bitbucket.org/pypy/pypy/changeset/db5482cc94a2/

Log:	Fixes, trying to use siphash24 on pypy

diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -614,6 +614,9 @@
     This version is called from lltypesystem/rstr.py, and 'll_s' is a
     rstr.STR or rstr.UNICODE.
     """
+    if not we_are_translated():
+        global HASH_ALGORITHM_FIXED
+        HASH_ALGORITHM_FIXED = True
     if HASH_ALGORITHM == "rpython":
         return _hash_string_rpython(ll_s.chars)
     if HASH_ALGORITHM == "siphash24":
diff --git a/rpython/rtyper/lltypesystem/rstr.py b/rpython/rtyper/lltypesystem/rstr.py
--- a/rpython/rtyper/lltypesystem/rstr.py
+++ b/rpython/rtyper/lltypesystem/rstr.py
@@ -44,11 +44,13 @@
 mallocstr = new_malloc(STR, 'mallocstr')
 mallocunicode = new_malloc(UNICODE, 'mallocunicode')
 
+ at specialize.memo()
 def emptystrfun():
-    return emptystr
+    return string_repr.convert_const("")
 
+ at specialize.memo()
 def emptyunicodefun():
-    return emptyunicode
+    return unicode_repr.convert_const(u'')
 
 def _new_copy_contents_fun(SRC_TP, DST_TP, CHAR_TP, name):
     @specialize.arg(0)
@@ -1280,8 +1282,6 @@
 char_repr.ll = LLHelpers
 unichar_repr.ll = LLHelpers
 unicode_repr = UnicodeRepr()
-emptystr = string_repr.convert_const("")
-emptyunicode = unicode_repr.convert_const(u'')
 
 StringRepr.repr = string_repr
 UnicodeRepr.repr = unicode_repr
@@ -1340,14 +1340,6 @@
 string_repr.iterator_repr = StringIteratorRepr()
 unicode_repr.iterator_repr = UnicodeIteratorRepr()
 
-# these should be in rclass, but circular imports prevent (also it's
-# not that insane that a string constant is built in this file).
-
-instance_str_prefix = string_repr.convert_const("<")
-instance_str_infix  = string_repr.convert_const(" object at 0x")
-instance_str_suffix = string_repr.convert_const(">")
-
-null_str = string_repr.convert_const("NULL")
-
-unboxed_instance_str_prefix = string_repr.convert_const("<unboxed ")
-unboxed_instance_str_suffix = string_repr.convert_const(">")
+ at specialize.memo()
+def conststr(s):
+    return string_repr.convert_const(s)
diff --git a/rpython/rtyper/lltypesystem/rtagged.py b/rpython/rtyper/lltypesystem/rtagged.py
--- a/rpython/rtyper/lltypesystem/rtagged.py
+++ b/rpython/rtyper/lltypesystem/rtagged.py
@@ -117,9 +117,9 @@
             from rpython.rtyper.lltypesystem import rstr
             from rpython.rtyper.rint import signed_repr
             llstr1 = signed_repr.ll_str(ll_unboxed_to_int(i))
-            return rstr.ll_strconcat(rstr.unboxed_instance_str_prefix,
+            return rstr.ll_strconcat(rstr.conststr("<unboxed "),
                       rstr.ll_strconcat(llstr1,
-                                        rstr.unboxed_instance_str_suffix))
+                                        rstr.conststr(">")))
         else:
             return InstanceRepr.ll_str(self, i)
 
diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -840,18 +840,18 @@
         from rpython.rtyper.lltypesystem.ll_str import ll_int2hex
         from rpython.rlib.rarithmetic import r_uint
         if not i:
-            return rstr.null_str
+            return rstr.conststr("NULL")
         instance = cast_pointer(OBJECTPTR, i)
         # Two choices: the first gives a fast answer but it can change
         # (typically only once) during the life of the object.
         #uid = r_uint(cast_ptr_to_int(i))
         uid = r_uint(llop.gc_id(lltype.Signed, i))
         #
-        res = rstr.instance_str_prefix
+        res = rstr.conststr("<")
         res = rstr.ll_strconcat(res, instance.typeptr.name)
-        res = rstr.ll_strconcat(res, rstr.instance_str_infix)
+        res = rstr.ll_strconcat(res, rstr.conststr(" object at 0x"))
         res = rstr.ll_strconcat(res, ll_int2hex(uid, False))
-        res = rstr.ll_strconcat(res, rstr.instance_str_suffix)
+        res = rstr.ll_strconcat(res, rstr.conststr(">"))
         return res
 
     def get_ll_eq_function(self):
@@ -1092,7 +1092,6 @@
     except StandardError:
         return None
 
-
 # ____________________________________________________________
 #
 #  Low-level implementation of operations on classes and instances


More information about the pypy-commit mailing list