[pypy-commit] pypy stm-gc-2: tweaks
arigo
noreply at buildbot.pypy.org
Wed Apr 17 14:22:41 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc-2
Changeset: r63443:27210e49f4c5
Date: 2013-04-17 14:22 +0200
http://bitbucket.org/pypy/pypy/changeset/27210e49f4c5/
Log: tweaks
diff --git a/rpython/memory/gc/stmshared.py b/rpython/memory/gc/stmshared.py
--- a/rpython/memory/gc/stmshared.py
+++ b/rpython/memory/gc/stmshared.py
@@ -63,6 +63,7 @@
self.low_usage_pages = lltype.malloc(rffi.CArray(PAGE_PTR), length,
flavor='raw', zero=True,
immortal=True)
+ # ^^^ XXX not used so far
self.full_pages = lltype.malloc(rffi.CArray(PAGE_PTR), length,
flavor='raw', zero=True,
immortal=True)
@@ -197,7 +198,8 @@
return llarena.arena_malloc(
llmemory.raw_malloc_usage(totalsize), 0)
- def malloc_object(self, totalsize):
+ def malloc_object(self, objsize):
+ totalsize = self.gc.gcheaderbuilder.size_gc_header + objsize
addr = self.malloc_object_addr(totalsize)
llarena.arena_reserve(addr, _dummy_size(totalsize))
return addr + self.gc.gcheaderbuilder.size_gc_header
@@ -210,9 +212,10 @@
def free_object(self, obj):
adr1 = obj - self.gc.gcheaderbuilder.size_gc_header
- osize = self.gc.get_size_incl_hash(obj)
- if osize <= self.sharedarea.small_request_threshold:
- size_class = (osize + WORD_POWER_2 - 1) >> WORD_POWER_2
+ totalsize = (self.gc.gcheaderbuilder.size_gc_header +
+ self.gc.get_size_incl_hash(obj))
+ if totalsize <= self.sharedarea.small_request_threshold:
+ size_class = (totalsize + WORD_POWER_2 - 1) >> WORD_POWER_2
self._free_size_class(adr1, size_class)
else:
llarena.arena_free(llarena.getfakearenaaddress(adr1))
@@ -232,7 +235,8 @@
def gift_all_pages_to_shared_area(self):
"""Send to the shared area all my pages. For now we don't extract
the information about which locations are free or not; we just stick
- them into 'full_pages' and leave the next global GC to figure it out.
+ them into 'full_pages' and leave it to the next global GC to figure
+ them out.
"""
stmshared = self.sharedarea
stmshared.acquire_global_lock()
diff --git a/rpython/memory/gc/test/test_stmshared.py b/rpython/memory/gc/test/test_stmshared.py
--- a/rpython/memory/gc/test/test_stmshared.py
+++ b/rpython/memory/gc/test/test_stmshared.py
@@ -3,9 +3,11 @@
from rpython.memory.gc.stmshared import StmGCThreadLocalAllocator
+SGH = 3
+
class FakeGC:
class gcheaderbuilder:
- size_gc_header = 3
+ size_gc_header = SGH
def __init__(self):
self._object_sizes = {}
def set_size(self, obj, size):
@@ -20,17 +22,17 @@
shared = StmGCSharedArea(gc, 9*WORD, 2*WORD)
shared.setup()
thl1 = StmGCThreadLocalAllocator(shared)
- thl1.malloc_object(2*WORD-1)
+ thl1.malloc_object(2*WORD-1-SGH)
assert len(thl1._seen_pages) == 1
- thl1.malloc_object(2*WORD)
+ thl1.malloc_object(2*WORD-SGH)
assert len(thl1._seen_pages) == 1
- thl1.malloc_object(1*WORD)
+ thl1.malloc_object(1*WORD-SGH)
assert len(thl1._seen_pages) == 2
- thl1.malloc_object(2*WORD)
+ thl1.malloc_object(2*WORD-SGH)
assert len(thl1._seen_pages) == 2
- thl1.malloc_object(2*WORD)
+ thl1.malloc_object(2*WORD-SGH)
assert len(thl1._seen_pages) == 3
- thl1.malloc_object(2*WORD)
+ thl1.malloc_object(2*WORD-SGH)
assert len(thl1._seen_pages) == 3
assert thl1.count_pages == 3
thl1.delete()
@@ -40,10 +42,10 @@
shared = StmGCSharedArea(gc, 9*WORD, 2*WORD)
shared.setup()
thl1 = StmGCThreadLocalAllocator(shared)
- obj = thl1.malloc_object(2*WORD)
- gc.set_size(obj, 2*WORD)
+ obj = thl1.malloc_object(2*WORD-SGH)
+ gc.set_size(obj, 2*WORD-SGH)
thl1.free_object(obj)
- obj2 = thl1.malloc_object(2*WORD)
+ obj2 = thl1.malloc_object(2*WORD-SGH)
assert obj2 == obj # reusing the same location
thl1.delete()
@@ -52,8 +54,8 @@
shared = StmGCSharedArea(gc, 9*WORD, 2*WORD)
shared.setup()
thl1 = StmGCThreadLocalAllocator(shared)
- obj = thl1.malloc_object(3*WORD)
- gc.set_size(obj, 3*WORD)
+ obj = thl1.malloc_object(3*WORD-SGH)
+ gc.set_size(obj, 3*WORD-SGH)
thl1.free_object(obj)
thl1.delete()
@@ -65,11 +67,11 @@
thl2 = StmGCThreadLocalAllocator(shared)
#
assert len(thl1._seen_pages) == 0
- thl1.malloc_object(2*WORD)
+ thl1.malloc_object(2*WORD-SGH)
assert len(thl1._seen_pages) == 1
#
assert len(thl2._seen_pages) == 0
- thl2.malloc_object(2*WORD)
+ thl2.malloc_object(2*WORD-SGH)
assert len(thl2._seen_pages) == 1
#
thl1.delete()
@@ -80,7 +82,7 @@
shared = StmGCSharedArea(gc, 9*WORD, 2*WORD)
shared.setup()
thl1 = StmGCThreadLocalAllocator(shared)
- thl1.malloc_object(2*WORD)
+ thl1.malloc_object(2*WORD-SGH)
assert thl1.count_pages == 1
assert len(thl1._seen_pages) == 1
#
More information about the pypy-commit
mailing list