[pypy-svn] r47391 - in pypy/dist/pypy/rpython/memory: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Oct 11 11:48:00 CEST 2007
Author: cfbolz
Date: Thu Oct 11 11:48:00 2007
New Revision: 47391
Modified:
pypy/dist/pypy/rpython/memory/gc.py
pypy/dist/pypy/rpython/memory/test/test_gc.py
Log:
kill deferred refcounting: it was broken and unmaintained.
Modified: pypy/dist/pypy/rpython/memory/gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gc.py (original)
+++ pypy/dist/pypy/rpython/memory/gc.py Thu Oct 11 11:48:00 2007
@@ -1250,134 +1250,6 @@
STATISTICS_NUMBERS = 0
-class DeferredRefcountingGC(GCBase):
- _alloc_flavor_ = "raw"
-
- def __init__(self, AddressLinkedList, max_refcount_zero=50, get_roots=None):
- self.zero_ref_counts = None
- self.AddressLinkedList = AddressLinkedList
- self.length_zero_ref_counts = 0
- self.max_refcount_zero = max_refcount_zero
- #self.set_query_functions(None, None, None, None, None, None, None)
- self.get_roots = get_roots
- self.collecting = False
-
- def setup(self):
- self.zero_ref_counts = self.AddressLinkedList()
-
-
- def malloc(self, typeid, length=0):
- size = self.fixed_size(typeid)
- if self.is_varsize(typeid):
- size += length * self.varsize_item_sizes(typeid)
- size_gc_header = self.size_gc_header()
- result = raw_malloc(size + size_gc_header)
-## print "mallocing %s, size %s at %s" % (typeid, size, result)
- if not result:
- raise memoryError
- result.signed[0] = 0 # refcount
- result.signed[1] = typeid
- return result + size_gc_header
-
- def collect(self):
- if self.collecting:
- return
- else:
- self.collecting = True
- roots = self.get_roots()
- roots_copy = self.AddressLinkedList()
- curr = roots.pop()
- while curr != NULL:
-## print "root", root, root.address[0]
-## assert self.refcount(root.address[0]) >= 0, "refcount negative"
- self.incref(curr.address[0])
- roots_copy.append(curr)
- curr = roots.pop()
- roots = roots_copy
- dealloc_list = self.AddressLinkedList()
- self.length_zero_ref_counts = 0
- while self.zero_ref_counts.non_empty():
- candidate = self.zero_ref_counts.pop()
- refcount = self.refcount(candidate)
- typeid = (candidate - self.size_gc_header()).signed[1]
- if (refcount == 0 and typeid >= 0):
- (candidate - self.size_gc_header()).signed[1] = -typeid - 1
- dealloc_list.append(candidate)
- while dealloc_list.non_empty():
- deallocate = dealloc_list.pop()
- typeid = (deallocate - self.size_gc_header()).signed[1]
- (deallocate - self.size_gc_header()).signed[1] = -typeid - 1
- self.deallocate(deallocate)
- dealloc_list.delete()
- while roots.non_empty():
- root = roots.pop()
- self.decref(root.address[0])
- roots.delete()
- self.collecting = False
-
- def write_barrier(self, addr, addr_to, addr_struct):
- self.decref(addr_to.address[0])
- addr_to.address[0] = addr
- self.incref(addr)
-
- def deallocate(self, obj):
- gc_info = obj - self.size_gc_header()
- typeid = gc_info.signed[1]
-## print "deallocating", obj, typeid
- offsets = self.offsets_to_gc_pointers(typeid)
- i = 0
- while i < len(offsets):
- pointer = obj + offsets[i]
- self.decref(pointer.address[0])
- i += 1
- if self.is_varsize(typeid):
- offset = self.varsize_offset_to_variable_part(
- typeid)
- length = (obj + self.varsize_offset_to_length(typeid)).signed[0]
- offsets = self.varsize_offsets_to_gcpointers_in_var_part(typeid)
- itemlength = self.varsize_item_sizes(typeid)
- i = 0
- while i < length:
- item = obj + offset + itemlength * i
- j = 0
- while j < len(offsets):
- pointer = item + offsets[j]
- self.decref(pointer.address[0])
- j += 1
- i += 1
- raw_free(gc_info)
-
- def incref(self, addr):
- if addr == NULL:
- return
- (addr - self.size_gc_header()).signed[0] += 1
-
- def decref(self, addr):
- if addr == NULL:
- return
- refcount = (addr - self.size_gc_header()).signed[0]
-## assert refcount > 0, "neg refcount"
- if refcount == 1:
- self.zero_ref_counts.append(addr)
- self.length_zero_ref_counts += 1
- if self.length_zero_ref_counts > self.max_refcount_zero:
- self.collect()
- (addr - self.size_gc_header()).signed[0] = refcount - 1
-
- def refcount(self, addr):
- return (addr - self.size_gc_header()).signed[0]
-
- def init_gc_object(self, addr, typeid):
- addr.signed[0] = 0 # refcount
- addr.signed[1] = typeid
-
- def init_gc_object_immortal(self, addr, typeid):
- addr.signed[0] = sys.maxint // 2 # refcount
- addr.signed[1] = typeid
-
- def size_gc_header(self, typeid=0):
- XXX
-
# ____________________________________________________________
def choose_gc_from_config(config):
Modified: pypy/dist/pypy/rpython/memory/test/test_gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_gc.py (original)
+++ pypy/dist/pypy/rpython/memory/test/test_gc.py Thu Oct 11 11:48:00 2007
@@ -260,8 +260,3 @@
class TestGrowingSemiSpaceGC(TestSemiSpaceGC):
GC_PARAMS = {'space_size': 64}
-
-class TestDeferredRefcountingGC(GCTest):
- from pypy.rpython.memory.gc import DeferredRefcountingGC as GCClass
- def setup_class(cls):
- py.test.skip("DeferredRefcounting is unmaintained")
More information about the Pypy-commit
mailing list