[pypy-commit] pypy gc-minimark-pinning: a direct test for the return
fijal
noreply at buildbot.pypy.org
Sat Apr 14 18:40:49 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: gc-minimark-pinning
Changeset: r54367:5a93314d513e
Date: 2012-04-14 18:40 +0200
http://bitbucket.org/pypy/pypy/changeset/5a93314d513e/
Log: a direct test for the return
diff --git a/pypy/rpython/memory/gc/minimark.py b/pypy/rpython/memory/gc/minimark.py
--- a/pypy/rpython/memory/gc/minimark.py
+++ b/pypy/rpython/memory/gc/minimark.py
@@ -333,7 +333,8 @@
# external factors, like trackgcroot or the handling of the write
# barrier. Implemented by still using 'minsize' for the nursery
# size (needed to handle mallocs just below 'large_objects') but
- # hacking at the current nursery position in collect_and_reserve().
+ # hacking at the current nursery position in
+ # maybe_collect_and_reserve().
if newsize <= 0:
newsize = 4*1024*1024 # fixed to 4MB by default
# (it was env.estimate_best_nursery_size())
@@ -502,7 +503,7 @@
result = self.nursery_free
self.nursery_free = result + totalsize
if self.nursery_free > self.nursery_top:
- result = self.collect_and_reserve(totalsize)
+ result = self.maybe_collect_and_reserve(totalsize)
#
# Build the object.
llarena.arena_reserve(result, totalsize)
@@ -561,7 +562,7 @@
result = self.nursery_free
self.nursery_free = result + totalsize
if self.nursery_free > self.nursery_top:
- result = self.collect_and_reserve(totalsize)
+ result = self.maybe_collect_and_reserve(totalsize)
#
# Build the object.
llarena.arena_reserve(result, totalsize)
@@ -580,7 +581,7 @@
if gen > 0:
self.major_collection()
- def collect_and_reserve(self, totalsize):
+ def maybe_collect_and_reserve(self, totalsize):
"""To call when nursery_free overflows nursery_top.
Do a minor collection, and possibly also a major collection,
and finally reserve 'totalsize' bytes at the start of the
@@ -595,7 +596,6 @@
self.nursery_free = self.nursery_free + cur_obj_size
self.nursery_top = self.nursery_barriers.popleft()
if self.nursery_free + totalsize <= self.nursery_top:
- llarena.arena_reserve(self.nursery_free, totalsize)
res = self.nursery_free
self.nursery_free = res + totalsize
return res
@@ -622,7 +622,7 @@
self.nursery_free = self.nursery_top - self.debug_tiny_nursery
#
return result
- collect_and_reserve._dont_inline_ = True
+ maybe_collect_and_reserve._dont_inline_ = True
def external_malloc(self, typeid, length, can_make_young=True):
@@ -789,10 +789,12 @@
not self.header(obj).tid & GCFLAG_PINNED)
def pin(self, obj):
- self.header(obj).tid |= GCFLAG_PINNED
+ if self.is_in_nursery(obj):
+ self.header(obj).tid |= GCFLAG_PINNED
def unpin(self, obj):
- self.header(obj).tid &= ~GCFLAG_PINNED
+ if self.is_in_nursery(obj):
+ self.header(obj).tid &= ~GCFLAG_PINNED
def shrink_array(self, obj, smallerlength):
#
diff --git a/pypy/rpython/memory/gc/test/test_direct.py b/pypy/rpython/memory/gc/test/test_direct.py
--- a/pypy/rpython/memory/gc/test/test_direct.py
+++ b/pypy/rpython/memory/gc/test/test_direct.py
@@ -522,6 +522,19 @@
self.stackroots.pop()
test_card_marker.GC_PARAMS = {"card_page_indices": 4}
+ def test_pin_1(self):
+ self.malloc(S)
+ s2 = self.malloc(S)
+ self.gc.pin(llmemory.cast_ptr_to_adr(s2))
+ self.stackroots.append(s2)
+ self.gc.minor_collection()
+ self.stackroots.pop()
+ self.malloc(S)
+ one = self.gc.nursery_free
+ self.malloc(S)
+ two = self.gc.nursery_free
+ assert one != two
+
def test_writebarrier_before_copy(self):
from pypy.rpython.memory.gc import minimark
largeobj_size = self.gc.nonlarge_max + 1
More information about the pypy-commit
mailing list