Author: Alex Gaynor <[email protected]>
Branch: inline-dict-ops
Changeset: r48092:8c21856a5724
Date: 2011-10-16 13:39 -0400
http://bitbucket.org/pypy/pypy/changeset/8c21856a5724/

Log:    move stuff around a bit.

diff --git a/pypy/rpython/lltypesystem/rdict.py 
b/pypy/rpython/lltypesystem/rdict.py
--- a/pypy/rpython/lltypesystem/rdict.py
+++ b/pypy/rpython/lltypesystem/rdict.py
@@ -1,15 +1,14 @@
 from pypy.tool.pairtype import pairtype
 from pypy.objspace.flow.model import Constant
-from pypy.rpython.rdict import AbstractDictRepr, AbstractDictIteratorRepr,\
-     rtype_newdict
+from pypy.rpython.rdict import (AbstractDictRepr, AbstractDictIteratorRepr,
+     rtype_newdict)
 from pypy.rpython.lltypesystem import lltype
+from pypy.rlib import objectmodel, jit
 from pypy.rlib.rarithmetic import r_uint, intmask, LONG_BIT
-from pypy.rlib.objectmodel import hlinvoke
-from pypy.rlib import objectmodel
-from pypy.rlib import jit
 from pypy.rpython import rmodel
 from pypy.rpython.error import TyperError
 
+
 HIGHEST_BIT = intmask(1 << (LONG_BIT - 1))
 MASK = intmask(HIGHEST_BIT - 1)
 
@@ -421,11 +420,11 @@
 
 def ll_keyhash_custom(d, key):
     DICT = lltype.typeOf(d).TO
-    return hlinvoke(DICT.r_rdict_hashfn, d.fnkeyhash, key)
+    return objectmodel.hlinvoke(DICT.r_rdict_hashfn, d.fnkeyhash, key)
 
 def ll_keyeq_custom(d, key1, key2):
     DICT = lltype.typeOf(d).TO
-    return hlinvoke(DICT.r_rdict_eqfn, d.fnkeyeq, key1, key2)
+    return objectmodel.hlinvoke(DICT.r_rdict_eqfn, d.fnkeyeq, key1, key2)
 
 def ll_dict_len(d):
     return d.num_items
@@ -446,6 +445,9 @@
     i = ll_dict_lookup(d, key, hash)
     return _ll_dict_setitem_lookup_done(d, key, value, hash, i)
 
+# Leaving as dont_look_inside ATM, it has a few branches which could lead to
+# many bridges if we don't consider their possible frequency.
[email protected]_look_inside
 def _ll_dict_setitem_lookup_done(d, key, value, hash, i):
     valid = (i & HIGHEST_BIT) == 0
     i = i & MASK
@@ -489,6 +491,9 @@
         raise KeyError
     _ll_dict_del(d, i)
 
+# XXX: Move the size checking and resize into a single call which is opauqe to
+# the JIT to avoid extra branches.
[email protected]_look_inside
 def _ll_dict_del(d, i):
     d.entries.mark_deleted(i)
     d.num_items -= 1
@@ -556,18 +561,11 @@
         freeslot = i
     else:
         return i | HIGHEST_BIT # pristine entry -- lookup failed
-    return _ll_dict_lookup_slowpath(d, key, hash, freeslot)
 
-def _ll_dict_lookup_slowpath(d, key, hash, freeslot):
     # In the loop, a deleted entry (everused and not valid) is by far
     # (factor of 100s) the least likely outcome, so test for that last.
-    perturb = r_uint(hash) 
-    entries = d.entries
-    ENTRIES = lltype.typeOf(entries).TO
-    direct_compare = not hasattr(ENTRIES, 'no_direct_compare')
-    mask = len(entries) - 1
-    i = hash & mask
-    while 1: 
+    perturb = r_uint(hash)
+    while 1:
         # compute the next index using unsigned arithmetic
         i = r_uint(i)
         i = (i << 2) + i + perturb + 1
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to