[pypy-svn] r70944 - in pypy/branch/gc-huge-list/pypy: rlib rpython rpython/memory rpython/memory/gc
arigo at codespeak.net
arigo at codespeak.net
Thu Jan 28 13:07:37 CET 2010
Author: arigo
Date: Thu Jan 28 13:07:36 2010
New Revision: 70944
Modified:
pypy/branch/gc-huge-list/pypy/rlib/rgc.py
pypy/branch/gc-huge-list/pypy/rpython/llinterp.py
pypy/branch/gc-huge-list/pypy/rpython/memory/gc/generation.py
pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py
pypy/branch/gc-huge-list/pypy/rpython/memory/gcwrapper.py
Log:
(fijal) IN-PROGRESS commit. Work on missing places
Modified: pypy/branch/gc-huge-list/pypy/rlib/rgc.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rlib/rgc.py (original)
+++ pypy/branch/gc-huge-list/pypy/rlib/rgc.py Thu Jan 28 13:07:36 2010
@@ -258,7 +258,9 @@
if isinstance(TP.OF, lltype.Ptr) and TP.OF.TO._gckind == 'gc':
# perform a write barrier that copies necessary flags from
# source to dest
- if not llop.gc_writebarrier_before_copy(lltype.Void, source, dest):
+ if not llop.gc_writebarrier_before_copy(lltype.Void, source, dest,
+ source_start, dest_start,
+ length):
# if the write barrier is not supported, copy by hand
for i in range(length):
dest[i + dest_start] = source[i + source_start]
Modified: pypy/branch/gc-huge-list/pypy/rpython/llinterp.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rpython/llinterp.py (original)
+++ pypy/branch/gc-huge-list/pypy/rpython/llinterp.py Thu Jan 28 13:07:36 2010
@@ -760,9 +760,13 @@
def op_zero_gc_pointers_inside(self, obj):
raise NotImplementedError("zero_gc_pointers_inside")
- def op_gc_writebarrier_before_copy(self, source, dest):
+ def op_gc_writebarrier_before_copy(self, source, dest, source_start,
+ dest_start, length):
if hasattr(self.heap, 'writebarrier_before_copy'):
- return self.heap.writebarrier_before_copy(source, dest)
+ return self.heap.writebarrier_before_copy(source, dest,
+ source_start,
+ dest_start,
+ length)
else:
return True
Modified: pypy/branch/gc-huge-list/pypy/rpython/memory/gc/generation.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rpython/memory/gc/generation.py (original)
+++ pypy/branch/gc-huge-list/pypy/rpython/memory/gc/generation.py Thu Jan 28 13:07:36 2010
@@ -477,7 +477,7 @@
self.last_generation_root_objects.append(addr_struct)
def assume_young_pointers(self, addr_struct):
- XXXX
+ # XXX fix for hybrid
objhdr = self.header(addr_struct)
if objhdr.tid & GCFLAG_NO_YOUNG_PTRS:
self.old_objects_pointing_to_young.append(addr_struct)
@@ -486,7 +486,8 @@
objhdr.tid &= ~GCFLAG_NO_HEAP_PTRS
self.last_generation_root_objects.append(addr_struct)
- def _writebarrier_before_copy(self, source_addr, dest_addr):
+ def _writebarrier_before_copy(self, source_addr, dest_addr, source_start,
+ dest_start, length):
""" A hook for hybrid gc
"""
source_hdr = self.header(source_addr)
@@ -496,7 +497,8 @@
self.old_objects_pointing_to_young.append(dest_addr)
dest_hdr.tid &= ~GCFLAG_NO_YOUNG_PTRS
- def writebarrier_before_copy(self, source_addr, dest_addr):
+ def writebarrier_before_copy(self, source_addr, dest_addr, source_start,
+ dest_start, length):
""" This has the same effect as calling writebarrier over
each element in dest copied from source, except it might reset
one of the following flags a bit too eagerly, which means we'll have
Modified: pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py (original)
+++ pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py Thu Jan 28 13:07:36 2010
@@ -675,25 +675,47 @@
nextaddr.char[0] = chr(0)
i += 1
- def _writebarrier_before_copy(self, source_addr, dest_addr):
+ def mark_cards(self, addr, start, end):
+ hdr = self.header(addr)
+ hdr |= GCFLAG_CARDMARK_SET
+
+ def mark_cards(self, addr, start, length):
+ hdr = self.header(addr)
+ hdr |= GCFLAG_CARDMARK_SET
+ typeid = hdr.tid
+ itemsize = self.varsize_item_sizes(typeid)
+ offset = self.varsize_offset_to_variable_part(typeid) + itemsize * start
+ # XXX check details
+ first_card = raw_malloc_usage(offset) / self.card_size
+ offset += itemsize * length
+ last_card = raw_malloc_usage(offset) / self.card_size
+ i = first_card >> 3
+ while i < last_card >> 3:
+ card_adr = addr_struct - size_gc_header + llarena.negative_byte_index(i)
+ card_adr.char[0] = chr(0xff)
+
+ def _writebarrier_before_copy(self, source_addr, dest_addr, source_start,
+ dest_start, length):
""" A hook for hybrid gc
"""
source_hdr = self.header(source_addr)
dest_hdr = self.header(dest_addr)
if source_hdr.tid & GCFLAG_NO_YOUNG_PTRS == 0:
if dest_hdr.tid & GCFLAG_CARDMARKS:
- xxx # we copy from small -> larg list, set all cards
- # there might be an object in source that is in nursery
- self.old_objects_pointing_to_young.append(dest_addr)
- dest_hdr.tid &= ~GCFLAG_NO_YOUNG_PTRS
+ # we copy from small -> larg list, set all cards up
+ self.mark_cards(dest_addr, dest_start, length)
+ return
if source_hdr.tid & GCFLAG_CARDMARK_SET:
if dest_adr.tid & GCFLAG_CARDMARK_SET:
- # large -> large, copy cardmarks
- xxx
- else:
- # large -> small
- self.old_objects_pointing_to_young.append(dest_addr)
- dest_hdr.tid &= ~GCFLAG_NO_YOUNG_PTRS
+ # large -> large, copy cardmarks.
+ # XXX for now just set all cards within range
+ # that's why we need source_start, possibly
+ self.mark_cards(dest_addr, dest_start, length)
+ return
+ # large -> small
+ # there might be an object in source that is in nursery
+ self.old_objects_pointing_to_young.append(dest_addr)
+ dest_hdr.tid &= ~GCFLAG_NO_YOUNG_PTRS
def debug_check_object_no_nursery_pointer(self, obj):
tid = self.header(obj).tid
Modified: pypy/branch/gc-huge-list/pypy/rpython/memory/gcwrapper.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rpython/memory/gcwrapper.py (original)
+++ pypy/branch/gc-huge-list/pypy/rpython/memory/gcwrapper.py Thu Jan 28 13:07:36 2010
@@ -112,11 +112,14 @@
ptr = lltype.cast_opaque_ptr(llmemory.GCREF, ptr)
return self.gc.id(ptr)
- def writebarrier_before_copy(self, source, dest):
+ def writebarrier_before_copy(self, source, dest, source_start, dest_start,
+ length):
if self.gc.needs_write_barrier:
source_addr = llmemory.cast_ptr_to_adr(source)
dest_addr = llmemory.cast_ptr_to_adr(dest)
- return self.gc.writebarrier_before_copy(source_addr, dest_addr)
+ return self.gc.writebarrier_before_copy(source_addr, dest_addr,
+ source_start, dest_start,
+ length)
else:
return True
More information about the Pypy-commit
mailing list