Author: Alex Gaynor <[email protected]>
Branch: unroll-virtual-dict-resize
Changeset: r66846:42b97400acf7
Date: 2013-09-07 11:16 -0700
http://bitbucket.org/pypy/pypy/changeset/42b97400acf7/
Log: Start hacking on this, doesn't work because heapcache doesn't handle
GETINTERIORFIELD/SETINTERIOFIELD
diff --git a/rpython/jit/codewriter/support.py
b/rpython/jit/codewriter/support.py
--- a/rpython/jit/codewriter/support.py
+++ b/rpython/jit/codewriter/support.py
@@ -522,8 +522,6 @@
return LLtypeHelpers._dictnext_items(lltype.Ptr(RES), iter)
_ll_1_dictiter_nextitems.need_result_type = True
- _ll_1_dict_resize = ll_rdict.ll_dict_resize
-
# ---------- strings and unicode ----------
_ll_1_str_str2unicode = ll_rstr.LLHelpers.ll_str2unicode
diff --git a/rpython/jit/metainterp/heapcache.py
b/rpython/jit/metainterp/heapcache.py
--- a/rpython/jit/metainterp/heapcache.py
+++ b/rpython/jit/metainterp/heapcache.py
@@ -27,6 +27,9 @@
# heap array cache
# maps descrs to {index: {from_box: to_box}} dicts
self.heap_array_cache = {}
+ # heap array of struct cache
+ # maps descrs to {index: {descr: {from_box: to_box}}}
+ self.heap_array_struct_cache = {}
# cache the length of arrays
self.length_cache = {}
diff --git a/rpython/jit/metainterp/test/test_dict.py
b/rpython/jit/metainterp/test/test_dict.py
--- a/rpython/jit/metainterp/test/test_dict.py
+++ b/rpython/jit/metainterp/test/test_dict.py
@@ -1,7 +1,6 @@
-import py
from rpython.jit.metainterp.test.support import LLJitMixin
+from rpython.rlib import objectmodel, jit
from rpython.rlib.jit import JitDriver
-from rpython.rlib import objectmodel
class DictTests:
@@ -177,6 +176,29 @@
self.check_simple_loop({'int_sub': 1, 'int_gt': 1, 'guard_true': 1,
'jump': 1})
+ def test_look_inside_resize(self):
+ driver = JitDriver(greens=[], reds=['n', 'j'])
+
+ def f(n, j):
+ while n > 0:
+ driver.jit_merge_point(n=n, j=j)
+ jit.promote(j)
+ d = {
+ j: j,
+ j + 1: j,
+ j + 2: j,
+ j + 3: j,
+ j + 4: j,
+ j + 5: j
+ }
+ n -= (len(d) - 5)
+ return n
+
+ res = self.meta_interp(f, [10, 2], listops=True)
+ assert res == f(10, 2)
+ self.check_simple_loop({'int_sub': 1, 'int_gt': 1, 'guard_true': 1,
+ 'jump': 1})
+
class TestLLtype(DictTests, LLJitMixin):
pass
diff --git a/rpython/rtyper/lltypesystem/rdict.py
b/rpython/rtyper/lltypesystem/rdict.py
--- a/rpython/rtyper/lltypesystem/rdict.py
+++ b/rpython/rtyper/lltypesystem/rdict.py
@@ -536,6 +536,7 @@
# call which is opaque to the JIT when the dict isn't virtual, to
# avoid extra branches.
[email protected]_inside_iff(lambda d: jit.isvirtual(d))
def ll_dict_resize(d):
old_entries = d.entries
old_size = len(old_entries)
@@ -560,7 +561,6 @@
ll_dict_insertclean(d, entry.key, entry.value, hash)
i += 1
old_entries.delete()
-ll_dict_resize.oopspec = 'dict.resize(d)'
# ------- a port of CPython's dictobject.c's lookdict implementation -------
PERTURB_SHIFT = 5
@@ -627,6 +627,7 @@
freeslot = intmask(i)
perturb >>= PERTURB_SHIFT
[email protected]_inside_iff(lambda d, hash: jit.isvirtual(d) and jit.isconstant(hash))
def ll_dict_lookup_clean(d, hash):
# a simplified version of ll_dict_lookup() which assumes that the
# key is new, and the dictionary doesn't contain deleted entries.
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit