[pypy-commit] pypy unroll-if-alt: merged default in
alex_gaynor
noreply at buildbot.pypy.org
Tue Sep 20 02:41:00 CEST 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: unroll-if-alt
Changeset: r47358:e0d1e2877d27
Date: 2011-09-19 15:14 -0400
http://bitbucket.org/pypy/pypy/changeset/e0d1e2877d27/
Log: merged default in
diff --git a/pypy/jit/metainterp/heapcache.py b/pypy/jit/metainterp/heapcache.py
--- a/pypy/jit/metainterp/heapcache.py
+++ b/pypy/jit/metainterp/heapcache.py
@@ -30,11 +30,13 @@
self.clear_caches(opnum, descr, argboxes)
def mark_escaped(self, opnum, argboxes):
- for idx, box in enumerate(argboxes):
+ idx = 0
+ for box in argboxes:
# setfield_gc and setarrayitem_gc don't escape their first argument
if not (idx == 0 and opnum in [rop.SETFIELD_GC, rop.SETARRAYITEM_GC]):
if box in self.new_boxes:
self.new_boxes[box] = False
+ idx += 1
def clear_caches(self, opnum, descr, argboxes):
if opnum == rop.SETFIELD_GC:
diff --git a/pypy/rlib/_rweakkeydict.py b/pypy/rlib/_rweakkeydict.py
--- a/pypy/rlib/_rweakkeydict.py
+++ b/pypy/rlib/_rweakkeydict.py
@@ -117,7 +117,7 @@
d = lltype.malloc(WEAKDICT)
d.entries = WEAKDICT.entries.TO.allocate(rdict.DICT_INITSIZE)
d.num_items = 0
- d.num_pristine_entries = rdict.DICT_INITSIZE
+ d.resize_counter = rdict.DICT_INITSIZE * 2
return d
@jit.dont_look_inside
@@ -152,8 +152,8 @@
# ll_debugrepr(llkey),
# ll_debugrepr(llvalue))
if not everused:
- d.num_pristine_entries -= 1
- if d.num_pristine_entries * 3 <= len(d.entries):
+ d.resize_counter -= 3
+ if d.resize_counter <= 0:
#llop.debug_print(lltype.Void, 'RESIZE')
ll_weakdict_resize(d)
@@ -206,6 +206,6 @@
WEAKDICT = lltype.GcStruct("weakkeydict",
("num_items", lltype.Signed),
- ("num_pristine_entries", lltype.Signed),
+ ("resize_counter", lltype.Signed),
("entries", lltype.Ptr(WEAKDICTENTRYARRAY)),
adtmeths=dictmeths)
diff --git a/pypy/rlib/_rweakvaldict.py b/pypy/rlib/_rweakvaldict.py
--- a/pypy/rlib/_rweakvaldict.py
+++ b/pypy/rlib/_rweakvaldict.py
@@ -53,7 +53,7 @@
self.WEAKDICT = lltype.GcStruct(
"weakvaldict",
("num_items", lltype.Signed),
- ("num_pristine_entries", lltype.Signed),
+ ("resize_counter", lltype.Signed),
("entries", lltype.Ptr(WEAKDICTENTRYARRAY)),
adtmeths=dictmeths)
@@ -107,7 +107,7 @@
d = lltype.malloc(self.WEAKDICT)
d.entries = self.WEAKDICT.entries.TO.allocate(rdict.DICT_INITSIZE)
d.num_items = 0
- d.num_pristine_entries = rdict.DICT_INITSIZE
+ d.resize_counter = rdict.DICT_INITSIZE * 2
return d
@jit.dont_look_inside
@@ -138,8 +138,8 @@
d.entries[i].value = valueref
#llop.debug_print(lltype.Void, i, 'stored')
if not everused:
- d.num_pristine_entries -= 1
- if d.num_pristine_entries * 3 <= len(d.entries):
+ d.resize_counter -= 3
+ if d.resize_counter <= 0:
#llop.debug_print(lltype.Void, 'RESIZE')
self.ll_weakdict_resize(d)
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
@@ -20,7 +20,7 @@
# DICTVALUE types.
#
# XXX for immutable dicts, the array should be inlined and
-# num_pristine_entries and everused are not needed.
+# resize_counter and everused are not needed.
#
# struct dictentry {
# DICTKEY key;
@@ -32,7 +32,7 @@
#
# struct dicttable {
# int num_items;
-# int num_pristine_entries; # never used entries
+# int resize_counter;
# Array *entries;
# (Function DICTKEY, DICTKEY -> bool) *fnkeyeq;
# (Function DICTKEY -> int) *fnkeyhash;
@@ -176,7 +176,7 @@
self.DICTENTRYARRAY = lltype.GcArray(self.DICTENTRY,
adtmeths=entrymeths)
fields = [ ("num_items", lltype.Signed),
- ("num_pristine_entries", lltype.Signed),
+ ("resize_counter", lltype.Signed),
("entries", lltype.Ptr(self.DICTENTRYARRAY)) ]
if self.custom_eq_hash:
self.r_rdict_eqfn, self.r_rdict_hashfn = self._custom_eq_hash_repr()
@@ -465,8 +465,8 @@
d.num_items += 1
if not everused:
if hasattr(ENTRY, 'f_everused'): entry.f_everused = True
- d.num_pristine_entries -= 1
- if d.num_pristine_entries <= len(d.entries) / 3:
+ d.resize_counter -= 3
+ if d.resize_counter <= 0:
ll_dict_resize(d)
def ll_dict_insertclean(d, key, value, hash):
@@ -484,7 +484,7 @@
if hasattr(ENTRY, 'f_valid'): entry.f_valid = True
if hasattr(ENTRY, 'f_everused'): entry.f_everused = True
d.num_items += 1
- d.num_pristine_entries -= 1
+ d.resize_counter -= 3
def ll_dict_delitem(d, key):
i = ll_dict_lookup(d, key, d.keyhash(key))
@@ -518,7 +518,7 @@
new_size /= 2
d.entries = lltype.typeOf(old_entries).TO.allocate(new_size)
d.num_items = 0
- d.num_pristine_entries = new_size
+ d.resize_counter = new_size * 2
i = 0
while i < old_size:
if old_entries.valid(i):
@@ -619,7 +619,7 @@
d = DICT.allocate()
d.entries = DICT.entries.TO.allocate(DICT_INITSIZE)
d.num_items = 0
- d.num_pristine_entries = DICT_INITSIZE
+ d.resize_counter = DICT_INITSIZE * 2
return d
ll_newdict.oopspec = 'newdict()'
@@ -631,7 +631,7 @@
d = DICT.allocate()
d.entries = DICT.entries.TO.allocate(n)
d.num_items = 0
- d.num_pristine_entries = n
+ d.resize_counter = n * 2
return d
ll_newdict_size.oopspec = 'newdict()'
@@ -749,7 +749,7 @@
d = DICT.allocate()
d.entries = DICT.entries.TO.allocate(dictsize)
d.num_items = dict.num_items
- d.num_pristine_entries = dict.num_pristine_entries
+ d.resize_counter = dict.resize_counter
if hasattr(DICT, 'fnkeyeq'): d.fnkeyeq = dict.fnkeyeq
if hasattr(DICT, 'fnkeyhash'): d.fnkeyhash = dict.fnkeyhash
i = 0
@@ -767,12 +767,13 @@
ll_copy.oopspec = 'dict.copy(dict)'
def ll_clear(d):
- if len(d.entries) == d.num_pristine_entries == DICT_INITSIZE:
+ if (len(d.entries) == DICT_INITSIZE and
+ d.resize_counter == DICT_INITSIZE * 2):
return
old_entries = d.entries
d.entries = lltype.typeOf(old_entries).TO.allocate(DICT_INITSIZE)
d.num_items = 0
- d.num_pristine_entries = DICT_INITSIZE
+ d.resize_counter = DICT_INITSIZE * 2
old_entries.delete()
ll_clear.oopspec = 'dict.clear(d)'
diff --git a/pypy/rpython/memory/lldict.py b/pypy/rpython/memory/lldict.py
--- a/pypy/rpython/memory/lldict.py
+++ b/pypy/rpython/memory/lldict.py
@@ -83,7 +83,7 @@
})
DICT = lltype.Struct('DICT', ('entries', lltype.Ptr(ENTRIES)),
('num_items', lltype.Signed),
- ('num_pristine_entries', lltype.Signed),
+ ('resize_counter', lltype.Signed),
adtmeths = {
'allocate': dict_allocate,
'delete': dict_delete,
More information about the pypy-commit
mailing list