[pypy-commit] pypy default: Temporarily backout 90a0d3659179 and f3070ec0eeb3, which cause failures
arigo
pypy.commits at gmail.com
Wed Sep 13 19:46:17 EDT 2017
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r92381:626793f5423f
Date: 2017-09-14 01:45 +0200
http://bitbucket.org/pypy/pypy/changeset/626793f5423f/
Log: Temporarily backout 90a0d3659179 and f3070ec0eeb3, which cause
failures
diff --git a/rpython/memory/gc/base.py b/rpython/memory/gc/base.py
--- a/rpython/memory/gc/base.py
+++ b/rpython/memory/gc/base.py
@@ -22,7 +22,6 @@
can_usually_pin_objects = False
object_minimal_size = 0
gcflag_extra = 0 # or a real GC flag that is always 0 when not collecting
- _totalroots_rpy = 0 # for inspector.py
def __init__(self, config, chunk_size=DEFAULT_CHUNK_SIZE,
translated_to_c=True):
@@ -336,7 +335,6 @@
callback2, attrname = _convert_callback_formats(callback) # :-/
setattr(self, attrname, arg)
self.root_walker.walk_roots(callback2, callback2, callback2)
- self.enum_live_with_finalizers(callback, arg)
self.enum_pending_finalizers(callback, arg)
enumerate_all_roots._annspecialcase_ = 'specialize:arg(1)'
@@ -349,12 +347,6 @@
i += 1
enum_pending_finalizers._annspecialcase_ = 'specialize:arg(1)'
- def enum_live_with_finalizers(self, callback, arg):
- # as far as possible, enumerates the live objects with finalizers,
- # even if they have not been detected as unreachable yet (but may be)
- pass
- enum_live_with_finalizers._annspecialcase_ = 'specialize:arg(1)'
-
def _copy_pending_finalizers_deque(self, deque, copy_fn):
tmp = self.AddressDeque()
while deque.non_empty():
diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -2515,11 +2515,6 @@
MovingGCBase.enumerate_all_roots(self, callback, arg)
enumerate_all_roots._annspecialcase_ = 'specialize:arg(1)'
- def enum_live_with_finalizers(self, callback, arg):
- self.probably_young_objects_with_finalizers.foreach(callback, arg, 2)
- self.old_objects_with_finalizers.foreach(callback, arg, 2)
- enum_live_with_finalizers._annspecialcase_ = 'specialize:arg(1)'
-
def _collect_obj(self, obj, ignored):
# Ignore pinned objects, which are the ones still in the nursery here.
# Cache effects: don't read any flag out of 'obj' at this point.
diff --git a/rpython/memory/gc/inspector.py b/rpython/memory/gc/inspector.py
--- a/rpython/memory/gc/inspector.py
+++ b/rpython/memory/gc/inspector.py
@@ -10,62 +10,73 @@
# ---------- implementation of rpython.rlib.rgc.get_rpy_roots() ----------
+def _counting_rpy_root(obj, gc):
+ gc._count_rpy += 1
+
+def _do_count_rpy_roots(gc):
+ gc._count_rpy = 0
+ gc.enumerate_all_roots(_counting_rpy_root, gc)
+ return gc._count_rpy
+
def _append_rpy_root(obj, gc):
# Can use the gc list, but should not allocate!
# It is essential that the list is not resizable!
lst = gc._list_rpy
index = gc._count_rpy
- if index < len(lst):
- lst[index] = llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
- #else:
- # too many items. This situation is detected at the end
+ if index >= len(lst):
+ raise ValueError
gc._count_rpy = index + 1
+ lst[index] = llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
def _do_append_rpy_roots(gc, lst):
gc._count_rpy = 0
gc._list_rpy = lst
gc.enumerate_all_roots(_append_rpy_root, gc)
gc._list_rpy = None
- return gc._count_rpy
def get_rpy_roots(gc):
+ count = _do_count_rpy_roots(gc)
+ extra = 16
while True:
- result = [lltype.nullptr(llmemory.GCREF.TO)] * gc._totalroots_rpy
- count = _do_append_rpy_roots(gc, result)
- if count <= len(result): # 'count' fits inside the list
+ result = [lltype.nullptr(llmemory.GCREF.TO)] * (count + extra)
+ try:
+ _do_append_rpy_roots(gc, result)
+ except ValueError:
+ extra *= 3
+ else:
return result
- count += (count // 8)
- gc._totalroots_rpy = count + 10
# ---------- implementation of rpython.rlib.rgc.get_rpy_referents() ----------
+def _count_rpy_referent(pointer, gc):
+ gc._count_rpy += 1
+
+def _do_count_rpy_referents(gc, gcref):
+ gc._count_rpy = 0
+ gc.trace(llmemory.cast_ptr_to_adr(gcref), _count_rpy_referent, gc)
+ return gc._count_rpy
+
def _append_rpy_referent(pointer, gc):
# Can use the gc list, but should not allocate!
# It is essential that the list is not resizable!
lst = gc._list_rpy
index = gc._count_rpy
- if index < len(lst):
- lst[index] = llmemory.cast_adr_to_ptr(pointer.address[0],
- llmemory.GCREF)
- #else:
- # too many items. This situation is detected at the end
+ if index >= len(lst):
+ raise ValueError
gc._count_rpy = index + 1
+ lst[index] = llmemory.cast_adr_to_ptr(pointer.address[0],
+ llmemory.GCREF)
def _do_append_rpy_referents(gc, gcref, lst):
gc._count_rpy = 0
gc._list_rpy = lst
gc.trace(llmemory.cast_ptr_to_adr(gcref), _append_rpy_referent, gc)
- gc._list_rpy = None
- return gc._count_rpy
def get_rpy_referents(gc, gcref):
- count = 7
- while True:
- result = [lltype.nullptr(llmemory.GCREF.TO)] * count
- count = _do_append_rpy_referents(gc, gcref, result)
- if count <= len(result): # 'count' fits inside the list
- return result
- count += (count // 8)
+ count = _do_count_rpy_referents(gc, gcref)
+ result = [lltype.nullptr(llmemory.GCREF.TO)] * count
+ _do_append_rpy_referents(gc, gcref, result)
+ return result
# ----------
diff --git a/rpython/memory/gc/minimark.py b/rpython/memory/gc/minimark.py
--- a/rpython/memory/gc/minimark.py
+++ b/rpython/memory/gc/minimark.py
@@ -1780,11 +1780,6 @@
MovingGCBase.enumerate_all_roots(self, callback, arg)
enumerate_all_roots._annspecialcase_ = 'specialize:arg(1)'
- def enum_live_with_finalizers(self, callback, arg):
- self.probably_young_objects_with_finalizers.foreach(callback, arg, 2)
- self.old_objects_with_finalizers.foreach(callback, arg, 2)
- enum_live_with_finalizers._annspecialcase_ = 'specialize:arg(1)'
-
@staticmethod
def _collect_obj(obj, objects_to_trace):
objects_to_trace.append(obj)
diff --git a/rpython/memory/support.py b/rpython/memory/support.py
--- a/rpython/memory/support.py
+++ b/rpython/memory/support.py
@@ -269,23 +269,22 @@
self.index_in_oldest = index + 1
return result
- def foreach(self, callback, arg, step=1):
+ def foreach(self, callback, arg):
"""Invoke 'callback(address, arg)' for all addresses in the deque.
Typically, 'callback' is a bound method and 'arg' can be None.
- If step > 1, only calls it for addresses multiple of 'step'.
"""
chunk = self.oldest_chunk
index = self.index_in_oldest
while chunk is not self.newest_chunk:
while index < chunk_size:
callback(chunk.items[index], arg)
- index += step
+ index += 1
chunk = chunk.next
- index -= chunk_size
+ index = 0
limit = self.index_in_newest
while index < limit:
callback(chunk.items[index], arg)
- index += step
+ index += 1
foreach._annspecialcase_ = 'specialize:arg(1)'
def delete(self):
diff --git a/rpython/memory/test/test_support.py b/rpython/memory/test/test_support.py
--- a/rpython/memory/test/test_support.py
+++ b/rpython/memory/test/test_support.py
@@ -160,10 +160,6 @@
ll.foreach(callback, 42)
assert seen == addrs
- seen = []
- ll.foreach(callback, 42, step=2)
- assert seen == addrs[::2]
-
for a in addrs:
b = ll.popleft()
assert a == b
More information about the pypy-commit
mailing list